unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#13523: 24.2.92; [regression] mark-active
@ 2013-01-22  8:03 Leo Liu
  2013-01-22  8:28 ` Dmitry Gutov
  2013-01-23  8:06 ` Glenn Morris
  0 siblings, 2 replies; 15+ messages in thread
From: Leo Liu @ 2013-01-22  8:03 UTC (permalink / raw)
  To: 13523

I have just wasted a few hours wondering some odd behaviour in js2-mode
but to discover it is due to change between Emacs 23 and 24.

1. (global-set-key [mouse-1] (lambda (e) (interactive "e")))
2. Mouse-1 click on a buffer and check the value of mark-active

In emacs 23 it is nil; but in emacs 24.2/24.2.92, it is t.

With mark-active set to t, some commands following mouse-1 activate the
region unexpectedly and inconveniently, for example, in js2-mode, C-a
activate the region between the mouse and line beginning.

It seems 23 and 24 is consistent only if [mouse-1] is bound to
mouse-set-point.

As a result of this bug, most customised [mouse-1] commands fail to
handle mark-active i.e. it is subtle and hard to get the customised
mouse-1 command behave like mouse-set-point leaving users with creepy
behaviour like the one I am seeing in js2 mode.

Leo





^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#13523: 24.2.92; [regression] mark-active
  2013-01-22  8:03 bug#13523: 24.2.92; [regression] mark-active Leo Liu
@ 2013-01-22  8:28 ` Dmitry Gutov
  2013-01-22  8:59   ` Leo Liu
  2013-01-23  8:06 ` Glenn Morris
  1 sibling, 1 reply; 15+ messages in thread
From: Dmitry Gutov @ 2013-01-22  8:28 UTC (permalink / raw)
  To: Leo Liu; +Cc: 13523

Leo Liu <sdl.web@gmail.com> writes:

> I have just wasted a few hours wondering some odd behaviour in js2-mode
> but to discover it is due to change between Emacs 23 and 24.
>
> 1. (global-set-key [mouse-1] (lambda (e) (interactive "e")))
> 2. Mouse-1 click on a buffer and check the value of mark-active
>
> In emacs 23 it is nil; but in emacs 24.2/24.2.92, it is t.
>
> With mark-active set to t, some commands following mouse-1 activate the
> region unexpectedly and inconveniently, for example, in js2-mode, C-a
> activate the region between the mouse and line beginning.
>
> It seems 23 and 24 is consistent only if [mouse-1] is bound to
> mouse-set-point.
>
> As a result of this bug, most customised [mouse-1] commands fail to
> handle mark-active i.e. it is subtle and hard to get the customised
> mouse-1 command behave like mouse-set-point leaving users with creepy
> behaviour like the one I am seeing in js2 mode.

As far as js2-mode goes, this is supposed to be fixed:
https://github.com/mooz/js2-mode/issues/77

Also see http://lists.gnu.org/archive/html/help-gnu-emacs/2012-12/msg00152.html





^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#13523: 24.2.92; [regression] mark-active
  2013-01-22  8:28 ` Dmitry Gutov
@ 2013-01-22  8:59   ` Leo Liu
  0 siblings, 0 replies; 15+ messages in thread
From: Leo Liu @ 2013-01-22  8:59 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: 13523

On 2013-01-22 16:28 +0800, Dmitry Gutov wrote:
> As far as js2-mode goes, this is supposed to be fixed:
> https://github.com/mooz/js2-mode/issues/77

Thanks for the info. I am merely using js2 as an example; (my copy of
js2 is not even up-to-date).

> Also see
>http://lists.gnu.org/archive/html/help-gnu-emacs/2012-12/msg00152.html

I guess that thread didn't go anywhere.

But I can't believe such a design error has persisted for so long.
Hopefully someone get around to clean it up for the release.

Leo





^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#13523: 24.2.92; [regression] mark-active
  2013-01-22  8:03 bug#13523: 24.2.92; [regression] mark-active Leo Liu
  2013-01-22  8:28 ` Dmitry Gutov
