Function: pixel-scroll-precision-scroll-down-page

pixel-scroll-precision-scroll-down-page is a 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 the height of the current window.

Source Code

;; Defined in /usr/src/emacs/lisp/pixel-scroll.el.gz
(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
the height of the current window."
  (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)))
         (edges (window-edges nil t))
         (usable-height (- (nth 3 edges)
                           (nth 1 edges)))
         (next-pos (save-excursion
                     (goto-char desired-start)
                     (when (zerop (vertical-motion (1+ scroll-margin)))
                       (set-window-start nil desired-start)
                       (signal 'end-of-buffer nil))
                     (while (when-let ((posn (posn-at-point)))
                              (< (cdr (posn-x-y posn)) delta))
                       (when (zerop (vertical-motion 1))
                         (set-window-start nil desired-start)
                         (signal 'end-of-buffer nil)))
                     (point)))
         (scroll-preserve-screen-position nil)
         (auto-window-vscroll nil))
    (when (and (or (< (point) next-pos))
               (let ((pos-visibility (pos-visible-in-window-p next-pos nil t)))
                 (and pos-visibility
                      (or (eq (length pos-visibility) 2)
                          (when-let* ((posn (posn-at-point next-pos)))
                            (> (cdr (posn-object-width-height posn))
                               usable-height))))))
      (goto-char next-pos))
    (set-window-start nil (if (zerop (window-hscroll))
                              desired-start
                            (save-excursion
                              (goto-char desired-start)
                              (beginning-of-visual-line)
                              (point)))
                      t)
    (set-window-vscroll nil desired-vscroll t t)))