[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master c1cead89f5: (event-start/end): Fix part of bug#52092
From: |
Stefan Monnier |
Subject: |
master c1cead89f5: (event-start/end): Fix part of bug#52092 |
Date: |
Sat, 24 Sep 2022 10:38:25 -0400 (EDT) |
branch: master
commit c1cead89f5f230d9bd10da54f0e959d2570a037b
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
(event-start/end): Fix part of bug#52092
When synthesizing a posn for keyboard events, make sure the `posn-point`
i the same as `point`.
* lisp/subr.el (event--posn-at-point): New function.
(event-start, event-end): Use it.
---
lisp/subr.el | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/lisp/subr.el b/lisp/subr.el
index 59f9308f31..26fba4771b 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -1562,6 +1562,21 @@ in the current Emacs session, then this function may
return nil."
;; is this really correct? maybe remove mouse-movement?
(memq (event-basic-type object) '(mouse-1 mouse-2 mouse-3 mouse-movement)))
+(defun event--posn-at-point ()
+ ;; Use `window-point' for the case when the current buffer
+ ;; is temporarily switched to some other buffer (bug#50256)
+ (let* ((pos (window-point))
+ (posn (posn-at-point pos)))
+ (if (null posn) ;; `pos' is "out of sight".
+ (list (selected-window) pos '(0 . 0) 0)
+ ;; If `pos' is inside a chunk of text hidden by an `invisible'
+ ;; or `display' property, `posn-at-point' returns the position
+ ;; that *is* visible, whereas `event--posn-at-point' is used
+ ;; when we have a keyboard event, whose position is `point' even
+ ;; if that position is invisible.
+ (setf (nth 5 posn) pos)
+ posn)))
+
(defun event-start (event)
"Return the starting position of EVENT.
EVENT should be a mouse click, drag, or key press event. If
@@ -1588,10 +1603,7 @@ nil or (STRING . POSITION)'.
For more information, see Info node `(elisp)Click Events'."
(or (and (consp event) (nth 1 event))
- ;; Use `window-point' for the case when the current buffer
- ;; is temporarily switched to some other buffer (bug#50256)
- (posn-at-point (window-point))
- (list (selected-window) (window-point) '(0 . 0) 0)))
+ (event--posn-at-point)))
(defun event-end (event)
"Return the ending position of EVENT.
@@ -1599,10 +1611,7 @@ EVENT should be a click, drag, or key press event.
See `event-start' for a description of the value returned."
(or (and (consp event) (nth (if (consp (nth 2 event)) 2 1) event))
- ;; Use `window-point' for the case when the current buffer
- ;; is temporarily switched to some other buffer (bug#50256)
- (posn-at-point (window-point))
- (list (selected-window) (window-point) '(0 . 0) 0)))
+ (event--posn-at-point)))
(defsubst event-click-count (event)
"Return the multi-click count of EVENT, a click or drag event.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master c1cead89f5: (event-start/end): Fix part of bug#52092,
Stefan Monnier <=