]> git.eshelyaron.com Git - emacs.git/commitdiff
Don't require isearch-update before isearch-done
authorNoam Postavsky <npostavs@gmail.com>
Sun, 4 Sep 2016 03:38:35 +0000 (23:38 -0400)
committerNoam Postavsky <npostavs@gmail.com>
Sun, 2 Oct 2016 16:27:33 +0000 (12:27 -0400)
It is useful to be able to call `isearch-done' unconditionally to
ensure a non-isearching state.

* lisp/isearch.el (isearch-done): Check that `isearch--current-buffer'
is a live buffer before using it (Bug #21091).
* test/lisp/isearch-tests.el (isearch--test-done): Test it.

(cherry picked from commit 68f4b5292781bc331b040105c4079902b993835c)

lisp/isearch.el
test/automated/isearch-tests.el

index a97247671ccd02a4a1ed7cd8ebb07fcd2efe8228..9df7627fa7ccf52ddf94a1e8e20053539b322d34 100644 (file)
@@ -1049,9 +1049,10 @@ NOPUSH is t and EDIT is t."
   (remove-hook 'mouse-leave-buffer-hook 'isearch-done)
   (remove-hook 'kbd-macro-termination-hook 'isearch-done)
   (setq isearch-lazy-highlight-start nil)
-  (with-current-buffer isearch--current-buffer
-    (setq isearch--current-buffer nil)
-    (setq cursor-sensor-inhibit (delq 'isearch cursor-sensor-inhibit)))
+  (when (buffer-live-p isearch--current-buffer)
+    (with-current-buffer isearch--current-buffer
+      (setq isearch--current-buffer nil)
+      (setq cursor-sensor-inhibit (delq 'isearch cursor-sensor-inhibit))))
 
   ;; Called by all commands that terminate isearch-mode.
   ;; If NOPUSH is non-nil, we don't push the string on the search ring.
index 48c342403c92d9a235d508082c8f3f9f385940eb..52f312d0b97c00a26436706bc5e2cc327c9655bb 100644 (file)
     (isearch-update)
     (should (equal isearch--current-buffer (current-buffer)))))
 
+(ert-deftest isearch--test-done ()
+  ;; Normal operation.
+  (isearch-update)
+  (isearch-done)
+  (should-not isearch--current-buffer)
+  ;; Bug #21091: let `isearch-done' work without `isearch-update'.
+  (isearch-done))
+
 (provide 'isearch-tests)
 ;;; isearch-tests.el ends here