Mercurial > emacs
comparison lisp/mouse.el @ 60204:074d6632232c
(mouse-on-link-p): If arg POS is a mouse event,
check that window of that event is the selected window.
(mouse-drag-region-1): Compare mouse event window to selected
window before setting point.
author | Kim F. Storm <storm@cua.dk> |
---|---|
date | Tue, 22 Feb 2005 09:42:06 +0000 |
parents | aac0a33f5772 |
children | 6452fdddef8f bf0d492ea2d5 |
comparison
equal
deleted
inserted
replaced
60203:ba4a03ed6f89 | 60204:074d6632232c |
---|---|
767 (mouse-drag-region-1 start-event)))) | 767 (mouse-drag-region-1 start-event)))) |
768 | 768 |
769 | 769 |
770 (defun mouse-on-link-p (pos) | 770 (defun mouse-on-link-p (pos) |
771 "Return non-nil if POS is on a link in the current buffer. | 771 "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'. | |
772 | 774 |
773 A clickable link is identified by one of the following methods: | 775 A clickable link is identified by one of the following methods: |
774 | 776 |
775 - If the character at POS has a non-nil `follow-link' text or | 777 - If the character at POS has a non-nil `follow-link' text or |
776 overlay property, use the value of that property determines what | 778 overlay property, use the value of that property determines what |
785 - If the value is `mouse-face', POS is inside a link if there | 787 - If the value is `mouse-face', POS is inside a link if there |
786 is a non-nil `mouse-face' property at POS. Return t in this case. | 788 is a non-nil `mouse-face' property at POS. Return t in this case. |
787 | 789 |
788 - If the value is a function, FUNC, POS is inside a link if | 790 - If the value is a function, FUNC, POS is inside a link if |
789 the call \(FUNC POS) returns non-nil. Return the return value | 791 the call \(FUNC POS) returns non-nil. Return the return value |
790 from that call. | 792 from that call. Arg is \(posn-point POS) if POS is a mouse event, |
791 | 793 |
792 - Otherwise, return the value itself. | 794 - Otherwise, return the value itself. |
793 | 795 |
794 The return value is interpreted as follows: | 796 The return value is interpreted as follows: |
795 | 797 |
801 first element of that vector, i.e. the action of the mouse-1 | 803 first element of that vector, i.e. the action of the mouse-1 |
802 click is the local or global binding of that event. | 804 click is the local or global binding of that event. |
803 | 805 |
804 - Otherwise, the mouse-1 event is translated into a mouse-2 event | 806 - Otherwise, the mouse-1 event is translated into a mouse-2 event |
805 at the same position." | 807 at the same position." |
806 (let ((action | 808 (if (consp pos) |
807 (or (get-char-property pos 'follow-link) | 809 (setq pos (and (eq (selected-window) (posn-window pos)) |
808 (save-excursion | 810 (posn-point pos)))) |
809 (goto-char pos) | 811 (when pos |
810 (key-binding [follow-link] nil t))))) | 812 (let ((action |
811 (cond | 813 (or (get-char-property pos 'follow-link) |
812 ((eq action 'mouse-face) | 814 (save-excursion |
813 (and (get-char-property pos 'mouse-face) t)) | 815 (goto-char pos) |
814 ((functionp action) | 816 (key-binding [follow-link] nil t))))) |
815 (funcall action pos)) | 817 (cond |
816 (t action)))) | 818 ((eq action 'mouse-face) |
819 (and (get-char-property pos 'mouse-face) t)) | |
820 ((functionp action) | |
821 (funcall action pos)) | |
822 (t action))))) | |
823 | |
817 | 824 |
818 (defun mouse-drag-region-1 (start-event) | 825 (defun mouse-drag-region-1 (start-event) |
819 (mouse-minibuffer-check start-event) | 826 (mouse-minibuffer-check start-event) |
820 (let* ((echo-keystrokes 0) | 827 (let* ((echo-keystrokes 0) |
821 (start-posn (event-start start-event)) | 828 (start-posn (event-start start-event)) |
829 (top (nth 1 bounds)) | 836 (top (nth 1 bounds)) |
830 (bottom (if (window-minibuffer-p start-window) | 837 (bottom (if (window-minibuffer-p start-window) |
831 (nth 3 bounds) | 838 (nth 3 bounds) |
832 ;; Don't count the mode line. | 839 ;; Don't count the mode line. |
833 (1- (nth 3 bounds)))) | 840 (1- (nth 3 bounds)))) |
834 on-link remap-double-click | 841 (on-link (and mouse-1-click-follows-link |
842 (eq start-window (selected-window)))) | |
843 remap-double-click | |
835 (click-count (1- (event-click-count start-event)))) | 844 (click-count (1- (event-click-count start-event)))) |
836 (setq mouse-selection-click-count click-count) | 845 (setq mouse-selection-click-count click-count) |
837 (setq mouse-selection-click-count-buffer (current-buffer)) | 846 (setq mouse-selection-click-count-buffer (current-buffer)) |
838 (mouse-set-point start-event) | 847 (mouse-set-point start-event) |
839 ;; In case the down click is in the middle of some intangible text, | 848 ;; In case the down click is in the middle of some intangible text, |
840 ;; use the end of that text, and put it in START-POINT. | 849 ;; use the end of that text, and put it in START-POINT. |
841 (if (< (point) start-point) | 850 (if (< (point) start-point) |
842 (goto-char start-point)) | 851 (goto-char start-point)) |
843 (setq start-point (point)) | 852 (setq start-point (point)) |
844 (setq on-link (and mouse-1-click-follows-link | 853 (setq on-link (and on-link |
845 (mouse-on-link-p start-point))) | 854 (mouse-on-link-p start-point))) |
846 (setq remap-double-click (and on-link | 855 (setq remap-double-click (and on-link |
847 (eq mouse-1-click-follows-link 'double) | 856 (eq mouse-1-click-follows-link 'double) |
848 (= click-count 1))) | 857 (= click-count 1))) |
849 (if remap-double-click ;; Don't expand mouse overlay in links | 858 (if remap-double-click ;; Don't expand mouse overlay in links |