all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Difficulty with mouse-1-click-follows-link
@ 2005-10-09 17:57 Chong Yidong
  2005-10-09 18:51 ` Romain Francoise
  0 siblings, 1 reply; 13+ messages in thread
From: Chong Yidong @ 2005-10-09 17:57 UTC (permalink / raw)
  Cc: Kim F.Storm

I've figured out the trouble I have using mouse-1-click-follows-link.
It happens when I do the following (in rapid succession):

  * down-mouse-1 on a link
  * release the mouse button
  * move the mouse cursor somewhere else

If I move the cursor away too soon, the follow-link behavior is
cancelled.  That's counter-intuitive, because I already released the
mouse button.  As a result, it *feels* as though
mouse-1-click-follows-link is unreliable.

The problematic code is in mouse.el:

        (if (and on-link
                 ...
                 (or remap-double-click
                     (and
                      (not (eq mouse-1-click-follows-link 'double))
                      (= click-count 0)
                      ....
                      (or (not double-click-time)
                          (sit-for 0 (if (integerp double-click-time)
                                         double-click-time 500) t)))))
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            (if (or (vectorp on-link) (stringp on-link))
                (setq event (aref on-link 0))
              (setcar event 'mouse-2)))
        (push event unread-command-events))))

The sit-for call is intended to catch a second click, so that the
follow-link mechanism won't kick in when the user double-clicks.
However, it also catches mouse motion, which leads to the
unreliability described above.

The sit-for is also responsible for the small but irritating delay
between clicking on a link and the action taking place.

In practice, binding double-mouse-1 doesn't seem to work for links
anyway, so I suggest removing the sit-for.  I've tried it out, and
follow-link seems to work much more smoothly.

Thoughts?

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

* Re: Difficulty with mouse-1-click-follows-link
  2005-10-09 17:57 Difficulty with mouse-1-click-follows-link Chong Yidong
@ 2005-10-09 18:51 ` Romain Francoise
  2005-10-10 16:46   ` Chong Yidong
  0 siblings, 1 reply; 13+ messages in thread
From: Romain Francoise @ 2005-10-09 18:51 UTC (permalink / raw)


Chong Yidong <cyd@stupidchicken.com> writes:

> Thoughts?

Try lowering the value of `double-click-time' in your setup.  I have set
it to 150 and I'm pretty happy with that setting... but I very rarely
use double clicks in Emacs.

-- 
Romain Francoise <romain@orebokech.com> | I like the streets when
it's a miracle -- http://orebokech.com/ | they're empty, I can make the
                                        | rest up.

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

* Re: Difficulty with mouse-1-click-follows-link
  2005-10-09 18:51 ` Romain Francoise
@ 2005-10-10 16:46   ` Chong Yidong
  2005-10-11 17:16     ` Romain Francoise
  0 siblings, 1 reply; 13+ messages in thread
From: Chong Yidong @ 2005-10-10 16:46 UTC (permalink / raw)
  Cc: emacs-devel

>> Thoughts?
>
> Try lowering the value of `double-click-time' in your setup.  I have set
> it to 150 and I'm pretty happy with that setting... but I very rarely
> use double clicks in Emacs.

I'm more interested in fixing the default behavior.  Removing the
sit-for in mouse-drag-region-1 won't have any effect on double-clicks
elsewhere in Emacs.

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

* Re: Difficulty with mouse-1-click-follows-link
  2005-10-10 16:46   ` Chong Yidong
@ 2005-10-11 17:16     ` Romain Francoise
  2005-10-11 21:04       ` Kim F. Storm
  0 siblings, 1 reply; 13+ messages in thread
From: Romain Francoise @ 2005-10-11 17:16 UTC (permalink / raw)
  Cc: emacs-devel

Chong Yidong <cyd@stupidchicken.com> writes:

> I'm more interested in fixing the default behavior.  Removing the
> sit-for in mouse-drag-region-1 won't have any effect on double-clicks
> elsewhere in Emacs.

The change you installed appears to be a major usability improvement,
indeed.  Thank you.

-- 
Romain Francoise <romain@orebokech.com> | I've become someone else's
it's a miracle -- http://orebokech.com/ | nightmare...

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

* Re: Difficulty with mouse-1-click-follows-link
  2005-10-11 17:16     ` Romain Francoise
