Function: pixel-scroll-precision-scroll-down-page
pixel-scroll-precision-scroll-down-page is an autoloaded and
byte-compiled function defined in pixel-scroll.el.gz.
Signature
(pixel-scroll-precision-scroll-down-page DELTA)
Documentation
Scroll the current window down by DELTA pixels.
Note that this function doesn't work if DELTA is larger than or equal to the text height of the current window in pixels.
Source Code
;; Defined in /usr/src/emacs/lisp/pixel-scroll.el.gz
;;;###autoload
(defun pixel-scroll-precision-scroll-down-page (delta)
"Scroll the current window down by DELTA pixels.
Note that this function doesn't work if DELTA is larger than or
equal to the text height of the current window in pixels."
(let* ((desired-pos (posn-at-x-y 0 (+ delta
(window-tab-line-height)
(window-header-line-height))))
(desired-start (posn-point desired-pos))
(current-vs (window-vscroll nil t))
(start-posn (unless (eq desired-start (window-start))
(posn-at-point desired-start)))
(desired-vscroll (if start-posn
(- delta (cdr (posn-x-y start-posn)))
(+ current-vs delta)))
(scroll-preserve-screen-position nil)
(auto-window-vscroll nil)
(new-start-position (if (zerop (window-hscroll))
desired-start
(save-excursion
(goto-char desired-start)
(beginning-of-visual-line)
(point)))))
(set-window-start nil new-start-position
(not (zerop desired-vscroll)))
(set-window-vscroll nil desired-vscroll t t)
;; Constrain point to a location that will not result in
;; recentering, if it is no longer completely visible.
(unless (pos-visible-in-window-p (point))
;; If desired-vscroll is 0, target the window start itself. But
;; in any other case, target the line immediately below the
;; window start, unless that line is itself invisible. This
;; improves the appearance of the window by maintaining the
;; cursor row in a fully visible state.
(if (zerop desired-vscroll)
(goto-char new-start-position)
(let ((line-after (save-excursion
(goto-char new-start-position)
(if (zerop (vertical-motion 1))
(progn
(set-window-vscroll nil 0 t t)
nil) ; nil means move to new-start-position.
(point)))))
(if (not line-after)
(progn
(goto-char new-start-position)
(signal 'end-of-buffer nil))
(if (pos-visible-in-window-p line-after nil t)
(goto-char line-after)
(goto-char new-start-position))))))))