From 86af0d656e6ef13c92d7eb4ec6bdfc5f204b4101 Mon Sep 17 00:00:00 2001 From: Gregory Heytings Date: Tue, 6 Apr 2021 14:14:04 +0000 Subject: [PATCH] Terminate isearch when point has moved to another buffer * lisp/isearch.el (isearch-post-command-hook): Terminate isearch when the command just executed has moved point to another buffer. --- lisp/isearch.el | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lisp/isearch.el b/lisp/isearch.el index 943e24aa56..0f0985ba83 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -1209,7 +1209,8 @@ used to set the value of `isearch-regexp-function'." ;; Save the original value of `minibuffer-message-timeout', and ;; set it to nil so that isearch's messages don't get timed out. isearch-original-minibuffer-message-timeout minibuffer-message-timeout - minibuffer-message-timeout nil) + minibuffer-message-timeout nil + isearch-buffer (current-buffer)) (if (local-variable-p 'tool-bar-map) (setq isearch-tool-bar-old-map tool-bar-map)) @@ -3012,6 +3013,9 @@ See more for options in `search-exit-option'." (goto-char isearch-pre-move-point)) (isearch-search-and-update))) (setq isearch-pre-move-point nil)) + ;; Terminate the search if point has moved to another buffer. + (unless (eq isearch-buffer (current-buffer)) + (isearch-cancel)) (force-mode-line-update)) (defun isearch-quote-char (&optional count) -- 2.30.2