summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoam Postavsky <npostavs@gmail.com>2016-09-03 23:38:35 -0400
committerNoam Postavsky <npostavs@gmail.com>2016-10-02 12:27:33 -0400
commit623401267a66929a1c13c264e0dc40ba2599500f (patch)
treefb7eace60f90aac504b5767df866949363b839e7
parent5e50114d2495dab67793e76411d10c93bf411e03 (diff)
downloademacs-scratch/backports-25.2-strict.tar.gz
Don't require isearch-update before isearch-donescratch/backports-25.2-strict
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)
-rw-r--r--lisp/isearch.el7
-rw-r--r--test/automated/isearch-tests.el8
2 files changed, 12 insertions, 3 deletions
diff --git a/lisp/isearch.el b/lisp/isearch.el
index a97247671cc..9df7627fa7c 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -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.
diff --git a/test/automated/isearch-tests.el b/test/automated/isearch-tests.el
index 48c342403c9..52f312d0b97 100644
--- a/test/automated/isearch-tests.el
+++ b/test/automated/isearch-tests.el
@@ -28,5 +28,13 @@
(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