Function: follow-get-scrolled-point

follow-get-scrolled-point is a byte-compiled function defined in follow.el.gz.

Signature

(follow-get-scrolled-point DEST WINDOWS)

Documentation

Calculate the correct value for point after a scrolling operation.

DEST is our default position, typically where point was before the scroll. If scroll-preserve-screen-position is non-nil and active, DEST will be in the same screen position as before the scroll. WINDOWS is the list of windows in the follow chain.

This function attempts to duplicate the point placing from window_scroll_line_based in the Emacs core source window.c.

Return the new position.

Source Code

;; Defined in /usr/src/emacs/lisp/follow.el.gz
;;; User functions

;;; Scroll

(defun follow-get-scrolled-point (dest windows)
  "Calculate the correct value for point after a scrolling operation.

DEST is our default position, typically where point was before the scroll.
If `scroll-preserve-screen-position' is non-nil and active, DEST will be
in the same screen position as before the scroll.  WINDOWS is the list of
windows in the follow chain.

This function attempts to duplicate the point placing from
`window_scroll_line_based' in the Emacs core source window.c.

Return the new position."
  (if (and scroll-preserve-screen-position
	   (get this-command 'scroll-command))
      dest
    (let ((dest-column
	   (save-excursion
	     (goto-char dest)
	     (- (current-column)
		(progn (vertical-motion 0) (current-column)))))
	  (limit0
	   (with-selected-window (car windows)
	     (save-excursion
	       (goto-char (window-start))
	       (vertical-motion 0)
	       (point))))
	  (limitn
	   (with-selected-window (car (reverse windows))
	     (save-excursion
	       (goto-char (window-end nil t))
	       (if (pos-visible-in-window-p)
		   (point)		; i.e. (point-max)
		 (1- (point)))))))
      (cond
       ((< dest limit0)
	(with-selected-window (car windows)
	  (save-excursion
	    (goto-char limit0)
	    (vertical-motion (cons dest-column 0))
	    (point))))
       ((> dest limitn)
	(with-selected-window (car (reverse windows))
	  (save-excursion
	    (goto-char limitn)
	    (vertical-motion (cons dest-column 0))
	    (point))))
       (t dest)))))