summaryrefslogtreecommitdiff
path: root/lisp/mouse.el
diff options
context:
space:
mode:
authorPo Lu <luangruo@yahoo.com>2022-04-02 15:59:15 +0800
committerPo Lu <luangruo@yahoo.com>2022-04-02 15:59:15 +0800
commit7899e8daff6730ae0b4521cbedf6141dd2f1531e (patch)
tree5acf0e4f2740480bfeea349bbb520bc57ee5a944 /lisp/mouse.el
parentc8a49b69abc0beb7eca4c4ccf18eefc52aaf7cee (diff)
downloademacs-7899e8daff6730ae0b4521cbedf6141dd2f1531e.tar.gz
Fix error on mouse move over something not a window while dragging text
* lisp/mouse.el (mouse-drag-and-drop-region): Handle non-window values of `posn-window' correctly.
Diffstat (limited to 'lisp/mouse.el')
-rw-r--r--lisp/mouse.el25
1 files changed, 14 insertions, 11 deletions
diff --git a/lisp/mouse.el b/lisp/mouse.el
index 3f43b39079d..92e289b4ced 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -3097,20 +3097,23 @@ is copied instead of being cut."
;; either up or down depending on which margin it is in.
(when mouse-drag-and-drop-region-scroll-margin
(let* ((row (cdr (posn-col-row (event-end event))))
- (window (posn-window (event-end event)))
- (text-height (window-text-height window))
+ (window (when (windowp (posn-window (event-end event)))
+ (posn-window (event-end event))))
+ (text-height (when window
+ (window-text-height window)))
;; Make sure it's possible to scroll both up
;; and down if the margin is too large for the
;; window.
- (margin (min (/ text-height 3)
- mouse-drag-and-drop-region-scroll-margin)))
- ;; At 2 lines, the window becomes too small for any
- ;; meaningful scrolling.
- (unless (<= text-height 2)
- ;; We could end up at the beginning or end of the
- ;; buffer.
- (ignore-errors
- (when (windowp window)
+ (margin (when text-height
+ (min (/ text-height 3)
+ mouse-drag-and-drop-region-scroll-margin))))
+ (when (windowp window)
+ ;; At 2 lines, the window becomes too small for any
+ ;; meaningful scrolling.
+ (unless (<= text-height 2)
+ ;; We could end up at the beginning or end of the
+ ;; buffer.
+ (ignore-errors
(cond
;; Inside the bottom scroll margin, scroll up.
((> row (- text-height margin))