summaryrefslogtreecommitdiff
path: root/lisp/mouse.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/mouse.el')
-rw-r--r--lisp/mouse.el57
1 files changed, 37 insertions, 20 deletions
diff --git a/lisp/mouse.el b/lisp/mouse.el
index 4e11b1d4c96..0b6cccd86c6 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -556,7 +556,7 @@ resized by dragging their header-line."
(echo-keystrokes 0)
(start-event-frame (window-frame (car (car (cdr start-event)))))
(start-event-window (car (car (cdr start-event))))
- event mouse x left right edges wconfig growth
+ event mouse x left right edges growth
(which-side
(or (cdr (assq 'vertical-scroll-bars (frame-parameters start-event-frame)))
'right)))
@@ -775,6 +775,24 @@ If the click is in the echo area, display the `*Messages*' buffer."
(mouse-drag-track start-event t))))
+(defun mouse-posn-property (pos property)
+ "Look for a property at click position.
+POS may be either a buffer position or a click position like
+those returned from `event-start'. If the click position is on
+a string, the text property PROPERTY is examined.
+If this is nil or the click is not on a string, then
+the corresponding buffer position is searched for PROPERTY.
+If PROPERTY is encountered in one of those places,
+its value is returned."
+ (if (consp pos)
+ (let ((w (posn-window pos)) (pt (posn-point pos))
+ (str (posn-string pos)))
+ (or (and str
+ (get-text-property (cdr str) property (car str)))
+ (and pt
+ (get-char-property pt property w))))
+ (get-char-property pos property)))
+
(defun mouse-on-link-p (pos)
"Return non-nil if POS is on a link in the current buffer.
POS must be a buffer position in the current buffer or a mouse
@@ -814,24 +832,23 @@ click is the local or global binding of that event.
- Otherwise, the mouse-1 event is translated into a mouse-2 event
at the same position."
- (let ((w (and (consp pos) (posn-window pos))))
- (if (consp pos)
- (setq pos (and (or mouse-1-click-in-non-selected-windows
- (eq (selected-window) w))
- (posn-point pos))))
- (when pos
- (with-current-buffer (window-buffer w)
- (let ((action
- (or (get-char-property pos 'follow-link)
- (save-excursion
- (goto-char pos)
- (key-binding [follow-link] nil t)))))
- (cond
- ((eq action 'mouse-face)
- (and (get-char-property pos 'mouse-face) t))
- ((functionp action)
- (funcall action pos))
- (t action)))))))
+ (let ((action
+ (and (or (not (consp pos))
+ mouse-1-click-in-non-selected-windows
+ (eq (selected-window) (posn-window pos)))
+ (or (mouse-posn-property pos 'follow-link)
+ (key-binding [follow-link] nil t pos)))))
+ (cond
+ ((eq action 'mouse-face)
+ (and (mouse-posn-property pos 'mouse-face) t))
+ ((functionp action)
+ ;; FIXME: This seems questionable if the click is not in a buffer.
+ ;; Should we instead decide that `action' takes a `posn'?
+ (if (consp pos)
+ (with-current-buffer (window-buffer (posn-window pos))
+ (funcall action (posn-point pos)))
+ (funcall action pos)))
+ (t action))))
(defun mouse-fixup-help-message (msg)
"Fix help message MSG for `mouse-1-click-follows-link'."
@@ -904,7 +921,7 @@ should only be used by mouse-drag-region."
;; Use start-point before the intangibility
;; treatment, in case we click on a link inside an
;; intangible text.
- (mouse-on-link-p start-point)))
+ (mouse-on-link-p start-posn)))
(click-count (1- (event-click-count start-event)))
(remap-double-click (and on-link
(eq mouse-1-click-follows-link 'double)