From unknown Mon Jun 16 23:39:31 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#2932 <2932@debbugs.gnu.org> To: bug#2932 <2932@debbugs.gnu.org> Subject: Status: call-interactively wrongly calls mouse-leave-buffer-hook Reply-To: bug#2932 <2932@debbugs.gnu.org> Date: Tue, 17 Jun 2025 06:39:31 +0000 retitle 2932 call-interactively wrongly calls mouse-leave-buffer-hook reassign 2932 emacs submitter 2932 Alan Mackenzie severity 2932 normal thanks From acm@muc.de Wed Apr 8 14:16:26 2009 Received: (at submit) by emacsbugs.donarmstrong.com; 8 Apr 2009 21:16:27 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=0.1 required=4.0 tests=FOURLA autolearn=no version=3.2.5-bugs.debian.org_2005_01_02 Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id n38LGLQJ014382 for ; Wed, 8 Apr 2009 14:16:23 -0700 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Lrf88-0001Qg-Tw for bug-gnu-emacs@gnu.org; Wed, 08 Apr 2009 17:16:21 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Lrf84-0001PQ-4D for bug-gnu-emacs@gnu.org; Wed, 08 Apr 2009 17:16:20 -0400 Received: from [199.232.76.173] (port=38093 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lrf84-0001PN-0H for bug-gnu-emacs@gnu.org; Wed, 08 Apr 2009 17:16:16 -0400 Received: from colin.muc.de ([193.149.48.1]:3308 helo=mail.muc.de) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Lrf83-0000fx-7K for bug-gnu-emacs@gnu.org; Wed, 08 Apr 2009 17:16:15 -0400 Received: (qmail 5210 invoked by uid 3782); 8 Apr 2009 21:16:12 -0000 Received: from acm.muc.de (pD9E5114E.dip.t-dialin.net [217.229.17.78]) by colin2.muc.de (tmda-ofmipd) with ESMTP; Wed, 08 Apr 2009 23:16:10 +0200 Received: (qmail 2964 invoked by uid 1000); 8 Apr 2009 21:15:53 -0000 Date: Wed, 8 Apr 2009 21:15:53 +0000 To: bug-gnu-emacs@gnu.org Subject: call-interactively wrongly calls mouse-leave-buffer-hook Message-ID: <20090408211553.GA2627@muc.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.9i X-Delivery-Agent: TMDA/1.1.5 (Fettercairn) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-detected-operating-system: by monty-python.gnu.org: FreeBSD 4.6-4.9 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). From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 09 20:01:29 2011 Received: (at 2932) by debbugs.gnu.org; 10 Jul 2011 00:01:30 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QfhSj-0005gI-MC for submit@debbugs.gnu.org; Sat, 09 Jul 2011 20:01:29 -0400 Received: from mail-pz0-f44.google.com ([209.85.210.44]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QfhSh-0005g5-51 for 2932@debbugs.gnu.org; Sat, 09 Jul 2011 20:01:27 -0400 Received: by pzk5 with SMTP id 5so2345914pzk.3 for <2932@debbugs.gnu.org>; Sat, 09 Jul 2011 17:01:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=ySNRkRPyHJ1+UImTGKldyAOsAzKsykNEH0SgsulMVw4=; b=OFpx5KeInRZwsWBZKkq1aA2CrGqc1OnuzMil7/RnbVpekeCmwaRlyeW74VHRQNO9G5 3xkrYarH8t7NLl3QuprXpBx4QtOC94xHJtJWnBNfqCmY8SEcPJpjZpOhiryLDX3nsL6b zkgLvgyBBWksbA4wkBgMG4Rh80M3TMYLFohmU= Received: by 10.143.91.16 with SMTP id t16mr1109211wfl.366.1310256081166; Sat, 09 Jul 2011 17:01:21 -0700 (PDT) MIME-Version: 1.0 Received: by 10.142.144.4 with HTTP; Sat, 9 Jul 2011 17:00:41 -0700 (PDT) In-Reply-To: <20090408211553.GA2627@muc.de> References: <20090408211553.GA2627@muc.de> From: Juanma Barranquero Date: Sun, 10 Jul 2011 02:00:41 +0200 Message-ID: Subject: Re: bug#2932: call-interactively wrongly calls mouse-leave-buffer-hook To: Alan Mackenzie Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -3.3 (---) X-Debbugs-Envelope-To: 2932 Cc: 2932@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.3 (---) On Wed, Apr 8, 2009 at 23:15, Alan Mackenzie wrote: > 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. =C2=A0Hence the hook is wrongly invoked when the mous= e is > clicked in the current window. The trunk still behaves as you describe. As a first pass, we should fix the docstring of `mouse-leave-buffer-hook'. It seems wrong for the docstring of a hook with "leave-buffer" in its name to talk about windows and not say a word about buffers... =C2=A0 =C2=A0 Juanma From debbugs-submit-bounces@debbugs.gnu.org Sun Sep 18 04:49:01 2011 Received: (at 2932) by debbugs.gnu.org; 18 Sep 2011 08:49:01 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R5D3b-0003Tk-R6 for submit@debbugs.gnu.org; Sun, 18 Sep 2011 04:49:00 -0400 Received: from hermes.netfonds.no ([80.91.224.195]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R5D3W-0003TI-8A for 2932@debbugs.gnu.org; Sun, 18 Sep 2011 04:48:55 -0400 Received: from cm-84.215.51.58.getinternet.no ([84.215.51.58] helo=stories.gnus.org) by hermes.netfonds.no with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1R5Cyf-000619-9Y; Sun, 18 Sep 2011 10:43:53 +0200 From: Lars Magne Ingebrigtsen To: Juanma Barranquero Subject: Re: bug#2932: call-interactively wrongly calls mouse-leave-buffer-hook In-Reply-To: (Juanma Barranquero's message of "Sun, 10 Jul 2011 02:00:41 +0200") Date: Sun, 18 Sep 2011 10:17:18 +0200 Message-ID: References: <20090408211553.GA2627@muc.de> User-Agent: Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.50 (gnu/linux) X-Now-Playing: Eurythmics's _Touch_: "Right By Your Side" MIME-Version: 1.0 Content-Type: text/plain X-MailScanner-ID: 1R5Cyf-000619-9Y X-Netfonds-MailScanner: Found to be clean X-Netfonds-MailScanner-From: larsi@gnus.org MailScanner-NULL-Check: 1316940233.3604@W7oJRl6VClUd6oqqe4zHkg X-Spam-Status: No X-Spam-Score: -2.7 (--) X-Debbugs-Envelope-To: 2932 Cc: Alan Mackenzie , 2932@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.7 (--) Juanma Barranquero writes: > The trunk still behaves as you describe. > > As a first pass, we should fix the docstring of > `mouse-leave-buffer-hook'. It seems wrong for the docstring of a hook > with "leave-buffer" in its name to talk about windows and not say a > word about buffers... Yes, that's a somewhat confusing doc string. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog http://lars.ingebrigtsen.no/ From debbugs-submit-bounces@debbugs.gnu.org Mon Jul 19 10:42:28 2021 Received: (at 2932) by debbugs.gnu.org; 19 Jul 2021 14:42:28 +0000 Received: from localhost ([127.0.0.1]:59689 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m5UTU-0003SR-D0 for submit@debbugs.gnu.org; Mon, 19 Jul 2021 10:42:28 -0400 Received: from quimby.gnus.org ([95.216.78.240]:45688) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m5UTS-0003SB-Dv for 2932@debbugs.gnu.org; Mon, 19 Jul 2021 10:42:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=j4D9ggVmFdfXphavwcJdfT2OK+OWHr9sfIu19788mhY=; b=NwwqAklnyoFEX32HFK3hlKI9FW 6FwQpMNMCnlJjD2pgIB5kJ9COSqNKiXGLCCDUf3Cf3o+GcUetrsR3BWyxYk5OcmFC84r2KsDqDQQi wtFJ7zV+UXj7KGCuH0wdWFIr/tAgzF8ssuoAdLYtcWJlQfWI848N4vi57uNwjICfsCY4=; Received: from cm-84.212.220.105.getinternet.no ([84.212.220.105] helo=elva) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m5UTG-0007oP-FX; Mon, 19 Jul 2021 16:42:19 +0200 From: Lars Ingebrigtsen To: Alan Mackenzie Subject: Re: bug#2932: call-interactively wrongly calls mouse-leave-buffer-hook References: <20090408211553.GA2627@muc.de> X-Now-Playing: Colored Music's _Individual Beauty_: "De To Re Mi" Date: Mon, 19 Jul 2021 16:42:10 +0200 In-Reply-To: <20090408211553.GA2627@muc.de> (Alan Mackenzie's message of "Wed, 8 Apr 2009 21:15:53 +0000") Message-ID: <87k0lmnz5p.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Alan Mackenzie 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'. > > T [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 2932 Cc: 2932@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Alan Mackenzie 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 # [3 times] Leaving # 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 From debbugs-submit-bounces@debbugs.gnu.org Mon Jul 19 10:42:33 2021 Received: (at control) by debbugs.gnu.org; 19 Jul 2021 14:42:33 +0000 Received: from localhost ([127.0.0.1]:59692 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m5UTY-0003Sj-ME for submit@debbugs.gnu.org; Mon, 19 Jul 2021 10:42:33 -0400 Received: from quimby.gnus.org ([95.216.78.240]:45702) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m5UTW-0003SI-Pv for control@debbugs.gnu.org; Mon, 19 Jul 2021 10:42:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Subject:From:To:Message-Id:Date:Sender:Reply-To:Cc: MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=taUGXDG8D9PYQxoACSpu+2GKxhRUEFpb09cXYHm4cMg=; b=KfoPkkxBQfo3UdAcWHQkTZ5NlG gEzDxTjhHFmfW0uMljwNd+8SP+nwxt5q+giywVWymlMT6GaOWiyWMlwucId7UZ4FiBTDjdmUKfmOD U3pjou3WgxLb9LewDpHJB2TitDv7GHxSr7b1nwgJnyW+HO9vbwqCrDYpbixIg3cxvRF8=; Received: from cm-84.212.220.105.getinternet.no ([84.212.220.105] helo=elva) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m5UTP-0007oc-5f for control@debbugs.gnu.org; Mon, 19 Jul 2021 16:42:25 +0200 Date: Mon, 19 Jul 2021 16:42:22 +0200 Message-Id: <87im16nz5d.fsf@gnus.org> To: control@debbugs.gnu.org From: Lars Ingebrigtsen Subject: control message for bug #2932 X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: close 2932 28.1 quit Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) close 2932 28.1 quit From unknown Mon Jun 16 23:39:31 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Tue, 17 Aug 2021 11:24:06 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator