[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: Sun, 24 Oct 2004 14:42:03 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/21.3.50 (gnu/linux)

Richard Stallman <address@hidden> writes:

> Maybe it is good enough to be able to drag the mouse into the area
> and then release it and ignore the mark setting that it made.
> This is the sort of change for which we need to conduct a poll of the
> users.

I found a simpler solution which works really well, as it provides the
fallback directly on mouse-1 itself:

Measure the time between the mouse-1 down event and the up event, and
if it less than 300 ms (configurable), follow the link, else do what
mouse-1 normally does.

So a "fast" click follows the link, a slightly slower click sets the
point (or whatever mouse-1 does).  Dragging the mouse also inhibits
following the link.

Here is a patch:

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    24 Oct 2004 12:38:38 -0000
*** 48,53 ****
--- 48,66 ----
    :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 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 action, e.g.  set point, is performed."
+   :version "21.4"
+   :type '(choice (const :tag "Disabled" nil)
+                  (number :tag "Max. click time" :value 300)
+                  (other :tag "Enabled" t)))
  ;; Provide a mode-specific menu on a mouse button.
*** 877,882 ****
--- 890,905 ----
                         (or end-point
                             (= (window-start start-window)
+               (if (and mouse-1-click-follows-link
+                        (not end-point)
+                        (consp event)
+                        (get-char-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)
+                                   (<= (- t1 t0) 
+                   (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]