* when to bind *down-mouse* vs *mouse*?
@ 2004-11-28 18:50 Drew Adams
0 siblings, 0 replies; 2+ messages in thread
From: Drew Adams @ 2004-11-28 18:50 UTC (permalink / raw)
When is it recommended to bind *down-mouse* and when is it recommended to
bind just *mouse*? If the intention is to bind a mouse _click_ event (as
opposed to a drag), then which is generally the key sequence to bind?
I haven't been able to find any recommendations on this in the Info manuals.
If you grep the Emacs Lisp sources for "down-mouse" you will find zillions
of bindings. If you search for "down-mouse" in the Elisp Info doc you will
find that it seems to be used there too, if not explicitly recommended.
Similarly, however, if you grep or Info-search for "mouse-[123]" (and
flush/ignore hits for "down-mouse").
It would seem to make sense generally to bind *mouse* instead of
*down-mouse* for a mouse-click event, but perhaps there are considerations
having to do with multi-click or drag events that confuse the issue.
Now, this I think I can understand:
- down-mouse-1 is bound to mouse-drag-region.
- mouse-1 is bound to mouse-set-point.
If you press mouse-1 and don't follow it by a release in the same spot, you
get mouse-drag-region. (In fact, you get mouse-drag-region when you press,
and then mouse-drag-region reads another event and calls mouse-set-point.)
However, some of the standard bindings seem contradictory to me (but I'm no
doubt missing some fundamental logic behind mouse-button bindings):
- S-down-mouse-1 is bound to mouse-set-font.
- M-mouse-2 is bound to mouse-yank-secondary.
So, for instance:
- If you want to override `mouse-set-font' in, say, Dired mode, you would
presumably do something like this:
(define-key dired-mode-map [S-down-mouse-1] 'my-S-m1-cmd)
- If you want to override `mouse-yank-secondary' in Dired mode, you would
presumably do something (different) like this:
(define-key dired-mode-map [M-mouse-2] 'my-M-m2-cmd)
- If however, you did the following (for instance), then clicking
[M-mouse-2] in Dired could presumably (depending on when you released the
mouse button): 1) open the clicked file in another frame and then 2)
`mouse-yank-secondary' into that opened file - probably not what you want.
(define-key dired-mode-map [M-down-mouse-2]
'dired-mouse-find-file-other-frame)
- Note that even this additional binding wouldn't help in that situation, if
you released the button after the clicked file was opened:
(define-key dired-mode-map [M-mouse-2] 'ignore)
[This behavior is in fact what I see on Emacs 20. On Emacs 21, this problem
does not appear to arise (the `mouse-yank-secondary' does not take place) -
but I'm not sure why.]
Can someone clear this up for me? What is the recommendation? What is the
logic behind mouse bindings for click events? Are some of the standard
bindings inconsistent, or am I just missing something?
Thanks,
Drew
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-11-29 15:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <mailman.2011.1101668442.27204.help-gnu-emacs@gnu.org>
2004-11-29 15:11 ` when to bind *down-mouse* vs *mouse*? Stefan Monnier
2004-11-28 18:50 Drew Adams
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).