769 |
|
|
770 |
(defun mouse-on-link-p (pos) |
(defun mouse-on-link-p (pos) |
771 |
"Return non-nil if POS is on a link in the current buffer. |
"Return non-nil if POS is on a link in the current buffer. |
772 |
|
POS must be a buffer position in the current buffer or an mouse |
773 |
|
event location in the selected window, see `event-start'. |
774 |
|
|
775 |
A clickable link is identified by one of the following methods: |
A clickable link is identified by one of the following methods: |
776 |
|
|
789 |
|
|
790 |
- If the value is a function, FUNC, POS is inside a link if |
- If the value is a function, FUNC, POS is inside a link if |
791 |
the call \(FUNC POS) returns non-nil. Return the return value |
the call \(FUNC POS) returns non-nil. Return the return value |
792 |
from that call. |
from that call. Arg is \(posn-point POS) if POS is a mouse event, |
793 |
|
|
794 |
- Otherwise, return the value itself. |
- Otherwise, return the value itself. |
795 |
|
|
805 |
|
|
806 |
- Otherwise, the mouse-1 event is translated into a mouse-2 event |
- Otherwise, the mouse-1 event is translated into a mouse-2 event |
807 |
at the same position." |
at the same position." |
808 |
(let ((action |
(if (consp pos) |
809 |
(or (get-char-property pos 'follow-link) |
(setq pos (and (eq (selected-window) (posn-window pos)) |
810 |
(save-excursion |
(posn-point pos)))) |
811 |
(goto-char pos) |
(when pos |
812 |
(key-binding [follow-link] nil t))))) |
(let ((action |
813 |
(cond |
(or (get-char-property pos 'follow-link) |
814 |
((eq action 'mouse-face) |
(save-excursion |
815 |
(and (get-char-property pos 'mouse-face) t)) |
(goto-char pos) |
816 |
((functionp action) |
(key-binding [follow-link] nil t))))) |
817 |
(funcall action pos)) |
(cond |
818 |
(t action)))) |
((eq action 'mouse-face) |
819 |
|
(and (get-char-property pos 'mouse-face) t)) |
820 |
|
((functionp action) |
821 |
|
(funcall action pos)) |
822 |
|
(t action))))) |
823 |
|
|
824 |
|
|
825 |
(defun mouse-drag-region-1 (start-event) |
(defun mouse-drag-region-1 (start-event) |
826 |
(mouse-minibuffer-check start-event) |
(mouse-minibuffer-check start-event) |
838 |
(nth 3 bounds) |
(nth 3 bounds) |
839 |
;; Don't count the mode line. |
;; Don't count the mode line. |
840 |
(1- (nth 3 bounds)))) |
(1- (nth 3 bounds)))) |
841 |
on-link remap-double-click |
(on-link (and mouse-1-click-follows-link |
842 |
|
(eq start-window (selected-window)))) |
843 |
|
remap-double-click |
844 |
(click-count (1- (event-click-count start-event)))) |
(click-count (1- (event-click-count start-event)))) |
845 |
(setq mouse-selection-click-count click-count) |
(setq mouse-selection-click-count click-count) |
846 |
(setq mouse-selection-click-count-buffer (current-buffer)) |
(setq mouse-selection-click-count-buffer (current-buffer)) |
850 |
(if (< (point) start-point) |
(if (< (point) start-point) |
851 |
(goto-char start-point)) |
(goto-char start-point)) |
852 |
(setq start-point (point)) |
(setq start-point (point)) |
853 |
(setq on-link (and mouse-1-click-follows-link |
(setq on-link (and on-link |
854 |
(mouse-on-link-p start-point))) |
(mouse-on-link-p start-point))) |
855 |
(setq remap-double-click (and on-link |
(setq remap-double-click (and on-link |
856 |
(eq mouse-1-click-follows-link 'double) |
(eq mouse-1-click-follows-link 'double) |