emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 68f4b52: Don't require isearch-update before isearc


From: Noam Postavsky
Subject: [Emacs-diffs] master 68f4b52: Don't require isearch-update before isearch-done
Date: Sat, 10 Sep 2016 13:49:27 +0000 (UTC)

branch: master
commit 68f4b5292781bc331b040105c4079902b993835c
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>

    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.
---
 lisp/isearch.el            |    7 ++++---
 test/lisp/isearch-tests.el |    8 ++++++++
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/lisp/isearch.el b/lisp/isearch.el
index b50379a..39ed8af 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -1045,9 +1045,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/lisp/isearch-tests.el b/test/lisp/isearch-tests.el
index 48c3424..52f312d 100644
--- a/test/lisp/isearch-tests.el
+++ b/test/lisp/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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]