emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 7899e8daff: Fix error on mouse move over something not a window w


From: Po Lu
Subject: master 7899e8daff: Fix error on mouse move over something not a window while dragging text
Date: Sat, 2 Apr 2022 04:00:32 -0400 (EDT)

branch: master
commit 7899e8daff6730ae0b4521cbedf6141dd2f1531e
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    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.
---
 lisp/mouse.el | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/lisp/mouse.el b/lisp/mouse.el
index 3f43b39079..92e289b4ce 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))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]