]> code.delx.au - gnu-emacs/commitdiff
* lisp/isearch.el: Avoid an error that blocks isearch
authorArtur Malabarba <bruce.connor.am@gmail.com>
Fri, 30 Oct 2015 11:04:50 +0000 (11:04 +0000)
committerArtur Malabarba <bruce.connor.am@gmail.com>
Fri, 30 Oct 2015 11:08:57 +0000 (11:08 +0000)
(isearch-update): Don't error if `isearch--current-buffer' has
been killed.

* test/automated/isearch-tests.el (isearch--test-update): New
file.

lisp/isearch.el
test/automated/isearch-tests.el [new file with mode: 0644]

index e9eec013580ed6d304ba34611af07a374a72b9fe..b762884945ee28241a20876e6f4e7d2974a11d89 100644 (file)
@@ -954,7 +954,7 @@ used to set the value of `isearch-regexp-function'."
   "This is called after every isearch command to update the display.
 The last thing it does is to run `isearch-update-post-hook'."
   (unless (eq (current-buffer) isearch--current-buffer)
-    (when isearch--current-buffer
+    (when (buffer-live-p isearch--current-buffer)
       (with-current-buffer isearch--current-buffer
         (setq cursor-sensor-inhibit (delq 'isearch cursor-sensor-inhibit))))
     (setq isearch--current-buffer (current-buffer))
diff --git a/test/automated/isearch-tests.el b/test/automated/isearch-tests.el
new file mode 100644 (file)
index 0000000..d60c229
--- /dev/null
@@ -0,0 +1,32 @@
+;;; isearch-tests.el --- Tests for isearch.el        -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2013-2015 Free Software Foundation, Inc.
+
+;; Author: Artur Malabarba <bruce.connor.am@gmail.com>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Code:
+
+(require 'ert)
+
+(ert-deftest isearch--test-update ()
+  (with-temp-buffer
+    (setq isearch--current-buffer (current-buffer)))
+  (with-temp-buffer
+    (isearch-update)
+    (should (equal isearch--current-buffer (current-buffer)))))
+
+(provide 'isearch-tests)
+;;; isearch-tests.el ends here