comparison lisp/mouse.el @ 60253:6452fdddef8f

(mouse-1-click-in-non-selected-windows): New defcustom. (mouse-on-link-p, mouse-drag-region-1): Use it.
author Kim F. Storm <storm@cua.dk>
date Fri, 25 Feb 2005 23:30:59 +0000
parents 074d6632232c
children 2bc2e06d78aa e4694597cbf4
comparison
equal deleted inserted replaced
60252:825c64cf8e7c 60253:6452fdddef8f
79 :type '(choice (const :tag "Disabled" nil) 79 :type '(choice (const :tag "Disabled" nil)
80 (const :tag "Double click" double) 80 (const :tag "Double click" double)
81 (number :tag "Single click time limit" :value 350) 81 (number :tag "Single click time limit" :value 350)
82 (other :tag "Single click" t)) 82 (other :tag "Single click" t))
83 :group 'mouse) 83 :group 'mouse)
84
85 (defcustom mouse-1-click-in-non-selected-windows t
86 "*If non-nil, a Mouse-1 click also follows links in non-selected windows.
87
88 If nil, a Mouse-1 click on a link in a non-selected window performs
89 the normal mouse-1 binding, typically selects the window and sets
90 point at the click position."
91 :type 'boolean
92 :version "22.1"
93 :group 'mouse)
94
84 95
85 96
86 ;; Provide a mode-specific menu on a mouse button. 97 ;; Provide a mode-specific menu on a mouse button.
87 98
88 (defun popup-menu (menu &optional position prefix) 99 (defun popup-menu (menu &optional position prefix)
769 780
770 (defun mouse-on-link-p (pos) 781 (defun mouse-on-link-p (pos)
771 "Return non-nil if POS is on a link in the current buffer. 782 "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 783 POS must be a buffer position in the current buffer or an mouse
773 event location in the selected window, see `event-start'. 784 event location in the selected window, see `event-start'.
785 However, if `mouse-1-click-in-non-selected-windows' is non-nil,
786 POS may be a mouse event location in any window.
774 787
775 A clickable link is identified by one of the following methods: 788 A clickable link is identified by one of the following methods:
776 789
777 - If the character at POS has a non-nil `follow-link' text or 790 - If the character at POS has a non-nil `follow-link' text or
778 overlay property, use the value of that property determines what 791 overlay property, use the value of that property determines what
803 first element of that vector, i.e. the action of the mouse-1 816 first element of that vector, i.e. the action of the mouse-1
804 click is the local or global binding of that event. 817 click is the local or global binding of that event.
805 818
806 - Otherwise, the mouse-1 event is translated into a mouse-2 event 819 - Otherwise, the mouse-1 event is translated into a mouse-2 event
807 at the same position." 820 at the same position."
808 (if (consp pos) 821 (let ((w (and (consp pos) (posn-window pos))))
809 (setq pos (and (eq (selected-window) (posn-window pos)) 822 (if (consp pos)
810 (posn-point pos)))) 823 (setq pos (and (or mouse-1-click-in-non-selected-windows
811 (when pos 824 (eq (selected-window) w))
812 (let ((action 825 (posn-point pos))))
813 (or (get-char-property pos 'follow-link) 826 (when pos
814 (save-excursion 827 (with-current-buffer (window-buffer w)
815 (goto-char pos) 828 (let ((action
816 (key-binding [follow-link] nil t))))) 829 (or (get-char-property pos 'follow-link)
817 (cond 830 (save-excursion
818 ((eq action 'mouse-face) 831 (goto-char pos)
819 (and (get-char-property pos 'mouse-face) t)) 832 (key-binding [follow-link] nil t)))))
820 ((functionp action) 833 (cond
821 (funcall action pos)) 834 ((eq action 'mouse-face)
822 (t action))))) 835 (and (get-char-property pos 'mouse-face) t))
836 ((functionp action)
837 (funcall action pos))
838 (t action)))))))
823 839
824 840
825 (defun mouse-drag-region-1 (start-event) 841 (defun mouse-drag-region-1 (start-event)
826 (mouse-minibuffer-check start-event) 842 (mouse-minibuffer-check start-event)
827 (let* ((echo-keystrokes 0) 843 (let* ((echo-keystrokes 0)
837 (bottom (if (window-minibuffer-p start-window) 853 (bottom (if (window-minibuffer-p start-window)
838 (nth 3 bounds) 854 (nth 3 bounds)
839 ;; Don't count the mode line. 855 ;; Don't count the mode line.
840 (1- (nth 3 bounds)))) 856 (1- (nth 3 bounds))))
841 (on-link (and mouse-1-click-follows-link 857 (on-link (and mouse-1-click-follows-link
842 (eq start-window (selected-window)))) 858 (or mouse-1-click-in-non-selected-windows
859 (eq start-window (selected-window)))))
843 remap-double-click 860 remap-double-click
844 (click-count (1- (event-click-count start-event)))) 861 (click-count (1- (event-click-count start-event))))
845 (setq mouse-selection-click-count click-count) 862 (setq mouse-selection-click-count click-count)
846 (setq mouse-selection-click-count-buffer (current-buffer)) 863 (setq mouse-selection-click-count-buffer (current-buffer))
847 (mouse-set-point start-event) 864 (mouse-set-point start-event)