1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-11 08:30:45 -08:00

Fix follow-scroll-down in a small buffer which starts slightly scrolled

This fixes bug #51814.

* lisp/follow.el (follow-scroll-down): Do away with the optimization of doing
vertical-motion over only one window.  Instead move over all windows, to
checck for being close to point-min, and setting point accordingly.
This commit is contained in:
Alan Mackenzie 2021-11-13 18:33:17 +00:00
parent 480241983e
commit d4536ff257

View file

@ -669,24 +669,30 @@ Works like `scroll-down' when not in Follow mode."
(t (t
(let* ((orig-point (point)) (let* ((orig-point (point))
(windows (follow-all-followers)) (windows (follow-all-followers))
(win (car (reverse windows))) (start (window-start (car windows)))
(start (window-start (car windows)))) (lines 0))
(if (eq start (point-min)) (if (eq start (point-min))
(if (or (null scroll-error-top-bottom) (if (or (null scroll-error-top-bottom)
(bobp)) (bobp))
(signal 'beginning-of-buffer nil) (signal 'beginning-of-buffer nil)
(goto-char (point-min))) (goto-char (point-min)))
(select-window win) (select-window (car windows))
(goto-char start) (dolist (win windows)
(vertical-motion (- (- (window-height win) (setq lines
(if header-line-format 2 1) ; always mode-line (+ lines
(if tab-line-format 1 0) (- (window-height win)
next-screen-context-lines))) (if header-line-format 2 1) ; Count mode-line, too.
(set-window-start win (point)) (if tab-line-format 1 0)))))
(if (< orig-point (window-end win t)) (setq lines (- lines next-screen-context-lines))
(goto-char orig-point) (goto-char start)
(goto-char start) (let ((at-top (> (vertical-motion (- lines)) (- lines))))
(vertical-motion (- next-screen-context-lines 1))) (set-window-start (car windows) (point))
(if at-top
(goto-char orig-point)
(goto-char start)
(vertical-motion (- next-screen-context-lines 1))
(if (< orig-point (point))
(goto-char orig-point))))
(setq follow-internal-force-redisplay t)))))) (setq follow-internal-force-redisplay t))))))
(put 'follow-scroll-down 'scroll-command t) (put 'follow-scroll-down 'scroll-command t)