@ 2005-10-11 21:04       ` Kim F. Storm
  2005-10-11 21:20         ` Chong Yidong
  0 siblings, 1 reply; 13+ messages in thread
From: Kim F. Storm @ 2005-10-11 21:04 UTC (permalink / raw)
  Cc: Chong Yidong, emacs-devel

Romain Francoise <romain@orebokech.com> writes:

> Chong Yidong <cyd@stupidchicken.com> writes:
>
>> I'm more interested in fixing the default behavior.  Removing the
>> sit-for in mouse-drag-region-1 won't have any effect on double-clicks
>> elsewhere in Emacs.
>
> The change you installed appears to be a major usability improvement,
> indeed.  Thank you.

As the author of the feature, I just want to point out that originally
I did not include double-click support, but I added it on request from RMS.

If it turns out to be a major obstackle for using the feature (I haven't
had that experience myself), I don't mind removing it.

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

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

* Re: Difficulty with mouse-1-click-follows-link
  2005-10-11 21:04       ` Kim F. Storm
@ 2005-10-11 21:20         ` Chong Yidong
  2005-10-12  9:32           ` Kim F. Storm
  0 siblings, 1 reply; 13+ messages in thread
From: Chong Yidong @ 2005-10-11 21:20 UTC (permalink / raw)
  Cc: Romain Francoise, emacs-devel

> As the author of the feature, I just want to point out that originally
> I did not include double-click support, but I added it on request from RMS.
>
> If it turns out to be a major obstackle for using the feature (I haven't
> had that experience myself), I don't mind removing it.

Just to avoid a misunderstanding: the change I made (removing the
sit-for call in mouse-drag-region-1) doesn't affect the double-click
support.  Setting mouse-1-click-follows-link to 'double still has the
same results: it makes a double-click rather than a single click
follow the link.  As far as I can see, there are no bad side-effects
to the change.

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

* Re: Difficulty with mouse-1-click-follows-link
  2005-10-11 21:20         ` Chong Yidong
@ 2005-10-12  9:32           ` Kim F. Storm
  2005-10-12 13:11             ` Chong Yidong
  2005-10-13  4:52             ` Richard M. Stallman
  0 siblings, 2 replies; 13+ messages in thread
From: Kim F. Storm @ 2005-10-12  9:32 UTC (permalink / raw)
  Cc: Romain Francoise, emacs-devel

Chong Yidong <cyd@stupidchicken.com> writes:

>> As the author of the feature, I just want to point out that originally
>> I did not include double-click support, but I added it on request from RMS.
>>
>> If it turns out to be a major obstackle for using the feature (I haven't
>> had that experience myself), I don't mind removing it.
>
> Just to avoid a misunderstanding: the change I made (removing the
> sit-for call in mouse-drag-region-1) doesn't affect the double-click
> support.  Setting mouse-1-click-follows-link to 'double still has the
> same results: it makes a double-click rather than a single click
> follow the link.  As far as I can see, there are no bad side-effects
> to the change.

IIRC, the code you removed was intended to make a double-click do the
normal action at point rather than following the link 
(when mouse-1-click-follows-link != double-click).

I'm not sure how useful that feature was, but it was added on request
from RMS.

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

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

* Re: Difficulty with mouse-1-click-follows-link
  2005-10-12  9:32           ` Kim F. Storm
@ 2005-10-12 13:11             ` Chong Yidong
  2005-10-12 13:37               ` Kim F. Storm
  2005-10-13  4:52             ` Richard M. Stallman
  1 sibling, 1 reply; 13+ messages in thread
From: Chong Yidong @ 2005-10-12 13:11 UTC (permalink / raw)
  Cc: Romain Francoise, emacs-devel

> IIRC, the code you removed was intended to make a double-click do the
> normal action at point rather than following the link 
> (when mouse-1-click-follows-link != double-click).
>
> I'm not sure how useful that feature was, but it was added on request
> from RMS.

It didn't do that; the double-click binding never got called.  To bind
double-mouse-1 to something, you had to unbind down-mouse-1, which
means mouse-drag-region-1 wouldn't get called anyway.

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

* Re: Difficulty with mouse-1-click-follows-link
  2005-10-12 13:11             ` Chong Yidong
