Function: mouse-scroll-subr

mouse-scroll-subr is a byte-compiled function defined in mouse.el.gz.

Signature

(mouse-scroll-subr WINDOW JUMP &optional OVERLAY START ADJUST)

Documentation

Scroll the window WINDOW, JUMP lines at a time, until new input arrives.

If OVERLAY is an overlay, let it stretch from START to the far edge of the newly visible text. ADJUST, if non-nil, is a function, without arguments, to call after setting point. Upon exit, point is at the far edge of the newly visible text.

Source Code

;; Defined in /usr/src/emacs/lisp/mouse.el.gz
(defun mouse-scroll-subr (window jump &optional overlay start adjust)
  "Scroll the window WINDOW, JUMP lines at a time, until new input arrives.
If OVERLAY is an overlay, let it stretch from START to the far edge of
the newly visible text.
ADJUST, if non-nil, is a function, without arguments, to call after
setting point.
Upon exit, point is at the far edge of the newly visible text."
  (cond
   ((and (> jump 0) (< jump mouse-scroll-min-lines))
    (setq jump mouse-scroll-min-lines))
   ((and (< jump 0) (< (- jump) mouse-scroll-min-lines))
    (setq jump (- mouse-scroll-min-lines))))
  (let ((opoint (point)))
    (while (progn
	     (goto-char (window-start window))
	     (if (not (zerop (vertical-motion jump window)))
		 (progn
		   (set-window-start window (point))
		   (if (natnump jump)
		       (if (window-end window)
			   (progn
			     (goto-char (window-end window))
			     ;; window-end doesn't reflect the window's new
			     ;; start position until the next redisplay.
			     (vertical-motion (1- jump) window))
			 (vertical-motion (- (window-height window) 2)))
		     (goto-char (window-start window)))
		   (if overlay
		       (move-overlay overlay start (point)))
		   ;; Now that we have scrolled WINDOW properly,
		   ;; put point back where it was for the redisplay
		   ;; so that we don't mess up the selected window.
		   (or (eq window (selected-window))
		       (goto-char opoint))
                   (when adjust
                     (funcall adjust))
		   (sit-for mouse-scroll-delay)))))
    (or (eq window (selected-window))
	(goto-char opoint))))