@ 2013-01-23  8:06 ` Glenn Morris
  2013-01-23 12:48   ` Stefan Monnier
  2013-01-24  1:20   ` Leo Liu
  1 sibling, 2 replies; 15+ messages in thread
From: Glenn Morris @ 2013-01-23  8:06 UTC (permalink / raw)
  To: 13523; +Cc: Chong Yidong


So IIUC the issue can be summarized as:

down-mouse-1 runs mouse-drag-region
mouse-1 runs mouse-set-point

mouse-drag-region calls mouse-drag-track.
Since 2010-07-03 (I think), this unconditionally pushes mark.

It then uses track-mouse to watch for further mouse events.
If at the end, point has not moved and the last event was
mouse-set-point or mouse-set-region, it deactivates and pops the mark.

Otherwise it assumes it is handling a multi-click event (since
2010-07-05), and does not deactivate mark.

The result is that if you bind mouse-1 to something other than
mouse-set-point, and leave down-mouse-1 alone, then after a mouse-1 click
the mark stays active (unless you specifically deactivate it).

Examples can be seen with image-dired and rst-toc-mode, which both bind
mouse-1 but not down-mouse-1. In both cases, mouse-1 clicks leave the
mouse active. It doesn't seem to matter in either case, but probably is
not intended.

Is the intention that people bind down-mouse-1 as well/instead of
mouse-1, or that things bound to mouse-1 deactivate mark, or can the
multi-click detection be changed somehow to avoid this?





^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#13523: 24.2.92; [regression] mark-active
  2013-01-23  8:06 ` Glenn Morris
@ 2013-01-23 12:48   ` Stefan Monnier
  2013-01-27  2:16     ` Glenn Morris
  2013-01-24  1:20   ` Leo Liu
  1 sibling, 1 reply; 15+ messages in thread
From: Stefan Monnier @ 2013-01-23 12:48 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 13523, Chong Yidong

> It then uses track-mouse to watch for further mouse events.
> If at the end, point has not moved and the last event was
> mouse-set-point or mouse-set-region, it deactivates and pops the mark.

It should probably unconditionally deactivate the mark and let the
command of the up event run in the normal way.

> Is the intention that people bind down-mouse-1 as well/instead of
> mouse-1, or that things bound to mouse-1 deactivate mark, or can the
> multi-click detection be changed somehow to avoid this?

It can be changed, but IIRC this might be tricky.  Partly because the
current code is pretty tricky already.


        Stefan





^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#13523: 24.2.92; [regression] mark-active
  2013-01-23  8:06 ` Glenn Morris
  2013-01-23 12:48   ` Stefan Monnier
@ 2013-01-24  1:20   ` Leo Liu
  1 sibling, 0 replies; 15+ messages in thread
From: Leo Liu @ 2013-01-24  1:20 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 13523, Chong Yidong

On 2013-01-23 16:06 +0800, Glenn Morris wrote:
> In both cases, mouse-1 clicks leave the mouse active. It doesn't seem
> to matter in either case, but probably is not intended.

One example, C-s following mouse-1 click would unexpectedly activate
region.

Leo





^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#13523: 24.2.92; [regression] mark-active
  2013-01-23 12:48   ` Stefan Monnier
@ 2013-01-27  2:16     ` Glenn Morris
  2013-01-28  1:33       ` Stefan Monnier
  0 siblings, 1 reply; 15+ messages in thread
From: Glenn Morris @ 2013-01-27  2:16 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 13523, Chong Yidong

Stefan Monnier wrote:

>> If at the end, point has not moved and the last event was
>> mouse-set-point or mouse-set-region, it deactivates and pops the mark.
>
> It should probably unconditionally deactivate the mark and let the
> command of the up event run in the normal way.

This seems like something that should be fixed for 24.3, but I don't see
how to do it.





^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#13523: 24.2.92; [regression] mark-active
  2013-01-27  2:16     ` Glenn Morris