@ 2005-10-12 13:37               ` Kim F. Storm
  0 siblings, 0 replies; 13+ messages in thread
From: Kim F. Storm @ 2005-10-12 13:37 UTC (permalink / raw)
  Cc: Romain Francoise, emacs-devel

Chong Yidong <cyd@stupidchicken.com> writes:

>> IIRC, the code you removed was intended to make a double-click do the
>> normal action at point rather than following the link 
>> (when mouse-1-click-follows-link != double-click).
>>
>> I'm not sure how useful that feature was, but it was added on request
>> from RMS.
>
> It didn't do that; the double-click binding never got called.  To bind
> double-mouse-1 to something, you had to unbind down-mouse-1, which
> means mouse-drag-region-1 wouldn't get called anyway.

Are you sure?

IIUC, double clicks works by executing the mouse-1 action on the
first click, and the double-mouse-1 action on the second click.

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

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

* Re: Difficulty with mouse-1-click-follows-link
  2005-10-12  9:32           ` Kim F. Storm
  2005-10-12 13:11             ` Chong Yidong
@ 2005-10-13  4:52             ` Richard M. Stallman
  2005-10-13 14:39               ` Stefan Monnier
  2005-10-13 15:33               ` Chong Yidong
  1 sibling, 2 replies; 13+ messages in thread
From: Richard M. Stallman @ 2005-10-13  4:52 UTC (permalink / raw)
  Cc: cyd, romain, emacs-devel

    IIRC, the code you removed was intended to make a double-click do the
    normal action at point rather than following the link 
    (when mouse-1-click-follows-link != double-click).

That is important.  Double-click of mouse-1 has a standard meaning,
and the link-following feature is not supposed to interfere with it.

Whether the old code succeeded in keeping double-click working right,
I don't know.  But if it doesn't work correctly now, it needs to be
fixed.

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

