Function: mouse--click-1-maybe-follows-link

mouse--click-1-maybe-follows-link is a byte-compiled function defined in mouse.el.gz.

Signature

(mouse--click-1-maybe-follows-link &optional PROMPT)

Documentation

Turn mouse-1 events into mouse-2 events if follows-link.

Expects to be bound to (double-)mouse-1 in key-translation-map.

Source Code

;; Defined in /usr/src/emacs/lisp/mouse.el.gz
(defun mouse--click-1-maybe-follows-link (&optional _prompt)
  "Turn `mouse-1' events into `mouse-2' events if follows-link.
Expects to be bound to `(double-)mouse-1' in `key-translation-map'."
  (and mouse--last-down
       (pcase mouse-1-click-follows-link
         ('nil nil)
         ('double (eq 'double-mouse-1 (car-safe last-input-event)))
         (_ (and (eq 'mouse-1 (car-safe last-input-event))
                 (or (not (numberp mouse-1-click-follows-link))
		     (funcall (if (< mouse-1-click-follows-link 0)
				  (lambda (a b) (time-less-p b a))
				#'time-less-p)
			      (time-since (cdr mouse--last-down))
                              (/ (abs mouse-1-click-follows-link) 1000.0))))))
       (eq (car mouse--last-down)
           (event-convert-list
            `(down ,@(event-modifiers last-input-event)
                   ,(event-basic-type last-input-event))))
       (let* ((action (mouse-on-link-p (event-start last-input-event))))
         (when (and action
                    (or mouse-1-click-in-non-selected-windows
                        (eq (selected-window)
                            (posn-window (event-start last-input-event)))))
           ;; Turn the mouse-1 into a mouse-2 to follow links,
           ;; but only if ‘mouse-on-link-p’ hasn’t returned a
           ;; string or vector (see its docstring).
           (if (arrayp action)
               (vector (aref action 0))
             (let ((newup (if (eq mouse-1-click-follows-link 'double)
                              'double-mouse-2 'mouse-2)))
               ;; If mouse-2 has never been done by the user, it
               ;; doesn't have the necessary property to be
               ;; interpreted correctly.
               (unless (get newup 'event-kind)
                 (put newup 'event-kind
                      (get (car last-input-event) 'event-kind)))
               ;; Modify the event in-place, otherwise we can get a prefix
               ;; added again, so a click on the header-line turns
               ;; into a [header-line header-line mouse-2] :-(.
               ;; See fake_prefixed_keys in src/keyboard.c's.
               (setf (car last-input-event) newup)
               (vector last-input-event)))))))