]> git.eshelyaron.com Git - emacs.git/commitdiff
Terminate isearch when point has moved to another buffer
authorGregory Heytings <gregory@heytings.org>
Wed, 7 Apr 2021 16:58:51 +0000 (16:58 +0000)
committerJuri Linkov <juri@linkov.net>
Thu, 8 Apr 2021 19:04:39 +0000 (22:04 +0300)
* lisp/isearch.el (isearch-post-command-hook): Terminate isearch
when the command just executed has moved point to another buffer.
https://lists.gnu.org/archive/html/emacs-devel/2021-04/msg00309.html

lisp/isearch.el

index 1ac1e63a9b7805c17cdb23dc2169d1e2688de608..5efac4c78f4bcda2068a010356699419c390597c 100644 (file)
@@ -3054,6 +3054,10 @@ 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--current-buffer (current-buffer))
+    (when (buffer-live-p isearch--current-buffer)
+      (with-current-buffer isearch--current-buffer (isearch-exit))))
   (force-mode-line-update))
 
 (defun isearch-quote-char (&optional count)