From: Po Lu Date: Sat, 2 Apr 2022 07:59:15 +0000 (+0800) Subject: Fix error on mouse move over something not a window while dragging text X-Git-Tag: emacs-29.0.90~1931^2~823 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=7899e8daff6730ae0b4521cbedf6141dd2f1531e;p=emacs.git 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. --- 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))