GNU bug report logs -
#69236
29.1; Unwanted Focus Shift when Clicking Menu Functions in Emacs Mode Line
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 69236 in the body.
You can then email your comments to 69236 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#69236
; Package
emacs
.
(Sun, 18 Feb 2024 18:25:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Gabriele Nicolardi <gabriele <at> medialab.sissa.it>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Sun, 18 Feb 2024 18:25:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hi,
I have this MWE code:
(defun mwe-function-1 ()
"MWE function 1"
(interactive)
(unwind-protect
(query-replace "foo" "bar" nil (point-min) (point-max))
;; UNWINDFORMS
(read-string "function 1 executed")))
(defun mwe-function-2 ()
"MWE function 2"
(interactive)
(unwind-protect
(query-replace "foo" "bar" nil (point-min) (point-max))
;; UNWINDFORMS
(read-string "function 2 executed")))
(defun mwe-function-3 ()
"MWE function 3"
(interactive)
(unwind-protect
(query-replace "foo" "bar" nil (point-min) (point-max))
;; UNWINDFORMS
(read-string "function 3 executed")))
(define-minor-mode mwe-mode
"MWE mode"
:init-value nil
:lighter (:eval (propertize " MWE "
'face '(:foreground "RoyalBlue"
:background "DarkGoldenrod1")))
:keymap
`(
(,(kbd "<C-kp-1>") . mwe-function)
)
(if mwe-mode
(easy-menu-define mwe-menu mwe-mode-map
"MWE"
'("MWE mode"
;; I want the menu on mode-line only:
:visible (not (eq (framep (selected-frame)) 'x))
["mwe-function-1" mwe-function-1
:help "mwe-function 1"]
["mwe-function-2" mwe-function-2
:help "mwe-function 2"]
["mwe-function-3" mwe-function-3
:help "mwe-function 3"]))
t))
that builds a minor mode where I have the mwe-menu on the mode line.
It happens, very randomly but quite often, that I am experiencing an
issue in Emacs where clicking on a function name in a menu displayed on
the mode line not only triggers the desired function but also has an
unintended effect on the window or buffer below, interfering with the
intended functionality.
When I click on the function mwe-function-* in the menu, it doesn't get
executed because the mouse event interrupts `query-replace'. The issue
doesn't occur consistently and is quite random.
I opened an issue on StackExchange:
https://emacs.stackexchange.com/q/80153/15606
Here you will find a GIF that shows the problem I described.
This is big problem for me because I write code for a team that use
Emacs to edit LaTeX documents and I'm trying to create a user-friendly
environment. But many functions doesn't work when called from this kind
of menus.
Best regards,
Gabriele Nicolardi
In GNU Emacs 29.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.20,
cairo version 1.16.0) of 2023-12-10 built on lcy02-amd64-098
Repository revision: 28fb02492c2444c5976eb53fd6f9badfe54f4ea1
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12013000
System Description: Ubuntu 20.04.6 LTS
Configured using:
'configure --prefix=/snap/emacs/current/usr --with-x-toolkit=gtk3
--without-xaw3d --with-modules --with-cairo
--with-native-compilation=aot --with-xinput2 --with-tree-sitter
--with-json
'CFLAGS=-isystem/build/emacs/parts/emacs/install/usr/include
-isystem/build/emacs/parts/emacs/install/usr/include/x86_64-linux-gnu
-isystem/build/emacs/stage/usr/include -O2'
'CPPFLAGS=-isystem/build/emacs/parts/emacs/install/usr/include
-isystem/build/emacs/parts/emacs/install/usr/include/x86_64-linux-gnu
-isystem/build/emacs/stage/usr/include'
'LDFLAGS=-L/build/emacs/parts/emacs/install/lib
-L/build/emacs/parts/emacs/install/usr/lib
-L/build/emacs/parts/emacs/install/lib/x86_64-linux-gnu
-L/build/emacs/parts/emacs/install/usr/lib/x86_64-linux-gnu
-L/build/emacs/stage/usr/lib''
Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES
NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3
THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER X11 XDBE XIM XINPUT2 XPM
GTK3 ZLIB
Important settings:
value of $LANG: it_IT.UTF-8
locale-coding-system: utf-8-unix
Major mode: LaTeX
Minor modes in effect:
shell-dirtrack-mode: t
mwe-mode: t
tooltip-mode: t
global-eldoc-mode: t
show-paren-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
tool-bar-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
line-number-mode: t
transient-mark-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
Load-path shadows:
None found.
Features:
(shadow sort mail-extr emacsbug message mailcap yank-media puny dired
dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg rfc6068
epg-config gnus-util mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils byte-opt time-date cl-loaddefs comp
comp-cstr warnings icons rx cl-seq cl-macs gv cl-extra help-mode
bytecomp byte-compile cl-lib tex-mode compile text-property-search shell
subr-x pcomplete comint ansi-osc ansi-color ring display-line-numbers
easy-mmode rmc iso-transl tooltip cconv eldoc paren electric uniquify
ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode lisp-mode prog-mode register
page tab-bar menu-bar rfn-eshadow isearch easymenu timer select
scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors
frame minibuffer nadvice seq simple cl-generic indonesian philippine
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite emoji-zwj charscript
charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure
cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp
files window text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget keymap hashtable-print-readable backquote
threads dbusbind inotify lcms2 dynamic-setting system-font-setting
font-render-setting cairo move-toolbar gtk x-toolkit xinput2 x multi-tty
make-network-process native-compile emacs)
Memory information:
((conses 16 102650 4917)
(symbols 48 8309 0)
(strings 32 24629 2279)
(string-bytes 1 807125)
(vectors 16 18896)
(vector-slots 8 370470 13534)
(floats 8 42 323)
(intervals 56 899 453)
(buffers 984 15))
I have this MWE code:
(defun mwe-function-1 ()
"MWE function 1"
(interactive)
(unwind-protect
(query-replace "foo" "bar" nil (point-min) (point-max))
;; UNWINDFORMS
(read-string "function 1 executed")))
(defun mwe-function-2 ()
"MWE function 2"
(interactive)
(unwind-protect
(query-replace "foo" "bar" nil (point-min) (point-max))
;; UNWINDFORMS
(read-string "function 2 executed")))
(defun mwe-function-3 ()
"MWE function 3"
(interactive)
(unwind-protect
(query-replace "foo" "bar" nil (point-min) (point-max))
;; UNWINDFORMS
(read-string "function 3 executed")))
(define-minor-mode mwe-mode
"MWE mode"
:init-value nil
:lighter (:eval (propertize " MWE "
'face '(:foreground "RoyalBlue" :background "DarkGoldenrod1")))
:keymap
`(
(,(kbd "") . mwe-function)
)
(if mwe-mode
(easy-menu-define mwe-menu mwe-mode-map
"MWE"
'("MWE mode"
;; I want the menu on mode-line only:
:visible (not (eq (framep (selected-frame)) 'x))
["mwe-function-1" mwe-function-1
:help "mwe-function 1"]
["mwe-function-2" mwe-function-2
:help "mwe-function 2"]
["mwe-function-3" mwe-function-3
:help "mwe-function 3"]))
t))
that builds a minor mode where I have the mwe-menu on the mode line.
It happens, very randomly, that I am experiencing an issue in Emacs
where clicking on a function name in a menu displayed on the mode line
not only triggers the desired function but also has an unintended effect
on the window or buffer below, interfering with the intended
functionality.
In GNU Emacs 29.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.20,
cairo version 1.16.0) of 2023-12-10 built on lcy02-amd64-098
Repository revision: 28fb02492c2444c5976eb53fd6f9badfe54f4ea1
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12013000
System Description: Ubuntu 20.04.6 LTS
Configured using:
'configure --prefix=/snap/emacs/current/usr --with-x-toolkit=gtk3
--without-xaw3d --with-modules --with-cairo
--with-native-compilation=aot --with-xinput2 --with-tree-sitter
--with-json
'CFLAGS=-isystem/build/emacs/parts/emacs/install/usr/include
-isystem/build/emacs/parts/emacs/install/usr/include/x86_64-linux-gnu
-isystem/build/emacs/stage/usr/include -O2'
'CPPFLAGS=-isystem/build/emacs/parts/emacs/install/usr/include
-isystem/build/emacs/parts/emacs/install/usr/include/x86_64-linux-gnu
-isystem/build/emacs/stage/usr/include'
'LDFLAGS=-L/build/emacs/parts/emacs/install/lib
-L/build/emacs/parts/emacs/install/usr/lib
-L/build/emacs/parts/emacs/install/lib/x86_64-linux-gnu
-L/build/emacs/parts/emacs/install/usr/lib/x86_64-linux-gnu
-L/build/emacs/stage/usr/lib''
Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES
NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3
THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER X11 XDBE XIM XINPUT2 XPM
GTK3 ZLIB
Important settings:
value of $LANG: it_IT.UTF-8
locale-coding-system: utf-8-unix
Major mode: LaTeX
Minor modes in effect:
shell-dirtrack-mode: t
mwe-mode: t
tooltip-mode: t
global-eldoc-mode: t
show-paren-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
tool-bar-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
line-number-mode: t
transient-mark-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
Load-path shadows:
None found.
Features:
(shadow sort mail-extr emacsbug message mailcap yank-media puny dired
dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg rfc6068
epg-config gnus-util mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils byte-opt time-date cl-loaddefs comp
comp-cstr warnings icons rx cl-seq cl-macs gv cl-extra help-mode
bytecomp byte-compile cl-lib tex-mode compile text-property-search shell
subr-x pcomplete comint ansi-osc ansi-color ring display-line-numbers
easy-mmode rmc iso-transl tooltip cconv eldoc paren electric uniquify
ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode lisp-mode prog-mode register
page tab-bar menu-bar rfn-eshadow isearch easymenu timer select
scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors
frame minibuffer nadvice seq simple cl-generic indonesian philippine
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite emoji-zwj charscript
charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure
cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp
files window text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget keymap hashtable-print-readable backquote
threads dbusbind inotify lcms2 dynamic-setting system-font-setting
font-render-setting cairo move-toolbar gtk x-toolkit xinput2 x multi-tty
make-network-process native-compile emacs)
Memory information:
((conses 16 102650 4917)
(symbols 48 8309 0)
(strings 32 24629 2279)
(string-bytes 1 807125)
(vectors 16 18896)
(vector-slots 8 370470 13534)
(floats 8 42 323)
(intervals 56 899 453)
(buffers 984 15))
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#69236
; Package
emacs
.
(Sun, 18 Feb 2024 19:00:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 69236 <at> debbugs.gnu.org (full text, mbox):
> Date: Thu, 15 Feb 2024 22:55:12 +0100
> From: Gabriele Nicolardi <gabriele <at> medialab.sissa.it>
>
> I have this MWE code:
>
> (defun mwe-function-1 ()
> "MWE function 1"
> (interactive)
> (unwind-protect
> (query-replace "foo" "bar" nil (point-min) (point-max))
> ;; UNWINDFORMS
> (read-string "function 1 executed")))
>
> (defun mwe-function-2 ()
> "MWE function 2"
> (interactive)
> (unwind-protect
> (query-replace "foo" "bar" nil (point-min) (point-max))
> ;; UNWINDFORMS
> (read-string "function 2 executed")))
>
> (defun mwe-function-3 ()
> "MWE function 3"
> (interactive)
> (unwind-protect
> (query-replace "foo" "bar" nil (point-min) (point-max))
> ;; UNWINDFORMS
> (read-string "function 3 executed")))
>
> (define-minor-mode mwe-mode
> "MWE mode"
> :init-value nil
> :lighter (:eval (propertize " MWE "
> 'face '(:foreground "RoyalBlue" :background "DarkGoldenrod1")))
>
> :keymap
> `(
> (,(kbd "<C-kp-1>") . mwe-function)
> )
>
> (if mwe-mode
> (easy-menu-define mwe-menu mwe-mode-map
> "MWE"
> '("MWE mode"
> ;; I want the menu on mode-line only:
> :visible (not (eq (framep (selected-frame)) 'x))
> ["mwe-function-1" mwe-function-1
> :help "mwe-function 1"]
> ["mwe-function-2" mwe-function-2
> :help "mwe-function 2"]
> ["mwe-function-3" mwe-function-3
> :help "mwe-function 3"]))
> t))
>
> that builds a minor mode where I have the mwe-menu on the mode line.
>
> It happens, very randomly but quite often, that I am experiencing an
> issue in Emacs where clicking on a function name in a menu displayed on
> the mode line not only triggers the desired function but also has an
> unintended effect on the window or buffer below, interfering with the
> intended functionality.
>
> When I click on the function mwe-function-* in the menu, it doesn't get
> executed because the mouse event interrupts `query-replace'. The issue
> doesn't occur consistently and is quite random.
Please show the output of "C-h l" in both cases, i.e. when things work
and when they don't. This should give some ideas about what goes
wrong.
Thanks.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#69236
; Package
emacs
.
(Sun, 18 Feb 2024 19:38:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 69236 <at> debbugs.gnu.org (full text, mbox):
[Please use Reply All to reply, to have the bug tracker CC'ed.]
> Date: Sun, 18 Feb 2024 20:25:50 +0100
> From: Gabriele Nicolardi <gabriele <at> medialab.sissa.it>
>
> When things do work I get:
>
> <help-echo> <down-mouse-1> ;; mouse-minor-mode-menu
> q <return> ;; exit-minibuffer
> <help-echo> C-h l ;; view-lossage
>
> When things doesn't work I get:
>
> <help-echo> <down-mouse-1> ;; mouse-minor-mode-menu
> <mouse-1> <mouse-1> ;; mouse-select-window
> <help-echo> C-x o ;; other-window
> <return> ;; exit-minibuffer
> C-h l ;; view-lossage
>
> I see the <mouse-1> event but i click the mouse just one time. Other users reported the same issue so I
> presume it is not a hardware problem (the mouse...).
>
> I also find that this code:
>
> (defmacro with-ignore-mouse-events (&rest body)
> "Macro to ignore mouse events before evaluating BODY."
> `(progn
> (when (input-pending-p)
> (let ((event (read-event)))
> (if (mouse-event-p event)
> (let ((button (event-basic-type event)))
> (if (eq button 'mouse-1)
> (ignore)
> (setq unread-command-events (list event))))
> (setq unread-command-events (list event)))))
> ,@body))
>
> (defun mwe-function-1 ()
> "MWE function 1"
> (interactive)
> (unwind-protect
> (query-replace "foo" "bar" nil (point-min) (point-max))
> ;; UNWINDFORMS
> (read-string "function 1 executed")))
>
> (defun mwe-function-1* ()
> (interactive)
> (with-ignore-mouse-events
> (mwe-function-1)))
>
> fixes the problem. (I need to use mwe-function-1* in the menu definition).
So the problem is fixed, and we can close this bug? Or is there still
something left to investigate and/or fix?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#69236
; Package
emacs
.
(Sun, 18 Feb 2024 20:05:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 69236 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
I think I found a workaround but not a fix. I need to create a modified
version of the functions I call by the menu to avoid the problem.
I'm also aware that this may depend on the graphical server and/or the
operating system.
Thanks
Il 18/02/24 20:36, Eli Zaretskii ha scritto:
> So the problem is fixed, and we can close this bug? Or is there still
> something left to investigate and/or fix?
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#69236
; Package
emacs
.
(Sun, 18 Feb 2024 20:17:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 69236 <at> debbugs.gnu.org (full text, mbox):
> Date: Sun, 18 Feb 2024 21:03:28 +0100
> Cc: 69236 <at> debbugs.gnu.org
> From: Gabriele Nicolardi <gabriele <at> medialab.sissa.it>
>
> I think I found a workaround but not a fix. I need to create a modified version of the functions I call by the menu
> to avoid the problem.
>
> I'm also aware that this may depend on the graphical server and/or the operating system.
Well, if it helps, the output of "C-h l" indicates that the
problematic behavior is because the spot where you click the mouse
invokes the mouse-1 binding instead of down-mouse-1 binding. So you
should investigate what is different about mouse-click bindings in
that spot.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#69236
; Package
emacs
.
(Sat, 01 Mar 2025 03:25:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 69236 <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> writes:
>> Date: Sun, 18 Feb 2024 21:03:28 +0100
>> Cc: 69236 <at> debbugs.gnu.org
>> From: Gabriele Nicolardi <gabriele <at> medialab.sissa.it>
>>
>> I think I found a workaround but not a fix. I need to create a modified version of the functions I call by the menu
>> to avoid the problem.
>>
>> I'm also aware that this may depend on the graphical server and/or the operating system.
>
> Well, if it helps, the output of "C-h l" indicates that the
> problematic behavior is because the spot where you click the mouse
> invokes the mouse-1 binding instead of down-mouse-1 binding. So you
> should investigate what is different about mouse-click bindings in
> that spot.
Gabriele, did you manage to find out anything more here?
Added tag(s) moreinfo.
Request was from
Stefan Kangas <stefankangas <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Sat, 01 Mar 2025 03:25:08 GMT)
Full text and
rfc822 format available.
Reply sent
to
Stefan Kangas <stefankangas <at> gmail.com>
:
You have taken responsibility.
(Tue, 04 Mar 2025 10:10:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
Gabriele Nicolardi <gabriele <at> medialab.sissa.it>
:
bug acknowledged by developer.
(Tue, 04 Mar 2025 10:10:02 GMT)
Full text and
rfc822 format available.
Message #27 received at 69236-done <at> debbugs.gnu.org (full text, mbox):
Gabriele Nicolardi <gabriele <at> medialab.sissa.it> writes:
> Il 01/03/25 04:24, Stefan Kangas ha scritto:
>> Gabriele, did you manage to find out anything more here?
>
> No, sorry.
OK, thanks.
I unfortunately don't think we can proceed here without more
information. Will you have time to look into this at some point?
Otherwise, I'm not sure there is much more that we can do here.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Tue, 01 Apr 2025 11:24:57 GMT)
Full text and
rfc822 format available.
This bug report was last modified 80 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.