* Binding mouse key sequences @ 2013-07-02 22:48 greenwaters 2013-07-03 0:16 ` Michael Heerdegen 0 siblings, 1 reply; 5+ messages in thread From: greenwaters @ 2013-07-02 22:48 UTC (permalink / raw) To: Help-gnu-emacs I tried unsuccesfully to bind a sequence of two mouse keys. For example (global-set-key [mouse-8 mouse-9] 'write-file) after unsetting mouse-8 globally. Pressing mouse-8 gives a message "Empty menu" at the bottom of the screen. Section 48.3.10 Rebinding Mouse Buttons in the manual mentions, at the end, the possibility of binding mouse sequences. What is the right way to do this? -- View this message in context: http://emacs.1067599.n5.nabble.com/Binding-mouse-key-sequences-tp291017.html Sent from the Emacs - Help mailing list archive at Nabble.com. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Binding mouse key sequences 2013-07-02 22:48 Binding mouse key sequences greenwaters @ 2013-07-03 0:16 ` Michael Heerdegen 2013-07-04 9:50 ` greenwaters 0 siblings, 1 reply; 5+ messages in thread From: Michael Heerdegen @ 2013-07-03 0:16 UTC (permalink / raw) To: help-gnu-emacs greenwaters <regularclockwork@gmail.com> writes: > I tried unsuccesfully to bind a sequence of two mouse keys. For example > > (global-set-key [mouse-8 mouse-9] 'write-file) > > after unsetting mouse-8 globally. Pressing mouse-8 gives a message "Empty > menu" at the bottom of the screen. Does this happen with emacs -Q (i.e., without loading your init file)? What does C-h k mouse-8 tell you? Does it even work when you do (global-set-key [mouse-8] 'write-file) ? > Section > > 48.3.10 Rebinding Mouse Buttons > > in the manual mentions, at the end, the possibility of binding mouse > sequences. > > What is the right way to do this? IMHO this is the right way. If I eval (global-set-key [mouse-8 mouse-9] 'write-file) and then (progn (push 'mouse-9 unread-command-events) (push 'mouse-8 unread-command-events)) I get `write-file' called (sorry, I don't have a mouse with mouse-8 to test, that's why I pushed events to `unread-command-events'). Are you sure Emacs is really receiving a mouse-8 event? Also (setq debug-on-error t) should help you to see what's going on, because you seem to get an error. Regards, Michael. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Binding mouse key sequences 2013-07-03 0:16 ` Michael Heerdegen @ 2013-07-04 9:50 ` greenwaters 2013-07-04 14:40 ` Michael Heerdegen 0 siblings, 1 reply; 5+ messages in thread From: greenwaters @ 2013-07-04 9:50 UTC (permalink / raw) To: Help-gnu-emacs Thank you for answering Michael. I'll try to answer your questions adding some new facts. 1. Yes, it happens with emacs -Q. 2. After calling emacs -Q, C-h k mouse-8 gives <mouse-8> (translated from <down-mouse-8> <mouse-8>) at that spot is undefined Similar behaviour for C-h k mouse-9. After binding with (global-set-key [mouse-8 mouse-9] 'write-file) C-h k mouse-8 gives byte-code: Empty menu 3. However, after binding with (global-set-key [mouse-8] 'write-file) C-h k mouse-8 gives the usual info <mouse-8> (translated from <down-mouse-8> <mouse-8>) at that spot runs the command write-file, which is an interactive compiled Lisp function. It is bound to <mouse-8>, C-x C-w, <menu-bar> <file> <write-file>. etc. and mouse-8 pops up the file selector window. 4. Now, setting (global-set-key [mouse-8 mouse-9] 'write-file) and executing (progn (push 'mouse-9 unread-command-events) (push 'mouse-8 unread-command-events)) does indeed call write-file. 5. I used xev to catch mouse key press events in Xorg: both mouse-8 and mouse-9 are recognized. This does not tell me much, however, because the test used xev's own window. When I tell xev to monitor any other window, e.g., emacs, mouse clicks are not catched by xev. 6. Setting the debug variable to true gives simply Debugger entered--Lisp error: (error "Empty menu") I replicated the tests above using mouse-3 instead of mouse-8 and mouse-2 instead of mouse-9. Therefore I doubt there's any relation with high numbered mouse buttons in Xorg. This is all I was able to find out, with one addition: double-mouse-8 or drag-mouse-8 always pops up a menu with just two entries, "tool bar" and "Menu bar", both giving access to submenus. The former has entries for all the buttons in the emacs tool bar, but all entries seem disabled. The latter equals the Lisp-Interaction menu (I am performing tests inside the scratch buffer). Same using mouse-3 and mouse-2, or using S-mouse-3 and mouse-2; therefore it looks definitely as an effect of using global-set-key, and not some predefined undocumented behavior. Moreover, globally unsetting double-mouse-8 leaves that menu still functional. BTW I am using GNU Emacs 23.4.1 (i486-pc-linux-gnu, GTK+ Version 2.24.10) GNU Emacs 23.4.1 (x86_64-pc-linux-gnu, GTK+ Version 2.24.10) on Debian Wheezy. Any further hint is welcomed. -- View this message in context: http://emacs.1067599.n5.nabble.com/Binding-mouse-key-sequences-tp291017p291164.html Sent from the Emacs - Help mailing list archive at Nabble.com. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Binding mouse key sequences 2013-07-04 9:50 ` greenwaters @ 2013-07-04 14:40 ` Michael Heerdegen 2013-07-04 16:36 ` greenwaters 0 siblings, 1 reply; 5+ messages in thread From: Michael Heerdegen @ 2013-07-04 14:40 UTC (permalink / raw) To: help-gnu-emacs greenwaters <regularclockwork@gmail.com> writes: > Thank you for answering Michael. > I'll try to answer your questions adding some new facts. Thanks. I can reproduce everything you say, in all Emacs versions I tried, trunk is among them. And indeed it contradicts the manual, which says that "You can put more than one mouse button in a key sequence". Can you please make a bug report (M-x report-emacs-bug)? Please give a minimal example starting from emacs -Q, and please include the information that this also happens in trunk. BTW, I tried hard to find a workaround to make possible what you want, but failed. Reading key sequences generally seems to terminate after any mouse event (try `read-key-sequence'!). The only thing you can do is to bind mouse-8 to a command (a keymap does not work) that reads another event and DTRT. Regards, Michael. > 1. Yes, it happens with emacs -Q. > > 2. After calling emacs -Q, C-h k mouse-8 gives > > <mouse-8> (translated from <down-mouse-8> <mouse-8>) at that spot is > undefined > > Similar behaviour for C-h k mouse-9. > After binding with > > (global-set-key [mouse-8 mouse-9] 'write-file) > > C-h k mouse-8 gives > > byte-code: Empty menu > > 3. However, after binding with > > (global-set-key [mouse-8] 'write-file) > > C-h k mouse-8 gives the usual info > > <mouse-8> (translated from <down-mouse-8> <mouse-8>) at that spot runs > the command write-file, which is an interactive compiled Lisp > function. > > It is bound to <mouse-8>, C-x C-w, <menu-bar> <file> <write-file>. > > etc. > > and mouse-8 pops up the file selector window. > > 4. Now, setting > > (global-set-key [mouse-8 mouse-9] 'write-file) > > and executing > > (progn > (push 'mouse-9 unread-command-events) > (push 'mouse-8 unread-command-events)) > > does indeed call write-file. > > 5. I used xev to catch mouse key press events in Xorg: both mouse-8 and > mouse-9 are recognized. This does not tell me much, however, because the > test used xev's own window. When I tell xev to monitor any other window, > e.g., emacs, mouse clicks are not catched by xev. > > 6. Setting the debug variable to true gives simply > > Debugger entered--Lisp error: (error "Empty menu") > > I replicated the tests above using mouse-3 instead of mouse-8 and mouse-2 > instead of mouse-9. Therefore I doubt there's any relation with high > numbered mouse buttons in Xorg. > > This is all I was able to find out, with one addition: double-mouse-8 or > drag-mouse-8 always pops up a menu with just two entries, "tool bar" and > "Menu bar", both giving access to submenus. The former has entries for all > the buttons in the emacs tool bar, but all entries seem disabled. The latter > equals the Lisp-Interaction menu (I am performing tests inside the scratch > buffer). Same using mouse-3 and mouse-2, or using S-mouse-3 and mouse-2; > therefore it looks definitely as an effect of using global-set-key, and not > some predefined undocumented behavior. Moreover, globally unsetting > double-mouse-8 leaves that menu still functional. > > BTW I am using > > GNU Emacs 23.4.1 (i486-pc-linux-gnu, GTK+ Version 2.24.10) > GNU Emacs 23.4.1 (x86_64-pc-linux-gnu, GTK+ Version 2.24.10) > > on Debian Wheezy. > > Any further hint is welcomed. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Binding mouse key sequences 2013-07-04 14:40 ` Michael Heerdegen @ 2013-07-04 16:36 ` greenwaters 0 siblings, 0 replies; 5+ messages in thread From: greenwaters @ 2013-07-04 16:36 UTC (permalink / raw) To: Help-gnu-emacs Thanks Michael, I'll file a bug report. And thanks for trying to find a workaround. Meanwhile I also experimented with keymaps, without success. No matter how bindings are defined, after a mouse event in a prefix key I could only set up a menu keymap. Everything else fails. -- View this message in context: http://emacs.1067599.n5.nabble.com/Binding-mouse-key-sequences-tp291017p291214.html Sent from the Emacs - Help mailing list archive at Nabble.com. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-07-04 16:36 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-07-02 22:48 Binding mouse key sequences greenwaters 2013-07-03 0:16 ` Michael Heerdegen 2013-07-04 9:50 ` greenwaters 2013-07-04 14:40 ` Michael Heerdegen 2013-07-04 16:36 ` greenwaters
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).