unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Lars Ingebrigtsen <larsi@gnus.org>
To: Alan Mackenzie <acm@muc.de>
Cc: 2932@debbugs.gnu.org
Subject: bug#2932: call-interactively wrongly calls mouse-leave-buffer-hook
Date: Mon, 19 Jul 2021 16:42:10 +0200	[thread overview]
Message-ID: <87k0lmnz5p.fsf@gnus.org> (raw)
In-Reply-To: <20090408211553.GA2627@muc.de> (Alan Mackenzie's message of "Wed,  8 Apr 2009 21:15:53 +0000")

Alan Mackenzie <acm@muc.de> writes:

> 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.

Test code:

(setq mouse-leave-buffer-hook '((lambda ()
				  (message "Leaving %s" (current-buffer)))))

And then mouse-click.  And, indeed, it's run even when not changing a
window.

... Uhm, OK, that was a slightly different thing.  Try this:

(setq mouse-leave-buffer-hook '((lambda ()
				  (message "Leaving %s" (selected-window)))))

The hook is run three times in the selected window, and then it's run
once in the new buffer:

Leaving #<window 110 on sel.el> [3 times]
Leaving #<window 114 on *Messages*>

So the problem isn't just in call-interactively -- the hook is called a
lot -- on any mouse click, and whether we switch windows or not, and
both before and after the switch.

I'm guessing we can't change this at this point, so I'll just adjust the
doc string to reflect the current state of affairs instead.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





      parent reply	other threads:[~2021-07-19 14:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k0lmnz5p.fsf@gnus.org \
    --to=larsi@gnus.org \
    --cc=2932@debbugs.gnu.org \
    --cc=acm@muc.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).