Subject: Re: bug#23007: 24.5; buggy interactive search with middle click

From: Alex <[email-masked]>
Date: Mon, 29 May 2017 20:47:10 -0600

[email-masked] writes:

> Alex <[email-masked]> writes:
>
>> +      (let ((overriding-terminal-local-map nil))
>> +        (setq binding (key-binding (this-command-keys-vector) t)))
>
> IMO, it would be better style to do something like
>
> (let ((binding (let ((overriding-terminal-local-map nil))
>                  (key-binding (this-command-keys-vector) t))))
>   ...)

That was my first idea, but at the time I thought it was better style to
use the setq version instead. :)

Your version makes the binding more obvious, though, so I updated the
patch to use it. I've attached it below.

PS: I don't immediately see a reason to check for the (mark) in the
condition. I tested by deactivating the mark explicitly, and setting
mark-even-if-inactive to nil in the window, but it still worked
correctly.

>From be6236ea77920a123a30b6fb3b4d52602d4d9097 Mon Sep 17 00:00:00 2001
From: Alexander Gramiak <[email-masked]>
Date: Mon, 29 May 2017 13:43:23 -0600
Subject: [PATCH] Limit scope of local overriding-terminal-local-map

The function `binding' may call isearch-done, which globally sets
overriding-terminal-local-map to nil (Bug#23007).
* lisp/isearch.el (isearch-mouse-2): Don't bind
overriding-terminal-local-map around the call to `binding'.
---
 lisp/isearch.el | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/lisp/isearch.el b/lisp/isearch.el
index c34739d638..0d50c9dd9a 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -2036,14 +2036,14 @@ isearch-mouse-2
 Otherwise invoke whatever the calling mouse-2 command sequence
 is bound to outside of Isearch."
   (interactive "e")
-  (let* ((w (posn-window (event-start click)))
-	 (overriding-terminal-local-map nil)
-	 (binding (key-binding (this-command-keys-vector) t)))
+  (let ((w (posn-window (event-start click)))
+        (binding (let ((overriding-terminal-local-map nil))
+                   (key-binding (this-command-keys-vector) t))))
     (if (and (window-minibuffer-p w)
-	     (not (minibuffer-window-active-p w))) ; in echo area
-	(isearch-yank-x-selection)
+             (not (minibuffer-window-active-p w))) ; in echo area
+        (isearch-yank-x-selection)
       (when (functionp binding)
-	(call-interactively binding)))))
+        (call-interactively binding)))))
 
 (declare-function xterm--pasted-text "term/xterm" ())
 
-- 
2.11.0