diff options
Diffstat (limited to 'lisp/isearch.el')
-rw-r--r-- | lisp/isearch.el | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/lisp/isearch.el b/lisp/isearch.el index 13173a28579..fefdd16d25b 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -1,6 +1,6 @@ ;;; isearch.el --- incremental search minor mode -*- lexical-binding: t -*- -;; Copyright (C) 1992-1997, 1999-2020 Free Software Foundation, Inc. +;; Copyright (C) 1992-1997, 1999-2021 Free Software Foundation, Inc. ;; Author: Daniel LaLiberte <liberte@cs.uiuc.edu> ;; Maintainer: emacs-devel@gnu.org @@ -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) |