unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* M-y in isearch mode
@ 2011-05-02 13:59 Leo
  2011-05-02 16:27 ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Leo @ 2011-05-02 13:59 UTC (permalink / raw)
  To: emacs-devel

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)





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-05-03  3:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-02 13:59 M-y in isearch mode Leo
2011-05-02 16:27 ` Stefan Monnier
2011-05-02 16:51   ` Leo
2011-05-02 18:16     ` Stefan Monnier
2011-05-03  3:41       ` Leo
2011-05-02 21:21     ` Chong Yidong

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).