@ 2013-01-28  1:33       ` Stefan Monnier
  2013-01-30  2:00         ` Glenn Morris
  0 siblings, 1 reply; 15+ messages in thread
From: Stefan Monnier @ 2013-01-28  1:33 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 13523, Chong Yidong

>>> If at the end, point has not moved and the last event was
>>> mouse-set-point or mouse-set-region, it deactivates and pops the mark.
>> It should probably unconditionally deactivate the mark and let the
>> command of the up event run in the normal way.
> This seems like something that should be fixed for 24.3, but I don't see
> how to do it.

Fixing it right is clearly out of scope of 24.3, but I don't know either
how to patch it up for 24.3.


        Stefan





^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#13523: 24.2.92; [regression] mark-active
  2013-01-28  1:33       ` Stefan Monnier
@ 2013-01-30  2:00         ` Glenn Morris
  2013-01-31  2:47           ` Stefan Monnier
  0 siblings, 1 reply; 15+ messages in thread
From: Glenn Morris @ 2013-01-30  2:00 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 13523, Chong Yidong

Stefan Monnier wrote:

>>>> If at the end, point has not moved and the last event was
>>>> mouse-set-point or mouse-set-region, it deactivates and pops the mark.
[...]
> Fixing it right is clearly out of scope of 24.3, but I don't know either
> how to patch it up for 24.3.

Can we turn the test around, so that rather than saying "deactivate the
mark if the final event was mouse-set-point or mouse-set-region", we say
"deactivate the mark unless the final event was X or Y"?
(I don't know what X or Y are, something related to multi-clicks I guess.)





^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#13523: 24.2.92; [regression] mark-active
  2013-01-30  2:00         ` Glenn Morris
@ 2013-01-31  2:47           ` Stefan Monnier
  2013-01-31  3:34             ` Glenn Morris
  2013-02-01 23:41             ` Stefan Monnier
  0 siblings, 2 replies; 15+ messages in thread
From: Stefan Monnier @ 2013-01-31  2:47 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 13523, Chong Yidong

> Can we turn the test around, so that rather than saying "deactivate the
> mark if the final event was mouse-set-point or mouse-set-region", we say
> "deactivate the mark unless the final event was X or Y"?
> (I don't know what X or Y are, something related to multi-clicks I guess.)

Can someone point out why the patch below wouldn't work?


        Stefan


=== modified file 'lisp/mouse.el'
--- lisp/mouse.el	2013-01-30 17:14:24 +0000
+++ lisp/mouse.el	2013-01-31 02:45:05 +0000
@@ -880,9 +880,9 @@
 		     (copy-region-as-kill (mark) (point)))))
 
 	  ;; Otherwise, run binding of terminating up-event.
+          (deactivate-mark)
 	  (if do-multi-click
 	      (goto-char start-point)
-	    (deactivate-mark)
 	    (unless moved-off-start
 	      (pop-mark)))
 






^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#13523: 24.2.92; [regression] mark-active
  2013-01-31  2:47           ` Stefan Monnier
@ 2013-01-31  3:34             ` Glenn Morris
  2013-01-31  7:21               ` Glenn Morris
  2013-01-31 14:47               ` Stefan Monnier
  2013-02-01 23:41             ` Stefan Monnier
  1 sibling, 2 replies; 15+ messages in thread
From: Glenn Morris @ 2013-01-31  3:34 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 13523, Chong Yidong

Stefan Monnier wrote:

