From 9a1ff1644d34aba9de29c0afa9cdf6f798226efc Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Wed, 20 Mar 2013 14:13:00 -0400 Subject: [PATCH] * lisp/subr.el (posn-point, posn-string): Fix it here instead. * lisp/mouse.el (mouse-on-link-p): Undo scroll-bar fix. Fixes: debbugs:13979 --- lisp/ChangeLog | 12 ++++++++---- lisp/mouse.el | 3 +-- lisp/subr.el | 19 ++++++++++++------- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 392cc9ac2fa..908d10494ff 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2013-03-20 Stefan Monnier + + * subr.el (posn-point, posn-string): Fix it here instead (bug#13979). + * mouse.el (mouse-on-link-p): Undo scroll-bar fix. + 2013-03-20 Paul Eggert Suppress unnecessary non-ASCII chatter during build process. @@ -15,8 +20,8 @@ * whitespace.el (whitespace-font-lock, whitespace-font-lock-mode): Remove vars. - (whitespace-color-on, whitespace-color-off): Use - `font-lock-fontify-buffer' (Bug#13817). + (whitespace-color-on, whitespace-color-off): + Use `font-lock-fontify-buffer' (Bug#13817). 2013-03-19 Stefan Monnier @@ -76,8 +81,7 @@ buffer's first char. Use `with-selected-window' instead of `save-window-excursion' with `select-window'. (doc-view-document->bitmap): Check the current doc-view overlay's - display property instead the char property of the buffer's first - char. + display property instead the char property of the buffer's first char. 2013-03-18 Paul Eggert diff --git a/lisp/mouse.el b/lisp/mouse.el index 333a1cef703..0367cad87b8 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -759,8 +759,7 @@ 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 ((action - (and (not (memq 'vertical-scroll-bar pos)) - (or (not (consp pos)) + (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) diff --git a/lisp/subr.el b/lisp/subr.el index 9a7b94208fe..4eb46ec2b01 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1044,14 +1044,17 @@ and `event-end' functions." (nth 1 position)))) (and (symbolp area) area))) -(defsubst posn-point (position) +(defun posn-point (position) "Return the buffer location in POSITION. POSITION should be a list of the form returned by the `event-start' -and `event-end' functions." +and `event-end' functions. +Returns nil if POSITION does not correspond to any buffer location (e.g. +a click on a scroll bar)." (or (nth 5 position) - (if (consp (nth 1 position)) - (car (nth 1 position)) - (nth 1 position)))) + (let ((pt (nth 1 position))) + (or (car-safe pt) + ;; Apparently this can also be `vertical-scroll-bar' (bug#13979). + (if (integerp pt) pt))))) (defun posn-set-point (position) "Move point to POSITION. @@ -1124,12 +1127,14 @@ POSITION should be a list of the form returned by the `event-start' and `event-end' functions." (nth 3 position)) -(defsubst posn-string (position) +(defun posn-string (position) "Return the string object of POSITION. Value is a cons (STRING . STRING-POS), or nil if not a string. POSITION should be a list of the form returned by the `event-start' and `event-end' functions." - (nth 4 position)) + (let ((x (nth 4 position))) + ;; Apparently this can also be `handle' or `below-handle' (bug#13979). + (when (consp x) x))) (defsubst posn-image (position) "Return the image object of POSITION. -- 2.39.2