Subject: bug#20516: closed (Re: bug#20532: 25.0.50; void-variable cursor-sensor-inhibit)

From: [email-masked] (GNU bug Tracking System)
Date: Wed, 27 May 2015 16:19:03 +0000

Your bug report

#20532: 25.0.50; cursor-sensor is not loaded in isearch

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
20532: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=20532
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#20532: 25.0.50; void-variable cursor-sensor-inhibit
From: Stefan Monnier <[email-masked]>
To: [email-masked]
Date: Wed, 27 May 2015 12:18:20 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

>> Can you think of any reason why you might have started your search in
>> one buffer and ended it in another?

> This will happen by design if you use isearch to search across multiple
> files (i.e. multi-isearch), such as a sequence of ChangeLog.N files.
> (There may be other variables than cursor-sensor-inhibit that are also
> mishandled in this situation.)

I installed the patch below which should fix this.

        Stefan

diff --git a/lisp/isearch.el b/lisp/isearch.el
index dc10502..5599ea5 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -932,12 +932,6 @@ convert the search string to a regexp used by regexp search functions."
   (add-hook 'post-command-hook 'isearch-post-command-hook)
   (add-hook 'mouse-leave-buffer-hook 'isearch-done)
   (add-hook 'kbd-macro-termination-hook 'isearch-done)
-  (make-local-variable 'cursor-sensor-inhibit)
-  (unless (boundp 'cursor-sensor-inhibit)
-    (setq cursor-sensor-inhibit nil))
-  ;; Suspend things like cursor-intangible during Isearch so we can search even
-  ;; within intangible text.
-  (push 'isearch cursor-sensor-inhibit)
 
   ;; isearch-mode can be made modal (in the sense of not returning to
   ;; the calling function until searching is completed) by entering
@@ -949,10 +943,23 @@ convert the search string to a regexp used by regexp search functions."

 ;; Some high level utilities.  Others below.
+(defvar isearch--current-buffer)
 
 (defun isearch-update ()
   "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
+      (with-current-buffer isearch--current-buffer
+        (setq cursor-sensor-inhibit (delq 'isearch cursor-sensor-inhibit))))
+    (setq isearch--current-buffer (current-buffer))
+    (make-local-variable 'cursor-sensor-inhibit)
+    (unless (boundp 'cursor-sensor-inhibit)
+      (setq cursor-sensor-inhibit nil))
+    ;; Suspend things like cursor-intangible during Isearch so we can search
+    ;; even within intangible text.
+    (push 'isearch cursor-sensor-inhibit))
+
   (if (and (null unread-command-events)
 	   (null executing-kbd-macro))
       (progn
@@ -1026,7 +1033,9 @@ 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)
-  (setq cursor-sensor-inhibit (delq 'isearch cursor-sensor-inhibit))
+  (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.

Subject: 25.0.50; cursor-sensor is not loaded in isearch
From: Vitalie Spinu <[email-masked]>
To: [email-masked]
Date: Wed, 06 May 2015 18:44:46 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Occasionally I am getting

 isearch-cancel: Symbol's value as variable is void: cursor-sensor-inhibit [12 times]

but I cannot give exact steps to reproduce.

Likely cause - isearch is not requiring cursor-sensor.

  Vitalie