[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master ff9ec6b 1/2: Make posn-set-point work on frame events
From: |
Lars Ingebrigtsen |
Subject: |
master ff9ec6b 1/2: Make posn-set-point work on frame events |
Date: |
Sat, 10 Oct 2020 22:05:51 -0400 (EDT) |
branch: master
commit ff9ec6b139768e5385d7632465445cbcbe628092
Author: Robert Weiner <rsw@gnu.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Make posn-set-point work on frame events
* lisp/subr.el (event-start): Mention the frame part of the events.
(posn-window): Ditto.
(posn-set-point): Make this work if the event is a frame event
(bug#28621).
---
lisp/subr.el | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/lisp/subr.el b/lisp/subr.el
index 777ef10..07cab59 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -1367,7 +1367,8 @@ EVENT is nil, the value of `posn-at-point' is used
instead.
The following accessor functions are used to access the elements
of the position:
-`posn-window': The window the event is in.
+`posn-window': The window of the event end, or its frame if the
+event end point belongs to no window.
`posn-area': A symbol identifying the area the event occurred in,
or nil if the event occurred in the text area.
`posn-point': The buffer position of the event.
@@ -1423,8 +1424,9 @@ than a window, return nil."
(defsubst posn-window (position)
"Return the window in POSITION.
-POSITION should be a list of the form returned by the `event-start'
-and `event-end' functions."
+If POSITION is outside the frame where the event was initiated,
+return that frame instead. POSITION should be a list of the form
+returned by the `event-start' and `event-end' functions."
(nth 0 position))
(defsubst posn-area (position)
@@ -1451,9 +1453,14 @@ a click on a scroll bar)."
(defun posn-set-point (position)
"Move point to POSITION.
Select the corresponding window as well."
- (if (not (windowp (posn-window position)))
+ (if (framep (posn-window position))
+ (progn
+ (unless (windowp (frame-selected-window (posn-window position)))
+ (error "Position not in text area of window"))
+ (select-window (frame-selected-window (posn-window position))))
+ (unless (windowp (posn-window position))
(error "Position not in text area of window"))
- (select-window (posn-window position))
+ (select-window (posn-window position)))
(if (numberp (posn-point position))
(goto-char (posn-point position))))