unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* when to bind *down-mouse* vs *mouse*?
@ 2004-12-02 22:28 Drew Adams
  2004-12-03  1:10 ` Andreas Schwab
  2004-12-03  2:00 ` Luc Teirlinck
  0 siblings, 2 replies; 23+ messages in thread
From: Drew Adams @ 2004-12-02 22:28 UTC (permalink / raw)


I sent this to help-gnu-emacs a few days ago, but got no response. Can
anyone here help?

--

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] 23+ messages in thread

end of thread, other threads:[~2004-12-09  4:42 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-12-02 22:28 when to bind *down-mouse* vs *mouse*? Drew Adams
2004-12-03  1:10 ` Andreas Schwab
2004-12-03  1:26   ` Drew Adams
2004-12-03 10:08     ` Andreas Schwab
2004-12-03 17:22       ` Drew Adams
2004-12-03 21:22         ` Andreas Schwab
2004-12-05 14:37         ` Richard Stallman
2004-12-03  2:00 ` Luc Teirlinck
2004-12-03 17:22   ` Drew Adams
2004-12-03 18:53     ` Luc Teirlinck
2004-12-04 10:19     ` Jason Rumney
2004-12-04 17:59     ` Alex Schroeder
2004-12-04 19:06       ` Lennart Borgman
2004-12-04 21:42         ` Jan D.
2004-12-05  0:10         ` Luc Teirlinck
2004-12-07 13:20           ` Jan D.
2004-12-06 19:16       ` Drew Adams
2004-12-06 20:10         ` Stefan Monnier
2004-12-08  1:38         ` Alex Schroeder
2004-12-08 19:06           ` Drew Adams
2004-12-08 19:45             ` Stefan Monnier
2004-12-08 20:42               ` Drew Adams
2004-12-09  4:42             ` Richard Stallman

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