Function: pixel-scroll-precision-scroll-up-page

pixel-scroll-precision-scroll-up-page is an autoloaded and byte-compiled function defined in pixel-scroll.el.gz.

Signature

(pixel-scroll-precision-scroll-up-page DELTA)

Documentation

Scroll the current window up 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
;;;###autoload
(defun pixel-scroll-precision-scroll-up-page (delta)
  "Scroll the current window up by DELTA pixels.
Note that this function doesn't work if DELTA is larger than
the height of the current window."
  (let* ((edges (window-edges nil t nil t))
         (max-y (- (nth 3 edges)
                   (nth 1 edges)))
         (posn (posn-at-x-y 0 (+ (window-tab-line-height)
                                 (window-header-line-height)
                                 (- max-y delta))))
         (point (posn-point posn)))
    (let ((current-vscroll (window-vscroll nil t))
          (wanted-pos (window-start)))
      (setq delta (- delta current-vscroll))
      (set-window-vscroll nil 0 t t)
      (when (> delta 0)
        (let* ((start (window-start))
               (dims (window-text-pixel-size nil (cons start (- delta))
                                             start nil nil nil t))
               (height (nth 1 dims))
               (position (nth 2 dims)))
          (setq wanted-pos position)
          (when (or (not position) (eq position start))
            (signal 'beginning-of-buffer nil))
          (setq delta (- delta height))))
      (set-window-start nil wanted-pos
                        (not (zerop delta)))
      (when (< delta 0)
        (set-window-vscroll nil (- delta) t t))
      ;; vscroll and the window start are now set.  Move point to a
      ;; position where redisplay will not recenter, if it is now
      ;; outside the window.
      (unless (pos-visible-in-window-p (point))
        (let ((up-pos (save-excursion
                        (goto-char point)
                        (vertical-motion -1)
                        (point))))
          (if (pos-visible-in-window-p up-pos nil t)
              (goto-char up-pos)
            (goto-char (window-start))))))))