unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#2932: call-interactively wrongly calls mouse-leave-buffer-hook
@ 2009-04-08 21:15 Alan Mackenzie
  2011-07-10  0:00 ` Juanma Barranquero
  2021-07-19 14:42 ` Lars Ingebrigtsen
  0 siblings, 2 replies; 4+ messages in thread
From: Alan Mackenzie @ 2009-04-08 21:15 UTC (permalink / raw)
  To: bug-gnu-emacs

Hi, Emacs!

In call-interactively (callint.c L~449), whilst processing `@' ("switch
to the window the mouse was clicked in") in an interactive string, the
code runs the hook `mouse-leave-buffer-hook'.

The code HASN'T CHECKED that this new window is different from the
current window, and even if it is, whether the new window is displaying
a different buffer.  Hence the hook is wrongly invoked when the mouse is
clicked in the current window.

Here is a fragment of the guilty code:

      else if (*string == '@')
        {
          Lisp_Object event, tem;

          event = (next_event < key_count
                   ? AREF (keys, next_event)
                   : Qnil);
          if (EVENT_HAS_PARAMETERS (event)
              && (tem = XCDR (event), CONSP (tem))
              && (tem = XCAR (tem), CONSP (tem))
              && (tem = XCAR (tem), WINDOWP (tem)))
            {                    /* <======================= Check for different window missing here. */
              if (MINI_WINDOW_P (XWINDOW (tem))
                  && ! (minibuf_level > 0 && EQ (tem, minibuf_window)))
                error ("Attempt to select inactive minibuffer window");

              /* If the current buffer wants to clean up, let it.  */
              if (!NILP (Vmouse_leave_buffer_hook))
                call1 (Vrun_hooks, Qmouse_leave_buffer_hook);   /* <============== Possibly spurious call */

              Fselect_window (tem, Qnil);
            }
          string++;
        }

######################################################

Similarly, DEFUN ("handle-switch-frame" (in frame.c L922) calls the same
hook without checking the new buffer is different.  This is _probably_
also a bug (I haven't checked whether handle-switch-frame's callers
perform this check).

######################################################

Similarly, there are several runnings of this hook from Lisp code, that
don't check the new buffer is different from the old. 


This probably isn't important enough to delay a release.


-- 
Alan Mackenzie (Nuremberg, Germany).







^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-07-19 14:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-08 21:15 bug#2932: call-interactively wrongly calls mouse-leave-buffer-hook Alan Mackenzie
2011-07-10  0:00 ` Juanma Barranquero
2011-09-18  8:17   ` Lars Magne Ingebrigtsen
2021-07-19 14:42 ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).