(defcustom mouse-drag-copy-region t
"*If non-nil, mouse drag copies region to kill-ring."
:type 'boolean
- :version "21.4"
+ :version "22.1"
:group 'mouse)
(defcustom mouse-1-click-follows-link 350
This feature only works in modes that specifically identify
clickable text as links, so it may not work with some external
packages. See `mouse-on-link-p' for details."
- :version "21.4"
+ :version "22.1"
:type '(choice (const :tag "Disabled" nil)
(const :tag "Double click" double)
(number :tag "Single click time limit" :value 350)
(other :tag "Single click" t))
:group 'mouse)
+(defcustom mouse-1-click-in-non-selected-windows t
+ "*If non-nil, a Mouse-1 click also follows links in non-selected windows.
+
+If nil, a Mouse-1 click on a link in a non-selected window performs
+the normal mouse-1 binding, typically selects the window and sets
+point at the click position."
+ :type 'boolean
+ :version "22.1"
+ :group 'mouse)
+
+
\f
;; Provide a mode-specific menu on a mouse button.
(if (and (window-minibuffer-p w)
(not (minibuffer-window-active-p w)))
(save-excursion
+ ;; Swallow the up-event.
(read-event)
(set-buffer "*Messages*")
(goto-char (point-max))
(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 an mouse
+event location in the selected window, see `event-start'.
+However, if `mouse-1-click-in-non-selected-windows' is non-nil,
+POS may be a mouse event location in any window.
A clickable link is identified by one of the following methods:
-1) If the character at POS has a non-nil `follow-link' text or
-overlay property, the value of that property is returned.
+- If the character at POS has a non-nil `follow-link' text or
+overlay property, use the value of that property determines what
+to do.
+
+- If there is a local key-binding or a keybinding at position POS
+for the `follow-link' event, the binding of that event determines
+what to do.
-2) If there is a local key-binding or a keybinding at position
-POS for the `follow-link' event, the binding of that event
-determines whether POS is inside a link:
+The resulting value determine whether POS is inside a link:
-- If the binding is `mouse-face', POS is inside a link if there
+- If the value is `mouse-face', POS is inside a link if there
is a non-nil `mouse-face' property at POS. Return t in this case.
-- If the binding is a function, FUNC, POS is inside a link if
+- If the value is a function, FUNC, POS is inside a link if
the call \(FUNC POS) returns non-nil. Return the return value
-from that call.
+from that call. Arg is \(posn-point POS) if POS is a mouse event,
-- Otherwise, return the binding of the `follow-link' binding.
+- Otherwise, return the value itself.
The return value is interpreted as follows:
- Otherwise, the mouse-1 event is translated into a mouse-2 event
at the same position."
- (or (get-char-property pos 'follow-link)
- (save-excursion
- (goto-char pos)
- (let ((b (key-binding [follow-link] nil t)))
+ (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 b 'mouse-face)
+ ((eq action 'mouse-face)
(and (get-char-property pos 'mouse-face) t))
- ((functionp b)
- (funcall b pos))
- (t b))))))
+ ((functionp action)
+ (funcall action pos))
+ (t action)))))))
+
(defun mouse-drag-region-1 (start-event)
(mouse-minibuffer-check start-event)
(nth 3 bounds)
;; Don't count the mode line.
(1- (nth 3 bounds))))
- on-link remap-double-click
+ (on-link (and mouse-1-click-follows-link
+ (or mouse-1-click-in-non-selected-windows
+ (eq start-window (selected-window)))))
+ remap-double-click
(click-count (1- (event-click-count start-event))))
(setq mouse-selection-click-count click-count)
(setq mouse-selection-click-count-buffer (current-buffer))
(if (< (point) start-point)
(goto-char start-point))
(setq start-point (point))
- (setq on-link (and mouse-1-click-follows-link
+ (setq on-link (and on-link
(mouse-on-link-p start-point)))
(setq remap-double-click (and on-link
(eq mouse-1-click-follows-link 'double)