Function: follow-calculate-first-window-start-from-below
follow-calculate-first-window-start-from-below is a byte-compiled
function defined in follow.el.gz.
Signature
(follow-calculate-first-window-start-from-below WINDOWS GUESS &optional WIN START)
Source Code
;; Defined in /usr/src/emacs/lisp/follow.el.gz
;; Find the starting point, start at GUESS and search upward. Return
;; a point on the same line as GUESS, or above.
(defun follow-calculate-first-window-start-from-below
(windows guess &optional win start)
(setq win (or win (selected-window)))
(setq start (or start (window-start win)))
(save-excursion
(let (done win-start res opoint)
;; Always calculate what happens when no line is displayed in the first
;; window. (The `previous' res is needed below!)
(goto-char guess)
(vertical-motion 0 (car windows))
(setq res (point))
(while (not done)
(setq opoint (point))
(if (not (= (vertical-motion -1 (car windows)) -1))
;; Hit roof!
(setq done t res (point-min))
(setq win-start (follow-calc-win-start windows (point) win))
(cond ((>= (point) opoint)
;; In some pathological cases, vertical-motion may
;; return -1 even though point has not decreased. In
;; that case, avoid looping forever.
(setq done t res (point)))
((= win-start start) ; Perfect match, use this value
(setq done t res (point)))
((< win-start start) ; Walked to far, use previous result
(setq done t))
(t ; Store result for next iteration
(setq res (point))))))
res)))