* How to bind a command to mouse-1 properly?
@ 2012-12-12 7:36 Dmitry Gutov
0 siblings, 0 replies; 6+ messages in thread
From: Dmitry Gutov @ 2012-12-12 7:36 UTC (permalink / raw)
To: help-gnu-emacs
Hi all,
If I bind a command other than `mouse-set-point' to [mouse-1], the mark
is active after the mouse click. Example:
1. (global-set-key [mouse-1] (lambda (e) (interactive "e")
(mouse-set-point e)))
2. Click somewhere in a buffer.
3. Press `C-s', then search for some existing word.
=> the region will be active and span from the position of the click to
the new point.
If, on the other hand,
1. (global-set-key [mouse-1] 'mouse-set-point)
2, 3: same as before.
=> the region is not active.
Should I (setq deactivate-mark t) inside the command body?
--Dmitry
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How to bind a command to mouse-1 properly?
@ 2012-12-12 9:42 martin rudalics
2012-12-12 10:01 ` Dmitry Gutov
0 siblings, 1 reply; 6+ messages in thread
From: martin rudalics @ 2012-12-12 9:42 UTC (permalink / raw)
To: dgutov; +Cc: help-gnu-emacs
> If I bind a command other than `mouse-set-point' to [mouse-1], the mark
> is active after the mouse click.
I suppose this issue was discussed in bug#9541 and in
http://lists.gnu.org/archive/html/emacs-devel/2011-04/msg00399.html
martin
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How to bind a command to mouse-1 properly?
2012-12-12 9:42 How to bind a command to mouse-1 properly? martin rudalics
@ 2012-12-12 10:01 ` Dmitry Gutov
2012-12-12 10:21 ` martin rudalics
0 siblings, 1 reply; 6+ messages in thread
From: Dmitry Gutov @ 2012-12-12 10:01 UTC (permalink / raw)
To: martin rudalics; +Cc: help-gnu-emacs
On 12.12.2012 13:42, martin rudalics wrote:
> > If I bind a command other than `mouse-set-point' to [mouse-1], the mark
> > is active after the mouse click.
>
> I suppose this issue was discussed in bug#9541 and in
>
> http://lists.gnu.org/archive/html/emacs-devel/2011-04/msg00399.html
They look related, but I don't see anything helpful there.
The bug discusses clicking inside scroll-margin (I'm not), and the fact
the mouse-clicks set the mark is declared intended at the end.
The emacs-devel link describes a problem which I don't encounter, and
seems to fizzle out in the end, without resolution.
(setq deactivate-mark t) works, by the way. I just don't understand why
I have to do that, and if I should do something else.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How to bind a command to mouse-1 properly?
2012-12-12 10:01 ` Dmitry Gutov
@ 2012-12-12 10:21 ` martin rudalics
2012-12-12 11:25 ` Dmitry Gutov
0 siblings, 1 reply; 6+ messages in thread
From: martin rudalics @ 2012-12-12 10:21 UTC (permalink / raw)
To: Dmitry Gutov; +Cc: help-gnu-emacs
> The bug discusses clicking inside scroll-margin (I'm not), and the fact
> the mouse-clicks set the mark is declared intended at the end.
As Johan mentions in this thread ...
>> The real bug is that mouse-clicks set the mark (always). (Search for
>> push-mark in mouse-drag-track.)
... which should explain ...
> (setq deactivate-mark t) works, by the way. I just don't understand why
> I have to do that, and if I should do something else.
... why you have "to do that".
martin
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How to bind a command to mouse-1 properly?
2012-12-12 10:21 ` martin rudalics
@ 2012-12-12 11:25 ` Dmitry Gutov
2012-12-12 12:43 ` martin rudalics
0 siblings, 1 reply; 6+ messages in thread
From: Dmitry Gutov @ 2012-12-12 11:25 UTC (permalink / raw)
To: martin rudalics; +Cc: help-gnu-emacs
On 12.12.2012 14:21, martin rudalics wrote:
> > The bug discusses clicking inside scroll-margin (I'm not), and the fact
> > the mouse-clicks set the mark is declared intended at the end.
>
> As Johan mentions in this thread ...
>
> >> The real bug is that mouse-clicks set the mark (always). (Search for
> >> push-mark in mouse-drag-track.)
And Chong answers that this behavior is intended. And the bug is closed.
> ... which should explain ...
>
> > (setq deactivate-mark t) works, by the way. I just don't understand why
> > I have to do that, and if I should do something else.
>
> ... why you have "to do that".
If you look at my examples, the "non-working" one does exactly the same
thing as the working one. The only difference is the command name.
I guess the reason is in this mouse-drag-track code:
;; Find its binding.
(let* ((fun (key-binding (vector (car event))))
(do-multi-click (and (> (event-click-count event) 0)
(functionp fun)
(not (memq fun '(mouse-set-point
mouse-set-region))))))
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How to bind a command to mouse-1 properly?
2012-12-12 11:25 ` Dmitry Gutov
@ 2012-12-12 12:43 ` martin rudalics
0 siblings, 0 replies; 6+ messages in thread
From: martin rudalics @ 2012-12-12 12:43 UTC (permalink / raw)
To: Dmitry Gutov; +Cc: help-gnu-emacs
> If you look at my examples, the "non-working" one does exactly the same
> thing as the working one. The only difference is the command name.
> I guess the reason is in this mouse-drag-track code:
>
> ;; Find its binding.
> (let* ((fun (key-binding (vector (car event))))
> (do-multi-click (and (> (event-click-count event) 0)
> (functionp fun)
> (not (memq fun '(mouse-set-point
> mouse-set-region))))))
Probably. Ever since that change I get an active region in at least
three independent contexts, one of them being Info. But I was too lazy
to look into this issue yet.
martin
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-12-12 12:43 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-12 9:42 How to bind a command to mouse-1 properly? martin rudalics
2012-12-12 10:01 ` Dmitry Gutov
2012-12-12 10:21 ` martin rudalics
2012-12-12 11:25 ` Dmitry Gutov
2012-12-12 12:43 ` martin rudalics
-- strict thread matches above, loose matches on Subject: below --
2012-12-12 7:36 Dmitry Gutov
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.