diff options
| author | Juri Linkov | 2018-01-23 00:14:10 +0200 |
|---|---|---|
| committer | Juri Linkov | 2018-01-23 00:14:10 +0200 |
| commit | 71e458505f3f3fb5e545b83f7609dac5dff1c289 (patch) | |
| tree | 02f10d3dc9b2cca639979b85525f0b10a730d38b | |
| parent | 4aabb425dba14c752befa15f609cc4864be41ef6 (diff) | |
| download | emacs-71e458505f3f3fb5e545b83f7609dac5dff1c289.tar.gz emacs-71e458505f3f3fb5e545b83f7609dac5dff1c289.zip | |
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.
| -rw-r--r-- | lisp/comint.el | 12 | ||||
| -rw-r--r-- | lisp/dired-aux.el | 12 | ||||
| -rw-r--r-- | lisp/isearch.el | 7 |
3 files changed, 21 insertions, 10 deletions
diff --git a/lisp/comint.el b/lisp/comint.el index a79e34b36c3..8dba317099c 100644 --- a/lisp/comint.el +++ b/lisp/comint.el | |||
| @@ -1434,14 +1434,14 @@ If nil, Isearch operates on the whole comint buffer." | |||
| 1434 | (defun comint-history-isearch-backward () | 1434 | (defun comint-history-isearch-backward () |
| 1435 | "Search for a string backward in input history using Isearch." | 1435 | "Search for a string backward in input history using Isearch." |
| 1436 | (interactive) | 1436 | (interactive) |
| 1437 | (let ((comint-history-isearch t)) | 1437 | (setq comint-history-isearch t) |
| 1438 | (isearch-backward nil t))) | 1438 | (isearch-backward nil t)) |
| 1439 | 1439 | ||
| 1440 | (defun comint-history-isearch-backward-regexp () | 1440 | (defun comint-history-isearch-backward-regexp () |
| 1441 | "Search for a regular expression backward in input history using Isearch." | 1441 | "Search for a regular expression backward in input history using Isearch." |
| 1442 | (interactive) | 1442 | (interactive) |
| 1443 | (let ((comint-history-isearch t)) | 1443 | (setq comint-history-isearch t) |
| 1444 | (isearch-backward-regexp nil t))) | 1444 | (isearch-backward-regexp nil t)) |
| 1445 | 1445 | ||
| 1446 | (defvar-local comint-history-isearch-message-overlay nil) | 1446 | (defvar-local comint-history-isearch-message-overlay nil) |
| 1447 | 1447 | ||
| @@ -1472,7 +1472,9 @@ Intended to be added to `isearch-mode-hook' in `comint-mode'." | |||
| 1472 | (setq isearch-message-function nil) | 1472 | (setq isearch-message-function nil) |
| 1473 | (setq isearch-wrap-function nil) | 1473 | (setq isearch-wrap-function nil) |
| 1474 | (setq isearch-push-state-function nil) | 1474 | (setq isearch-push-state-function nil) |
| 1475 | (remove-hook 'isearch-mode-end-hook 'comint-history-isearch-end t)) | 1475 | (remove-hook 'isearch-mode-end-hook 'comint-history-isearch-end t) |
| 1476 | (unless isearch-suspended | ||
| 1477 | (custom-reevaluate-setting 'comint-history-isearch))) | ||
| 1476 | 1478 | ||
| 1477 | (defun comint-goto-input (pos) | 1479 | (defun comint-goto-input (pos) |
| 1478 | "Put input history item of the absolute history position POS." | 1480 | "Put input history item of the absolute history position POS." |
diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index 223b254c4ba..55b68a372e3 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el | |||
| @@ -2766,7 +2766,9 @@ Intended to be added to `isearch-mode-hook'." | |||
| 2766 | "Clean up the Dired file name search after terminating isearch." | 2766 | "Clean up the Dired file name search after terminating isearch." |
| 2767 | (define-key isearch-mode-map "\M-sff" nil) | 2767 | (define-key isearch-mode-map "\M-sff" nil) |
| 2768 | (dired-isearch-filenames-mode -1) | 2768 | (dired-isearch-filenames-mode -1) |
| 2769 | (remove-hook 'isearch-mode-end-hook 'dired-isearch-filenames-end t)) | 2769 | (remove-hook 'isearch-mode-end-hook 'dired-isearch-filenames-end t) |
| 2770 | (unless isearch-suspended | ||
| 2771 | (custom-reevaluate-setting 'dired-isearch-filenames))) | ||
| 2770 | 2772 | ||
| 2771 | (defun dired-isearch-filter-filenames (beg end) | 2773 | (defun dired-isearch-filter-filenames (beg end) |
| 2772 | "Test whether some part of the current search match is inside a file name. | 2774 | "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')." | |||
| 2779 | (defun dired-isearch-filenames () | 2781 | (defun dired-isearch-filenames () |
| 2780 | "Search for a string using Isearch only in file names in the Dired buffer." | 2782 | "Search for a string using Isearch only in file names in the Dired buffer." |
| 2781 | (interactive) | 2783 | (interactive) |
| 2782 | (let ((dired-isearch-filenames t)) | 2784 | (setq dired-isearch-filenames t) |
| 2783 | (isearch-forward nil t))) | 2785 | (isearch-forward nil t)) |
| 2784 | 2786 | ||
| 2785 | ;;;###autoload | 2787 | ;;;###autoload |
| 2786 | (defun dired-isearch-filenames-regexp () | 2788 | (defun dired-isearch-filenames-regexp () |
| 2787 | "Search for a regexp using Isearch only in file names in the Dired buffer." | 2789 | "Search for a regexp using Isearch only in file names in the Dired buffer." |
| 2788 | (interactive) | 2790 | (interactive) |
| 2789 | (let ((dired-isearch-filenames t)) | 2791 | (setq dired-isearch-filenames t) |
| 2790 | (isearch-forward-regexp nil t))) | 2792 | (isearch-forward-regexp nil t)) |
| 2791 | 2793 | ||
| 2792 | 2794 | ||
| 2793 | ;; Functions for searching in tags style among marked files. | 2795 | ;; Functions for searching in tags style among marked files. |
diff --git a/lisp/isearch.el b/lisp/isearch.el index 3725779703e..23dd9afccdb 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el | |||
| @@ -1233,6 +1233,8 @@ If this is set inside code wrapped by the macro | |||
| 1233 | (define-obsolete-variable-alias 'isearch-new-word | 1233 | (define-obsolete-variable-alias 'isearch-new-word |
| 1234 | 'isearch-new-regexp-function "25.1") | 1234 | 'isearch-new-regexp-function "25.1") |
| 1235 | 1235 | ||
| 1236 | (defvar isearch-suspended nil) | ||
| 1237 | |||
| 1236 | (defmacro with-isearch-suspended (&rest body) | 1238 | (defmacro with-isearch-suspended (&rest body) |
| 1237 | "Exit Isearch mode, run BODY, and reinvoke the pending search. | 1239 | "Exit Isearch mode, run BODY, and reinvoke the pending search. |
| 1238 | You can update the global isearch variables by setting new values to | 1240 | 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 | |||
| 1299 | isearch-original-minibuffer-message-timeout) | 1301 | isearch-original-minibuffer-message-timeout) |
| 1300 | old-point old-other-end) | 1302 | old-point old-other-end) |
| 1301 | 1303 | ||
| 1304 | (setq isearch-suspended t) | ||
| 1305 | |||
| 1302 | ;; Actually terminate isearching until editing is done. | 1306 | ;; Actually terminate isearching until editing is done. |
| 1303 | ;; This is so that the user can do anything without failure, | 1307 | ;; This is so that the user can do anything without failure, |
| 1304 | ;; like switch buffers and start another isearch, and return. | 1308 | ;; 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 | |||
| 1313 | (unwind-protect | 1317 | (unwind-protect |
| 1314 | (progn ,@body) | 1318 | (progn ,@body) |
| 1315 | 1319 | ||
| 1320 | (setq isearch-suspended nil) | ||
| 1321 | |||
| 1316 | ;; Always resume isearching by restarting it. | 1322 | ;; Always resume isearching by restarting it. |
| 1317 | (isearch-mode isearch-forward | 1323 | (isearch-mode isearch-forward |
| 1318 | isearch-regexp | 1324 | isearch-regexp |
| @@ -1374,6 +1380,7 @@ You can update the global isearch variables by setting new values to | |||
| 1374 | (message ""))))) | 1380 | (message ""))))) |
| 1375 | 1381 | ||
| 1376 | (quit ; handle abort-recursive-edit | 1382 | (quit ; handle abort-recursive-edit |
| 1383 | (setq isearch-suspended nil) | ||
| 1377 | (isearch-abort) ;; outside of let to restore outside global values | 1384 | (isearch-abort) ;; outside of let to restore outside global values |
| 1378 | ))) | 1385 | ))) |
| 1379 | 1386 | ||