aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoam Postavsky2016-09-03 23:38:35 -0400
committerNoam Postavsky2016-09-10 09:13:09 -0400
commit68f4b5292781bc331b040105c4079902b993835c (patch)
tree41915edb4e3077ad99539b04c2b7be51a1b1a8fe
parent367f8568bc9e759ebdfb423648891efa0346456b (diff)
downloademacs-68f4b5292781bc331b040105c4079902b993835c.tar.gz
emacs-68f4b5292781bc331b040105c4079902b993835c.zip
Don't require isearch-update before isearch-done
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.
-rw-r--r--lisp/isearch.el7
-rw-r--r--test/lisp/isearch-tests.el8
2 files changed, 12 insertions, 3 deletions
diff --git a/lisp/isearch.el b/lisp/isearch.el
index b50379a250b..39ed8af3702 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -1045,9 +1045,10 @@ NOPUSH is t and EDIT is t."
1045 (remove-hook 'mouse-leave-buffer-hook 'isearch-done) 1045 (remove-hook 'mouse-leave-buffer-hook 'isearch-done)
1046 (remove-hook 'kbd-macro-termination-hook 'isearch-done) 1046 (remove-hook 'kbd-macro-termination-hook 'isearch-done)
1047 (setq isearch-lazy-highlight-start nil) 1047 (setq isearch-lazy-highlight-start nil)
1048 (with-current-buffer isearch--current-buffer 1048 (when (buffer-live-p isearch--current-buffer)
1049 (setq isearch--current-buffer nil) 1049 (with-current-buffer isearch--current-buffer
1050 (setq cursor-sensor-inhibit (delq 'isearch cursor-sensor-inhibit))) 1050 (setq isearch--current-buffer nil)
1051 (setq cursor-sensor-inhibit (delq 'isearch cursor-sensor-inhibit))))
1051 1052
1052 ;; Called by all commands that terminate isearch-mode. 1053 ;; Called by all commands that terminate isearch-mode.
1053 ;; If NOPUSH is non-nil, we don't push the string on the search ring. 1054 ;; If NOPUSH is non-nil, we don't push the string on the search ring.
diff --git a/test/lisp/isearch-tests.el b/test/lisp/isearch-tests.el
index 48c342403c9..52f312d0b97 100644
--- a/test/lisp/isearch-tests.el
+++ b/test/lisp/isearch-tests.el
@@ -28,5 +28,13 @@
28 (isearch-update) 28 (isearch-update)
29 (should (equal isearch--current-buffer (current-buffer))))) 29 (should (equal isearch--current-buffer (current-buffer)))))
30 30
31(ert-deftest isearch--test-done ()
32 ;; Normal operation.
33 (isearch-update)
34 (isearch-done)
35 (should-not isearch--current-buffer)
36 ;; Bug #21091: let `isearch-done' work without `isearch-update'.
37 (isearch-done))
38
31(provide 'isearch-tests) 39(provide 'isearch-tests)
32;;; isearch-tests.el ends here 40;;; isearch-tests.el ends here