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

From: Drew Adams <[email-masked]>
Date: Mon, 29 May 2017 18:07:49 -0700 (PDT)

> >> > +      (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))))
> >>   ...)
> >
> > (let* ((overriding-terminal-local-map nil)
> >        (binding (key-binding (this-command-keys-vector) t)))
> >   ...)
> 
> Check https://urldefense.proofpoint.com/v2/url?u=https-
> 3A__debbugs.gnu.org_cgi_bugreport.cgi-3Fbug-3D23007-
> 238&d=DwIBAg&c=RoP1YumCXCgaWHvlZYR8PQcxBKCX5YTpkKY057SbK10&r=qZLZosY6GBAaJtO
> G9v8QX7nD4BS9t9s5otgxC3d4IFU&m=eZ-Uw6bQQfS-_CFDf_e3zupcjOhlrCnDnq5pNm6-
> bao&s=e0BQOMr3F7kitlASNZ_EMEy-LvwMn0CsRuZUecvrYZg&e= , we need to
> avoid binding `overriding-terminal-local-map' in "...".

Clearly I, like you, meant that this let is for only the second
`if' clause.  But these are only style differences.

If it were I, I'd also move the let-binding that is used only
in the first `if' clause into the `if' test.  (And I'd ensure
that there is in fact a mark.)

(if (let ((win (posn-window (event-start click))))
      (and (window-minibuffer-p win)
           (not (minibuffer-window-active-p win))
           (mark)))
    (isearch-yank-x-selection)
  (let* ((overriding-terminal-local-map nil)
         (binding (key-binding (this-command-keys-vector) t)))
    (when (functionp binding) (call-interactively binding))))