comparison lisp/mouse.el @ 72890:5ba1cd1da822

* mouse-sel.el (mouse-sel-follow-link-p): Use event position instead of buffer position for `mouse-on-link-p'. * mouse.el (mouse-posn-property): New function looking up the properties at a click position in overlays and text properties in either buffer or strings. (mouse-on-link-p): Use `mouse-posn-property' to streamline lookup of both `follow-link' as well as `mouse-face' properties. (mouse-drag-track): Check `mouse-on-link-p' on event position, not buffer position. * help.el (describe-key-briefly): When reading a down-event on mode lines or scroll bar, swallow the following up event, too. Use the new mouse sensitity of `key-binding' for lookup. (describe-key): The same here.
author David Kastrup <dak@gnu.org>
date Fri, 15 Sep 2006 08:53:18 +0000
parents 3fc22ce89bd1
children c983ed5a8049
comparison
equal deleted inserted replaced
72889:25c755416160 72890:5ba1cd1da822
773 ;; Give temporary modes such as isearch a chance to turn off. 773 ;; Give temporary modes such as isearch a chance to turn off.
774 (run-hooks 'mouse-leave-buffer-hook) 774 (run-hooks 'mouse-leave-buffer-hook)
775 (mouse-drag-track start-event t)))) 775 (mouse-drag-track start-event t))))
776 776
777 777
778 (defun mouse-posn-property (pos property)
779 "Look for a property at click position."
780 (if (consp pos)
781 (let ((w (posn-window pos)) (pt (posn-point pos))
782 (str (posn-string pos)))
783 (or (and str
784 (get-text-property (cdr str) property (car str)))
785 (and pt
786 (get-char-property pt property w))))
787 (get-char-property pos property)))
788
778 (defun mouse-on-link-p (pos) 789 (defun mouse-on-link-p (pos)
779 "Return non-nil if POS is on a link in the current buffer. 790 "Return non-nil if POS is on a link in the current buffer.
780 POS must be a buffer position in the current buffer or a mouse 791 POS must be a buffer position in the current buffer or a mouse
781 event location in the selected window (see `event-start'). 792 event location in the selected window (see `event-start').
782 However, if `mouse-1-click-in-non-selected-windows' is non-nil, 793 However, if `mouse-1-click-in-non-selected-windows' is non-nil,
812 first element of that vector, i.e. the action of the mouse-1 823 first element of that vector, i.e. the action of the mouse-1
813 click is the local or global binding of that event. 824 click is the local or global binding of that event.
814 825
815 - Otherwise, the mouse-1 event is translated into a mouse-2 event 826 - Otherwise, the mouse-1 event is translated into a mouse-2 event
816 at the same position." 827 at the same position."
817 (let ((w (and (consp pos) (posn-window pos)))) 828 (let ((action
818 (if (consp pos) 829 (and (or (not (consp pos))
819 (setq pos (and (or mouse-1-click-in-non-selected-windows 830 mouse-1-click-in-non-selected-windows
820 (eq (selected-window) w)) 831 (eq (selected-window) (posn-window pos)))
821 (posn-point pos)))) 832 (or (mouse-posn-property pos 'follow-link)
822 (when pos 833 (key-binding [follow-link] nil t pos)))))
823 (with-current-buffer (window-buffer w) 834 (cond
824 (let ((action 835 ((eq action 'mouse-face)
825 (or (get-char-property pos 'follow-link) 836 (and (mouse-posn-property pos 'mouse-face) t))
826 (save-excursion 837 ((functionp action)
827 (goto-char pos) 838 (funcall action pos))
828 (key-binding [follow-link] nil t))))) 839 (t action))))
829 (cond
830 ((eq action 'mouse-face)
831 (and (get-char-property pos 'mouse-face) t))
832 ((functionp action)
833 (funcall action pos))
834 (t action)))))))
835 840
836 (defun mouse-fixup-help-message (msg) 841 (defun mouse-fixup-help-message (msg)
837 "Fix help message MSG for `mouse-1-click-follows-link'." 842 "Fix help message MSG for `mouse-1-click-follows-link'."
838 (let (mp pos) 843 (let (mp pos)
839 (if (and mouse-1-click-follows-link 844 (if (and mouse-1-click-follows-link
902 (or mouse-1-click-in-non-selected-windows 907 (or mouse-1-click-in-non-selected-windows
903 (eq start-window original-window)) 908 (eq start-window original-window))
904 ;; Use start-point before the intangibility 909 ;; Use start-point before the intangibility
905 ;; treatment, in case we click on a link inside an 910 ;; treatment, in case we click on a link inside an
906 ;; intangible text. 911 ;; intangible text.
907 (mouse-on-link-p start-point))) 912 (mouse-on-link-p start-posn)))
908 (click-count (1- (event-click-count start-event))) 913 (click-count (1- (event-click-count start-event)))
909 (remap-double-click (and on-link 914 (remap-double-click (and on-link
910 (eq mouse-1-click-follows-link 'double) 915 (eq mouse-1-click-follows-link 'double)
911 (= click-count 1)))) 916 (= click-count 1))))
912 (setq mouse-selection-click-count click-count) 917 (setq mouse-selection-click-count click-count)