emacs-devel
[Top][All Lists]
Advanced

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

David Kastrup <address@hidden> writes:

> I think that nobody will complain if a double click on a link will
> cause it to execute instead of marking a word or line.  It is indeed
> rare that you need to mark a work from inside a link; and if you do,
> you can do it by normal dragging marking without much additional
> hassle.

It was a little more complex to implement than the previous methods,
but here is a patch which adds 'double click' support as a user option:

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    27 Oct 2004 12:29:31 -0000
***************
*** 48,53 ****
--- 48,77 ----
    :type 'boolean
    :group 'mouse)
  
+ (defcustom mouse-1-click-follows-link 'double
+   "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 the symbol double, a double click follows the link.
+ 
+ If value is an integer, the time between pressing and releasing
+ the mouse button determines whether to follow the link or perform
+ the normal mouse-1 action (typically set point).  The absolute
+ numeric value specifices the maximum duration of a \"short click\"
+ in milli-seconds.  A positive value means that a short click
+ follows the link, and a longer click performs the normal action.
+ A negative value specifies the opposite behaviour.
+ 
+ Otherwise, a single mouse-1 click unconditionally follows the link.
+ 
+ Note that dragging the mouse never follows the link."
+   :version "21.4"
+   :type '(choice (const :tag "Disabled" nil)
+                (const :tag "Double click" double)
+                  (number :tag "Single click time limit" :value 300)
+                  (other :tag "Single click" t))
+   :group 'mouse)
+ 
  
  ;; Provide a mode-specific menu on a mouse button.
  
***************
*** 731,736 ****
--- 755,764 ----
        (run-hooks 'mouse-leave-buffer-hook)
        (mouse-drag-region-1 start-event))))
  
+ (defun mouse-on-link-p (pos)
+   (and (get-char-property pos 'mouse-face)
+        (not (get-char-property pos 'dont-follow-link))))
+ 
  (defun mouse-drag-region-1 (start-event)
    (mouse-minibuffer-check start-event)
    (let* ((echo-keystrokes 0)
***************
*** 746,751 ****
--- 774,780 ----
                     (nth 3 bounds)
                   ;; Don't count the mode line.
                   (1- (nth 3 bounds))))
+        on-link remap-double-click
         (click-count (1- (event-click-count start-event))))
      (setq mouse-selection-click-count click-count)
      (setq mouse-selection-click-count-buffer (current-buffer))
***************
*** 755,760 ****
--- 784,796 ----
      (if (< (point) start-point)
        (goto-char start-point))
      (setq start-point (point))
+     (setq on-link (and mouse-1-click-follows-link
+                      (mouse-on-link-p start-point)))
+     (setq remap-double-click (and on-link
+                                 (eq mouse-1-click-follows-link 'double)
+                                 (= click-count 1)))
+     (if remap-double-click  ;; Don't expand mouse overlay in links
+       (setq click-count 0))
      (let ((range (mouse-start-end start-point start-point click-count)))
        (move-overlay mouse-drag-overlay (car range) (nth 1 range)
                    (window-buffer start-window))
***************
*** 877,882 ****
--- 913,938 ----
                         (or end-point
                             (= (window-start start-window)
                                start-window-start)))
+               (if (and on-link
+                        (not end-point)
+                        (consp event)
+                        (or remap-double-click
+                            (and
+                             (not (eq mouse-1-click-follows-link 'double))
+                             (= click-count 0)
+                             (= (event-click-count event) 1)
+                             (not (input-pending-p))
+                             (or (not (integerp mouse-1-click-follows-link))
+                                 (let ((t0 (posn-timestamp (event-start 
start-event)))
+                                       (t1 (posn-timestamp (event-end event))))
+                                   (and (integerp t0) (integerp t1)
+                                        (if (> mouse-1-click-follows-link 0)
+                                            (<= (- t1 t0) 
mouse-1-click-follows-link)
+                                          (< (- t0 t1) 
mouse-1-click-follows-link)))))
+                             (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]