>> Can we turn the test around, so that rather than saying "deactivate the
>> mark if the final event was mouse-set-point or mouse-set-region", we say
>> "deactivate the mark unless the final event was X or Y"?
>> (I don't know what X or Y are, something related to multi-clicks I guess.)
>
> Can someone point out why the patch below wouldn't work?

Won't it break dragging to select a region and activate the mark?





^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#13523: 24.2.92; [regression] mark-active
  2013-01-31  3:34             ` Glenn Morris
@ 2013-01-31  7:21               ` Glenn Morris
  2013-01-31  7:48                 ` Glenn Morris
  2013-01-31 14:47               ` Stefan Monnier
  1 sibling, 1 reply; 15+ messages in thread
From: Glenn Morris @ 2013-01-31  7:21 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 13523

Glenn Morris wrote:

>> Can someone point out why the patch below wouldn't work?
>
> Won't it break dragging to select a region and activate the mark?

Maybe not? I don't understand how any of this works...

Anyway, the conditional deactivation was introduced in r100728
  http://lists.gnu.org/archive/html/emacs-diffs/2010-07/msg00055.html
as something do with double and triple clicks.





^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#13523: 24.2.92; [regression] mark-active
  2013-01-31  7:21               ` Glenn Morris
@ 2013-01-31  7:48                 ` Glenn Morris
  0 siblings, 0 replies; 15+ messages in thread
From: Glenn Morris @ 2013-01-31  7:48 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 13523

Glenn Morris wrote:

> I don't understand how any of this works...

Bearing that in mind, this seems odd:

  (> (event-click-count event) 0)

since surely event-click-count is always >= 1?
But this code predates 24.1.





^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#13523: 24.2.92; [regression] mark-active
  2013-01-31  3:34             ` Glenn Morris
  2013-01-31  7:21               ` Glenn Morris
@ 2013-01-31 14:47               ` Stefan Monnier
  1 sibling, 0 replies; 15+ messages in thread
From: Stefan Monnier @ 2013-01-31 14:47 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 13523, Chong Yidong

>>> Can we turn the test around, so that rather than saying "deactivate the
>>> mark if the final event was mouse-set-point or mouse-set-region", we say
>>> "deactivate the mark unless the final event was X or Y"?
>>> (I don't know what X or Y are, something related to multi-clicks I guess.)
>> Can someone point out why the patch below wouldn't work?
> Won't it break dragging to select a region and activate the mark?

I don't think so, because the next command (the one bound to the
up-event) should/will activate the mark (since the next event should be
a drag-mouse-1).

And in my tests, it seems to work just fine, indeed.

> Bearing that in mind, this seems odd:
>   (> (event-click-count event) 0)
> since surely event-click-count is always >= 1?

Indeed even (event-click-count ?a) returns 1, so the test seems broken.


        Stefan





^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#13523: 24.2.92; [regression] mark-active
  2013-01-31  2:47           ` Stefan Monnier
  2013-01-31  3:34             ` Glenn Morris
@ 2013-02-01 23:41             ` Stefan Monnier
  1 sibling, 0 replies; 15+ messages in thread
From: Stefan Monnier @ 2013-02-01 23:41 UTC (permalink / raw)
  To: Glenn Morris; +Cc: Chong Yidong, 13523-done

> Can someone point out why the patch below wouldn't work?

I've installed the patch in emacs-24.


        Stefan





^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2013-02-01 23:41 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-22  8:03 bug#13523: 24.2.92; [regression] mark-active Leo Liu
2013-01-22  8:28 ` Dmitry Gutov
2013-01-22  8:59   ` Leo Liu
2013-01-23  8:06 ` Glenn Morris
2013-01-23 12:48   ` Stefan Monnier
2013-01-27  2:16     ` Glenn Morris
2013-01-28  1:33       ` Stefan Monnier
2013-01-30  2:00         ` Glenn Morris
2013-01-31  2:47           ` Stefan Monnier
2013-01-31  3:34             ` Glenn Morris
2013-01-31  7:21               ` Glenn Morris
2013-01-31  7:48                 ` Glenn Morris
2013-01-31 14:47               ` Stefan Monnier
2013-02-01 23:41             ` Stefan Monnier
2013-01-24  1:20   ` Leo Liu

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