[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: finger-pointer curser as default for mouse-face text

From: Kim F. Storm
Subject: Re: finger-pointer curser as default for mouse-face text
Date: Tue, 26 Oct 2004 11:00:26 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/21.3.50 (gnu/linux)

Stefan Monnier <address@hidden> writes:

>> If the time stamps for the clicks indeed come from the X server, then
>> Kim's timed scheme would probably not be very susceptible to system
>> load/traffic congestion effects.
> The problm with it is that it goes against what we're trying to do, which is
> to get Emacs's UI in line with "what non-Emacs users expect".
> I.e. such users will just do a simple click and expect it to follow
> the link.

Yes, that's what we are trying to achieve -- the fundamental problem
we discuss here is actually how to recognize when the stuff is a link
and when it is something else which has a mouse-face property.

In the examples given until now, the non-links have the mouse-face
on an overlay -- so maybe to fix would be to only follow link which
have the mouse-face as a text property in the buffer.

If we can safely differentiate between links and non-links I think
a short click should follow the link (double-clicks typically don't
make sense there anyway) and a long click should set point

Appended is a patch which uses get-text-property rather than
get-char-property to ignore overlay mouse-face properties.

The patch also allows you to double click on a link to get the normal
double-click action in the buffer rather than following the link.
To do that, I wait "double-click-time" milliseconds before following
the link -- if any input arrives in that period, I don't follow the
link.  May feel a little "slow", but it's worth a try.

> Adding a message saying "please keep the button pressed longer if you want
> to follow the link" is really not much better than adding a message that
> says "use mouse-2 if you want to follow the link".
> And if you add to the equation the extra code and conceptual complexity of
> using timing-dependent information, I find it ends up a loser.

I don't really want to add any message there -- if we leave the feature
disabled by default, the users who turn it on doesn't need to be told
how to get the alternative behaviour.

If we turn on the feature by default, there should at least be some
way to disable that message.

>> After all, we have the same problem with recognizing double-clicks.
> Sure.  But users have wanted double-clicks, so we gave it to them.
> Users's aren't asking for variable-duration clicks.  OTOH users are quite
> used to not being able to move cursor into a link by just left-clicking on
> it.  It may annoy them at times, but it seems to annoy them less than having
> to use mouse-2.

Variable length clicks are a new user interface invention in emacs :-)

Index: mouse.el
RCS file: /cvsroot/emacs/emacs/lisp/mouse.el,v
retrieving revision 1.251
diff -c -r1.251 mouse.el
*** mouse.el    18 Oct 2004 09:29:26 -0000      1.251
--- mouse.el    26 Oct 2004 08:56:24 -0000
*** 48,53 ****
--- 48,81 ----
    :type 'boolean
    :group 'mouse)
+ (defcustom mouse-1-click-follows-link 300
+   "Non-nil means that clicking mouse-1 on a link follows the link.
+ This is only done for links which have the mouse-face property.
+ If value is an positive integer, it specifies the maximum
+ duration in milli-seconds of the mouse-1 click to be recognized
+ as a mouse-2 click.  If the time between pressing and releasing
+ the mouse button is longer, the normal mouse-1 command (typically
+ set point) is performed.
+ If value is an negative integer, its absolute value specifies the
+ minimum duration in milli-seconds of the mouse-1 click to be
+ recognized as a mouse-2 click.  If the time between pressing and
+ releasing the mouse button is longer, the normal mouse-1 command
+ is performed.
+ Otherwise, mouse-1 unconditionally follows the link, unless you
+ drag the mouse in the link to run the normal mouse-1 command."
+   :version "21.4"
+   :type '(choice (const :tag "Disabled" nil)
+                  (number :tag "Click time limit" :value 300)
+                  (other :tag "Enabled" t))
+   :group 'mouse)
  ;; Provide a mode-specific menu on a mouse button.
*** 877,882 ****
--- 905,929 ----
                         (or end-point
                             (= (window-start start-window)
+               (if (and mouse-1-click-follows-link
+                        (not end-point)
+                        (consp event)
+                        (= click-count 0)
+                        (= (event-click-count event) 1)
+                        (not (input-pending-p))
+                        ;; Don't want to look at overlays here
+                        (get-text-property start-point 'mouse-face)
+                        (or (not (integerp mouse-1-click-follows-link))
+                            (let ((t0 (posn-timestamp (event-start 
+                                  (t1 (posn-timestamp (event-end event))))
+                              (and (integerp t0) (integerp t1)
+                                   (if (> mouse-1-click-follows-link 0)
+                                       (<= (- t1 t0) 
+                                     (< (- t0 t1) 
+                        (or (not double-click-time)
+                            (sit-for 0 (if (integerp double-click-time)
+                                           double-click-time 500) t)))
+                   (setcar event 'mouse-2))
                (setq unread-command-events
                      (cons event unread-command-events)))))
        (delete-overlay mouse-drag-overlay)))))

Kim F. Storm <address@hidden> http://www.cua.dk

reply via email to

[Prev in Thread] Current Thread [Next in Thread]