Function: dnd-handle-movement
dnd-handle-movement is a byte-compiled function defined in dnd.el.gz.
Signature
(dnd-handle-movement POSN)
Documentation
Handle mouse movement to POSN when receiving a drop from another program.
Source Code
;; Defined in /usr/src/emacs/lisp/dnd.el.gz
;; Functions
(defun dnd-handle-movement (posn)
"Handle mouse movement to POSN when receiving a drop from another program."
(when (windowp (posn-window posn))
(with-selected-window (posn-window posn)
(when (and dnd-scroll-margin
;; TODO: handle scroll bars reasonably.
(not (posn-area posn)))
(ignore-errors
(let* ((row (cdr (posn-col-row posn)))
(window (when (windowp (posn-window posn))
(posn-window posn)))
(text-height (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) dnd-scroll-margin)))
;; At 2 lines, the window becomes too small for any
;; meaningful scrolling.
(unless (<= text-height 2)
(cond
;; Inside the bottom scroll margin, scroll up.
((> row (- text-height margin))
(with-selected-window window
(scroll-up 1)))
;; Inside the top scroll margin, scroll down.
((< row margin)
(with-selected-window window
(scroll-down 1))))))))
(when dnd-indicate-insertion-point
(let ((pos (posn-point posn)))
;; We avoid errors here, since on some systems this runs
;; when waiting_for_input is non-zero, and that aborts on
;; error.
(if (and pos (<= (point-min) pos (point-max)))
(goto-char pos)
pos))))))