Function: follow-select-if-visible-from-first

follow-select-if-visible-from-first is a byte-compiled function defined in follow.el.gz.

Signature

(follow-select-if-visible-from-first DEST WINDOWS)

Documentation

Try to select one of WINDOWS without repositioning the topmost window.

If one of the windows in WINDOWS contains DEST, select it, call follow-redisplay, move point to DEST, and return that window. Otherwise, return nil.

Source Code

;; Defined in /usr/src/emacs/lisp/follow.el.gz
;; Select a window that will display point if the windows would
;; be redisplayed with the first window fixed.  This is useful for
;; example when the user has pressed return at the bottom of a window
;; as point is not visible in any window.

(defun follow-select-if-visible-from-first (dest windows)
  "Try to select one of WINDOWS without repositioning the topmost window.
If one of the windows in WINDOWS contains DEST, select it, call
`follow-redisplay', move point to DEST, and return that window.
Otherwise, return nil."
  (let (win end-pos-end-p)
    (save-excursion
      (goto-char (window-start (car windows)))
      ;; Make sure the line start in the beginning of a real screen
      ;; line.
      (vertical-motion 0 (car windows))
      (when (>= dest (point))
	;; At or below the start. Check the windows.
	(save-window-excursion
	  (let ((windows windows))
	    (while (and (not win) windows)
	      (set-window-start (car windows) (point) 'noforce)
	      (setq end-pos-end-p (follow-calc-win-end (car windows)))
	      (goto-char (car end-pos-end-p))
	      ;; Visible, if dest above end, or if eob is visible
	      ;; inside the window.
	      (if (or (car (cdr end-pos-end-p))
		      (< dest (point)))
		  (setq win (car windows))
		(setq windows (cdr windows))))))))
    (when win
      (select-window win)
      (follow-redisplay windows (car windows))
      (goto-char dest))
    win))