mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-11-26 07:33:47 +00:00
Restore isearch correctly after M-e in special modes (bug#30187)
* lisp/isearch.el (isearch-suspended): New defvar. (with-isearch-suspended): Set isearch-suspended to t at the beginning, then set it back to nil at the end. * lisp/comint.el (comint-history-isearch-backward) (comint-history-isearch-backward-regexp): Set global value of comint-history-isearch to t. (comint-history-isearch-end): Reevaluate comint-history-isearch when isearch-edit-string finishes. * lisp/dired-aux.el (dired-isearch-filenames) (dired-isearch-filenames-regexp): Set global value of dired-isearch-filenames to t. (dired-isearch-filenames-end): Reevaluate dired-isearch-filenames when isearch-edit-string finishes.
This commit is contained in:
parent
4aabb425db
commit
71e458505f
@ -1434,14 +1434,14 @@ If nil, Isearch operates on the whole comint buffer."
|
||||
(defun comint-history-isearch-backward ()
|
||||
"Search for a string backward in input history using Isearch."
|
||||
(interactive)
|
||||
(let ((comint-history-isearch t))
|
||||
(isearch-backward nil t)))
|
||||
(setq comint-history-isearch t)
|
||||
(isearch-backward nil t))
|
||||
|
||||
(defun comint-history-isearch-backward-regexp ()
|
||||
"Search for a regular expression backward in input history using Isearch."
|
||||
(interactive)
|
||||
(let ((comint-history-isearch t))
|
||||
(isearch-backward-regexp nil t)))
|
||||
(setq comint-history-isearch t)
|
||||
(isearch-backward-regexp nil t))
|
||||
|
||||
(defvar-local comint-history-isearch-message-overlay nil)
|
||||
|
||||
@ -1472,7 +1472,9 @@ Intended to be added to `isearch-mode-hook' in `comint-mode'."
|
||||
(setq isearch-message-function nil)
|
||||
(setq isearch-wrap-function nil)
|
||||
(setq isearch-push-state-function nil)
|
||||
(remove-hook 'isearch-mode-end-hook 'comint-history-isearch-end t))
|
||||
(remove-hook 'isearch-mode-end-hook 'comint-history-isearch-end t)
|
||||
(unless isearch-suspended
|
||||
(custom-reevaluate-setting 'comint-history-isearch)))
|
||||
|
||||
(defun comint-goto-input (pos)
|
||||
"Put input history item of the absolute history position POS."
|
||||
|
@ -2766,7 +2766,9 @@ Intended to be added to `isearch-mode-hook'."
|
||||
"Clean up the Dired file name search after terminating isearch."
|
||||
(define-key isearch-mode-map "\M-sff" nil)
|
||||
(dired-isearch-filenames-mode -1)
|
||||
(remove-hook 'isearch-mode-end-hook 'dired-isearch-filenames-end t))
|
||||
(remove-hook 'isearch-mode-end-hook 'dired-isearch-filenames-end t)
|
||||
(unless isearch-suspended
|
||||
(custom-reevaluate-setting 'dired-isearch-filenames)))
|
||||
|
||||
(defun dired-isearch-filter-filenames (beg end)
|
||||
"Test whether some part of the current search match is inside a file name.
|
||||
@ -2779,15 +2781,15 @@ is part of a file name (i.e., has the text property `dired-filename')."
|
||||
(defun dired-isearch-filenames ()
|
||||
"Search for a string using Isearch only in file names in the Dired buffer."
|
||||
(interactive)
|
||||
(let ((dired-isearch-filenames t))
|
||||
(isearch-forward nil t)))
|
||||
(setq dired-isearch-filenames t)
|
||||
(isearch-forward nil t))
|
||||
|
||||
;;;###autoload
|
||||
(defun dired-isearch-filenames-regexp ()
|
||||
"Search for a regexp using Isearch only in file names in the Dired buffer."
|
||||
(interactive)
|
||||
(let ((dired-isearch-filenames t))
|
||||
(isearch-forward-regexp nil t)))
|
||||
(setq dired-isearch-filenames t)
|
||||
(isearch-forward-regexp nil t))
|
||||
|
||||
|
||||
;; Functions for searching in tags style among marked files.
|
||||
|
@ -1233,6 +1233,8 @@ If this is set inside code wrapped by the macro
|
||||
(define-obsolete-variable-alias 'isearch-new-word
|
||||
'isearch-new-regexp-function "25.1")
|
||||
|
||||
(defvar isearch-suspended nil)
|
||||
|
||||
(defmacro with-isearch-suspended (&rest body)
|
||||
"Exit Isearch mode, run BODY, and reinvoke the pending search.
|
||||
You can update the global isearch variables by setting new values to
|
||||
@ -1299,6 +1301,8 @@ You can update the global isearch variables by setting new values to
|
||||
isearch-original-minibuffer-message-timeout)
|
||||
old-point old-other-end)
|
||||
|
||||
(setq isearch-suspended t)
|
||||
|
||||
;; Actually terminate isearching until editing is done.
|
||||
;; This is so that the user can do anything without failure,
|
||||
;; like switch buffers and start another isearch, and return.
|
||||
@ -1313,6 +1317,8 @@ You can update the global isearch variables by setting new values to
|
||||
(unwind-protect
|
||||
(progn ,@body)
|
||||
|
||||
(setq isearch-suspended nil)
|
||||
|
||||
;; Always resume isearching by restarting it.
|
||||
(isearch-mode isearch-forward
|
||||
isearch-regexp
|
||||
@ -1374,6 +1380,7 @@ You can update the global isearch variables by setting new values to
|
||||
(message "")))))
|
||||
|
||||
(quit ; handle abort-recursive-edit
|
||||
(setq isearch-suspended nil)
|
||||
(isearch-abort) ;; outside of let to restore outside global values
|
||||
)))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user