* Re: Difficulty with mouse-1-click-follows-link
  2005-10-13  4:52             ` Richard M. Stallman
@ 2005-10-13 14:39               ` Stefan Monnier
  2005-10-13 15:33               ` Chong Yidong
  1 sibling, 0 replies; 13+ messages in thread
From: Stefan Monnier @ 2005-10-13 14:39 UTC (permalink / raw)
  Cc: cyd, romain, emacs-devel, Kim F. Storm

>>>>> "Richard" == Richard M Stallman <rms@gnu.org> writes:

>     IIRC, the code you removed was intended to make a double-click do the
>     normal action at point rather than following the link 
>     (when mouse-1-click-follows-link != double-click).

> That is important.  Double-click of mouse-1 has a standard meaning,
> and the link-following feature is not supposed to interfere with it.

> Whether the old code succeeded in keeping double-click working right,
> I don't know.  But if it doesn't work correctly now, it needs to be
> fixed.

An alternative implementation which may fix the problem could look like:

After the first click, start a timer waiting for double-click-time and
add a pre-command-hook.  The timer just runs the mouse-2 binding.
The pre-command-hook will cancel the timer and depending on whether the
triggering event is a double-click or not, it will run the mouse-2 binding.

This way you avoid the problematic sit-for.  But it's pretty nasty code in
any case.


        Stefan

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

* Re: Difficulty with mouse-1-click-follows-link
  2005-10-13  4:52             ` Richard M. Stallman
  2005-10-13 14:39               ` Stefan Monnier
@ 2005-10-13 15:33               ` Chong Yidong
  2005-10-14  5:10                 ` Richard M. Stallman
  1 sibling, 1 reply; 13+ messages in thread
From: Chong Yidong @ 2005-10-13 15:33 UTC (permalink / raw)
  Cc: romain, emacs-devel, Kim F. Storm

> That is important.  Double-click of mouse-1 has a standard meaning,
> and the link-following feature is not supposed to interfere with it.
>
> Whether the old code succeeded in keeping double-click working right,
> I don't know.  But if it doesn't work correctly now, it needs to be
> fixed.

This patch should fix the problem.  I think `mouse-drag-region-1' was
failing to call double-click bindings because it assumed that
double-mouse-1 was bound to `mouse-set-point'.

By the way, there's no need to drop the mouse-1 event if the user
double-clicks (which is what the sit-for was trying to do).  The Elisp
manual says that

   When the user performs a double click, Emacs generates first an
   ordinary click event, and then a double-click event.  Therefore,
   you must design the command binding of the double click event to
   assume that the single-click command has already run.  It must
   produce the desired results of a double click, starting from the
   results of a single click.

This patch should make mouse-1 and double-mouse-1 work as stated.
Could people test it out?


*** emacs/lisp/mouse.el.~1.281.~	2005-10-09 13:59:03.000000000 -0400
--- emacs/lisp/mouse.el	2005-10-13 11:19:30.000000000 -0400
***************
*** 958,969 ****
          (mouse-move-drag-overlay mouse-drag-overlay start-point end-point click-count))
  
        (if (consp event)
! 	  (let ((fun (key-binding (vector (car event)))))
              ;; Run the binding of the terminating up-event, if possible.
              ;; In the case of a multiple click, it gives the wrong results,
  	    ;; because it would fail to set up a region.
! 	    (if (not (= (overlay-start mouse-drag-overlay)
! 			(overlay-end mouse-drag-overlay)))
  		(let* ((stop-point
  			(if (numberp (posn-point (event-end event)))
  			    (posn-point (event-end event))
--- 958,973 ----
          (mouse-move-drag-overlay mouse-drag-overlay start-point end-point click-count))
  
        (if (consp event)
! 	  (let* ((fun (key-binding (vector (car event))))
! 		 (do-multi-click   (and (> (event-click-count event) 0)
! 					(functionp fun)
! 					(not (eq fun 'mouse-set-point)))))
              ;; Run the binding of the terminating up-event, if possible.
              ;; In the case of a multiple click, it gives the wrong results,
  	    ;; because it would fail to set up a region.
! 	    (if (and (not (= (overlay-start mouse-drag-overlay)
! 			     (overlay-end mouse-drag-overlay)))
! 		     (not do-multi-click))
  		(let* ((stop-point
  			(if (numberp (posn-point (event-end event)))
  			    (posn-point (event-end event))
***************
*** 996,1001 ****
--- 1000,1006 ----
                      (and (mark t) mark-active
                           (eq buffer (current-buffer))
                           (mouse-set-region-1))))
+ 	      (if do-multi-click (goto-char start-point))
                (delete-overlay mouse-drag-overlay)
                ;; Run the binding of the terminating up-event.
                (when (and (functionp fun)

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

* Re: Difficulty with mouse-1-click-follows-link
  2005-10-13 15:33               ` Chong Yidong
@ 2005-10-14  5:10                 ` Richard M. Stallman
  0 siblings, 0 replies; 13+ messages in thread
From: Richard M. Stallman @ 2005-10-14  5:10 UTC (permalink / raw)
  Cc: romain, emacs-devel, storm

Thansk very much for fixing the double-click.

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

end of thread, other threads:[~2005-10-14  5:10 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-09 17:57 Difficulty with mouse-1-click-follows-link Chong Yidong
2005-10-09 18:51 ` Romain Francoise
2005-10-10 16:46   ` Chong Yidong
2005-10-11 17:16     ` Romain Francoise
2005-10-11 21:04       ` Kim F. Storm
2005-10-11 21:20         ` Chong Yidong
2005-10-12  9:32           ` Kim F. Storm
2005-10-12 13:11             ` Chong Yidong
2005-10-12 13:37               ` Kim F. Storm
2005-10-13  4:52             ` Richard M. Stallman
2005-10-13 14:39               ` Stefan Monnier
2005-10-13 15:33               ` Chong Yidong
2005-10-14  5:10                 ` Richard M. Stallman

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.