emacs-diffs
[Top][All Lists]
Advanced

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

master 75191b0: In Isearch bind 'C-s M-y' to isearch-yank-pop-only with


From: Juri Linkov
Subject: master 75191b0: In Isearch bind 'C-s M-y' to isearch-yank-pop-only with old code (bug#45483)
Date: Wed, 30 Dec 2020 04:31:21 -0500 (EST)

branch: master
commit 75191b0af20d1e29edb1744bd7574ed77f91f8f6
Author: Juri Linkov <juri@linkov.net>
Commit: Juri Linkov <juri@linkov.net>

    In Isearch bind 'C-s M-y' to isearch-yank-pop-only with old code (bug#45483)
    
    * lisp/isearch.el (isearch-menu-bar-yank-map, isearch-mode-map):
    (isearch-forward): Use isearch-yank-pop-only instead of isearch-yank-pop.
    (isearch-yank-pop): Mention isearch-yank-pop-only.
    (isearch-yank-pop-only): New command with old body from Emacs 27.
---
 etc/NEWS        |  5 +++--
 lisp/isearch.el | 31 ++++++++++++++++++++++++++-----
 2 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 3bfd31f..10a9259 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -232,8 +232,9 @@ forms, but this command has now been changed to work more 
like
 ** Standalone 'M-y' uses the minibuffer to complete previous kills.
 When 'M-y' is typed not after a yank command, it activates the minibuffer
 where you can browse previous kills using the minibuffer history or
-completion.  In Isearch 'C-s M-y' uses the minibuffer with completion
-on previous kills to read a string and append it to the search string.
+completion.  In Isearch, you can bind 'C-s M-y' to the command
+`isearch-yank-pop' that uses the minibuffer with completion on
+previous kills to read a string and append it to the search string.
 
 ---
 ** New user options 'copy-region-blink-delay' and 'delete-pair-blink-delay'.
diff --git a/lisp/isearch.el b/lisp/isearch.el
index 13173a2..e4d599f 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -519,7 +519,7 @@ This is like `describe-bindings', but displays only Isearch 
keys."
 (defvar isearch-menu-bar-yank-map
   (let ((map (make-sparse-keymap)))
     (define-key map [isearch-yank-pop]
-      '(menu-item "Previous kill" isearch-yank-pop
+      '(menu-item "Previous kill" isearch-yank-pop-only
                   :help "Replace previous yanked kill on search string"))
     (define-key map [isearch-yank-kill]
       '(menu-item "Current kill" isearch-yank-kill
@@ -734,7 +734,7 @@ This is like `describe-bindings', but displays only Isearch 
keys."
 
     (define-key map "\M-n" 'isearch-ring-advance)
     (define-key map "\M-p" 'isearch-ring-retreat)
-    (define-key map "\M-y" 'isearch-yank-pop)
+    (define-key map "\M-y" 'isearch-yank-pop-only)
 
     (define-key map "\M-\t" 'isearch-complete)
 
@@ -1019,7 +1019,7 @@ Type \\[isearch-yank-until-char] to yank from point until 
the next instance of a
 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
+Type \\[isearch-yank-pop-only] 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.
 Type \\[isearch-char-by-name] to add a character to search by Unicode name,\
@@ -2491,9 +2491,13 @@ If search string is empty, just beep."
   (isearch-yank-string (current-kill 0)))
 
 (defun isearch-yank-pop ()
-  "Replace just-yanked search string with previously killed string."
+  "Replace just-yanked search string with previously killed string.
+Unlike `isearch-yank-pop-only', when this command is called not immediately
+after a `isearch-yank-kill' or a `isearch-yank-pop', it activates the
+minibuffer to read a string from the `kill-ring' as `yank-pop' does."
   (interactive)
-  (if (not (memq last-command '(isearch-yank-kill isearch-yank-pop)))
+  (if (not (memq last-command '(isearch-yank-kill
+                                isearch-yank-pop isearch-yank-pop-only)))
       ;; Yank string from kill-ring-browser.
       (with-isearch-suspended
        (let ((string (read-from-kill-ring)))
@@ -2509,6 +2513,23 @@ If search string is empty, just beep."
     (isearch-pop-state)
     (isearch-yank-string (current-kill 1))))
 
+(defun isearch-yank-pop-only ()
+  "Replace just-yanked search string with previously killed string.
+Unlike `isearch-yank-pop', when this command is called not immediately
+after a `isearch-yank-kill' or a `isearch-yank-pop-only', it only pops
+the last killed string instead of activating the minibuffer to read
+a string from the `kill-ring' as `yank-pop' does."
+  (interactive)
+  (if (not (memq last-command '(isearch-yank-kill
+                                isearch-yank-pop isearch-yank-pop-only)))
+      ;; Fall back on `isearch-yank-kill' for the benefits of people
+      ;; who are used to the old behavior of `M-y' in isearch mode.
+      ;; In future, `M-y' could be changed from `isearch-yank-pop-only'
+      ;; to `isearch-yank-pop' that uses the kill-ring-browser.
+      (isearch-yank-kill)
+    (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]