[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 14:23:54 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/21.3.50 (gnu/linux)

David Kastrup <address@hidden> writes:

>> 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
> Well, I happen to disagree, since following a link is the more time
> consuming action, anyway, and people might be tempted to press until
> the browser window appears.

If you keep the button pressed in emacs, the window NEVER appears (as
it is the up-event which follows the link), so I doubt users do that.

> In any case, neither option is the behavior that a user would guess
> without being explicitly introduced to it.  So we need to turn it off
> by default, or give an explanatory message of some kind by default.

Well, if the "normal" click follows the link (and I claim that the
normal click is the short click), most users will never think there is
a problem, as they don't usually have to set the mouse in the middle
of a link.

They will probably set it next to the link and move the cursor into
the link (that's how it is often done in other applications).

Now, the more advanced users will ask (or find out by themselves) that
a longer click sets the mouse.  That is no different from a lot of
other functionality in emacs, where the defaults suit the majority,
but can be tweaked by the rest).

I really don't think a message is worth the extra code [but if
that's a prerequisite to get this installed, I'll do it].

>> Appended is a patch which uses get-text-property rather than
>> get-char-property to ignore overlay mouse-face properties.
> I firmly object to such a course.  While we should not let ourselves
> be influenced too much by that, with XEmacs there is not even a
> distinction between overlays and text properties.  The choice between
> the two when using Emacs should depend _exclusively_ on whether you
> need the association with the text or the buffer, and not on any
> chance side effects introduced to accidentally work with some package.

True, so it's the wrong solution.  What is the right solution?

Below is a patch which checks if the "link" has a dont-follow-link
property.  That requires package authors to adapt their code if they
don't want mouse-1 to follow links, but it is a trivial addition...

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 12:25:34 -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))
+                        (get-char-property start-point 'mouse-face)
+                        (not (get-char-property start-point 'dont-follow-link))
+                        (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]