emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

M-y in isearch mode


From: Leo
Subject: M-y in isearch mode
Date: Mon, 02 May 2011 21:59:07 +0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3.50 (Mac OS X 10.6.7)

Hello all,

I would like to propose binding M-y to a new command isearch-yank-pop as
in the attached patch. Please review it.

Thanks - Leo

=== modified file 'lisp/isearch.el'
--- lisp/isearch.el     2011-04-19 13:44:55 +0000
+++ lisp/isearch.el     2011-05-02 13:51:48 +0000
@@ -473,7 +473,7 @@
 
     (define-key map "\M-n" 'isearch-ring-advance)
     (define-key map "\M-p" 'isearch-ring-retreat)
-    (define-key map "\M-y" 'isearch-yank-kill)
+    (define-key map "\M-y" 'isearch-yank-pop)
 
     (define-key map "\M-\t" 'isearch-complete)
 
@@ -637,6 +637,8 @@
 Type \\[isearch-yank-line] to yank rest of line onto end of search string\
  and search for it.
 Type \\[isearch-yank-kill] to yank the last string of killed text.
+Type \\[isearch-yank-pop] to replace string just yanked into search prompt
+ with string killed before it.
 Type \\[isearch-quote-char] to quote control character to search for it.
 \\[isearch-abort] while searching or when search has failed cancels input\
  back to what has
@@ -1497,6 +1499,18 @@
   (interactive)
   (isearch-yank-string (current-kill 0)))
 
+(defun isearch-yank-pop ()
+  "Replace just-yanked search string with previously killed string.
+This command is allowed only immediately after a
+`isearch-yank-kill' or `isearch-yank-pop'."
+  (interactive)
+  (if (not (memq last-command '(isearch-yank-kill isearch-yank-pop)))
+      (let ((isearch-message-suffix-add
+            " [previous isearch command was not a yank]"))
+       (isearch-update))
+    (isearch-pop-state)
+    (isearch-yank-string (current-kill 1))))
+
 (defun isearch-yank-x-selection ()
   "Pull current X selection into search string."
   (interactive)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]