all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Leo <sdl.web@gmail.com>
To: emacs-devel@gnu.org
Subject: M-y in isearch mode
Date: Mon, 02 May 2011 21:59:07 +0800	[thread overview]
Message-ID: <m1iptt5hlg.fsf@th041070.ip.tsinghua.edu.cn> (raw)

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	other threads:[~2011-05-02 13:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-02 13:59 Leo [this message]
2011-05-02 16:27 ` M-y in isearch mode 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m1iptt5hlg.fsf@th041070.ip.tsinghua.edu.cn \
    --to=sdl.web@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.