]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix error on mouse move over something not a window while dragging text
authorPo Lu <luangruo@yahoo.com>
Sat, 2 Apr 2022 07:59:15 +0000 (15:59 +0800)
committerPo Lu <luangruo@yahoo.com>
Sat, 2 Apr 2022 07:59:15 +0000 (15:59 +0800)
* lisp/mouse.el (mouse-drag-and-drop-region): Handle non-window
values of `posn-window' correctly.

lisp/mouse.el

index 3f43b39079dbe1f01f593c2549b1b16c4f06b322..92e289b4cedc077999de0b3ac23b0517d2156444 100644 (file)
@@ -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))