From unknown Sat Aug 16 23:49:06 2025 X-Loop: help-debbugs@gnu.org Subject: bug#51814: follow-scroll-down leaves point in wrong place in a corner case. Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 13 Nov 2021 17:47:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 51814 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 51814@debbugs.gnu.org, juri@linkov.net Cc: acm@muc.de X-Debbugs-Original-To: bug-gnu-emacs@gnu.org, Juri Linkov Received: via spool by submit@debbugs.gnu.org id=B.163682560314805 (code B ref -1); Sat, 13 Nov 2021 17:47:01 +0000 Received: (at submit) by debbugs.gnu.org; 13 Nov 2021 17:46:43 +0000 Received: from localhost ([127.0.0.1]:48005 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mlx6x-0003qj-7T for submit@debbugs.gnu.org; Sat, 13 Nov 2021 12:46:43 -0500 Received: from lists.gnu.org ([209.51.188.17]:36868) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mlx6s-0003qY-HC for submit@debbugs.gnu.org; Sat, 13 Nov 2021 12:46:41 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41116) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mlx6s-0000OD-9D for bug-gnu-emacs@gnu.org; Sat, 13 Nov 2021 12:46:38 -0500 Received: from colin.muc.de ([193.149.48.1]:25292 helo=mail.muc.de) by eggs.gnu.org with smtp (Exim 4.90_1) (envelope-from ) id 1mlx6p-0000o0-Rs for bug-gnu-emacs@gnu.org; Sat, 13 Nov 2021 12:46:38 -0500 Received: (qmail 10966 invoked by uid 3782); 13 Nov 2021 17:46:19 -0000 Received: from acm.muc.de (p4fe15fc7.dip0.t-ipconnect.de [79.225.95.199]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Sat, 13 Nov 2021 18:46:19 +0100 Received: (qmail 27491 invoked by uid 1000); 13 Nov 2021 17:46:18 -0000 Date: Sat, 13 Nov 2021 17:46:18 +0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Submission-Agent: TMDA/1.3.x (Ph3nix) From: Alan Mackenzie X-Primary-Address: acm@muc.de Received-SPF: pass client-ip=193.149.48.1; envelope-from=acm@muc.de; helo=mail.muc.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.6 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.6 (--) Hello, Juri and Emacs. On the emacs-28 branch and master. This bug is a corner case, noted but not fixed in bug #51590. >From a post in that bug thread: [*] There is a situation which is not new, where if the buffer is too short to fill all the windows, and it is already scrolled up far, follow-scroll-down will scroll a correct amount, but leave point in a random position. I believe the following patch fixes this. Juri, could you try it out, please. As a test buffer, (i) open elisp.info in a default GUI window (34 lines); (ii) C-x 3 ; split it with a vertical divider. (iii) ] ; Move to next page in manual, "Introduction". (iv) M-x follow-mode. (v) C-u 20 C-v ; scroll-up a significant amount. (vi) Move point to the line beginning "* Caveats". (vii) M-x follow-scroll-down. Note that point is in a random place. This is a bug. The cause of the bug is that the current code is "optimised" for the case where there are enough buffer lines above point to scroll a full follow-page, yet neglects the case where this doesn't hold. The patch does away with this optimisation. diff --git a/lisp/follow.el b/lisp/follow.el index 2ca2c1f17b..3761275bbf 100644 --- a/lisp/follow.el +++ b/lisp/follow.el @@ -669,24 +669,30 @@ follow-scroll-down (t (let* ((orig-point (point)) (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 (or (null scroll-error-top-bottom) (bobp)) (signal 'beginning-of-buffer nil) (goto-char (point-min))) - (select-window win) - (goto-char start) - (vertical-motion (- (- (window-height win) - (if header-line-format 2 1) ; always mode-line - (if tab-line-format 1 0) - next-screen-context-lines))) - (set-window-start win (point)) - (if (< orig-point (window-end win t)) - (goto-char orig-point) - (goto-char start) - (vertical-motion (- next-screen-context-lines 1))) + (select-window (car windows)) + (dolist (win windows) + (setq lines + (+ lines + (- (window-height win) + (if header-line-format 2 1) ; Count mode-line, too. + (if tab-line-format 1 0))))) + (setq lines (- lines next-screen-context-lines)) + (goto-char start) + (let ((at-top (> (vertical-motion (- lines)) (- lines)))) + (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)))))) (put 'follow-scroll-down 'scroll-command t) -- Alan Mackenzie (Nuremberg, Germany). From unknown Sat Aug 16 23:49:06 2025 X-Loop: help-debbugs@gnu.org Subject: bug#51814: follow-scroll-down leaves point in wrong place in a corner case. Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 13 Nov 2021 18:01:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51814 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Alan Mackenzie Cc: 51814@debbugs.gnu.org Received: via spool by 51814-submit@debbugs.gnu.org id=B51814.163682644016372 (code B ref 51814); Sat, 13 Nov 2021 18:01:02 +0000 Received: (at 51814) by debbugs.gnu.org; 13 Nov 2021 18:00:40 +0000 Received: from localhost ([127.0.0.1]:48023 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mlxKS-0004Fz-4q for submit@debbugs.gnu.org; Sat, 13 Nov 2021 13:00:40 -0500 Received: from relay12.mail.gandi.net ([217.70.178.232]:35083) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mlxKO-0004Fk-RG for 51814@debbugs.gnu.org; Sat, 13 Nov 2021 13:00:37 -0500 Received: (Authenticated sender: juri@linkov.net) by relay12.mail.gandi.net (Postfix) with ESMTPSA id 80F19200006; Sat, 13 Nov 2021 18:00:29 +0000 (UTC) From: Juri Linkov Organization: LINKOV.NET References: Date: Sat, 13 Nov 2021 19:58:12 +0200 In-Reply-To: (Alan Mackenzie's message of "Sat, 13 Nov 2021 17:46:18 +0000") Message-ID: <864k8gdjkb.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > I believe the following patch fixes this. Juri, could you try it out, > please. > > As a test buffer, > (i) open elisp.info in a default GUI window (34 lines); > (ii) C-x 3 ; split it with a vertical divider. > (iii) ] ; Move to next page in manual, "Introduction". > (iv) M-x follow-mode. > (v) C-u 20 C-v ; scroll-up a significant amount. > > (vi) Move point to the line beginning "* Caveats". > (vii) M-x follow-scroll-down. > > Note that point is in a random place. This is a bug. Thanks, I confirm this bug is fixed with your patch. I've tested it with and without tab-line-mode in Info with the header line. From unknown Sat Aug 16 23:49:06 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Alan Mackenzie Subject: bug#51814: closed (Re: bug#51814: follow-scroll-down leaves point in wrong place in a corner case.) Message-ID: References: X-Gnu-PR-Message: they-closed 51814 X-Gnu-PR-Package: emacs Reply-To: 51814@debbugs.gnu.org Date: Sat, 13 Nov 2021 18:43:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1636828982-20692-1" This is a multi-part message in MIME format... ------------=_1636828982-20692-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #51814: follow-scroll-down leaves point in wrong place in a corner case. which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 51814@debbugs.gnu.org. --=20 51814: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D51814 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1636828982-20692-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 51814-done) by debbugs.gnu.org; 13 Nov 2021 18:42:38 +0000 Received: from localhost ([127.0.0.1]:48063 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mlxz4-0005N4-NZ for submit@debbugs.gnu.org; Sat, 13 Nov 2021 13:42:38 -0500 Received: from colin.muc.de ([193.149.48.1]:26728 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1mlxz3-0005Mn-BG for 51814-done@debbugs.gnu.org; Sat, 13 Nov 2021 13:42:38 -0500 Received: (qmail 47196 invoked by uid 3782); 13 Nov 2021 18:42:30 -0000 Received: from acm.muc.de (p4fe15fc7.dip0.t-ipconnect.de [79.225.95.199]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Sat, 13 Nov 2021 19:42:30 +0100 Received: (qmail 17048 invoked by uid 1000); 13 Nov 2021 18:42:29 -0000 Date: Sat, 13 Nov 2021 18:42:29 +0000 To: Juri Linkov Subject: Re: bug#51814: follow-scroll-down leaves point in wrong place in a corner case. Message-ID: References: <864k8gdjkb.fsf@mail.linkov.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <864k8gdjkb.fsf@mail.linkov.net> X-Submission-Agent: TMDA/1.3.x (Ph3nix) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 51814-done Cc: 51814-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hello, Juri On Sat, Nov 13, 2021 at 19:58:12 +0200, Juri Linkov wrote: > > I believe the following patch fixes this. Juri, could you try it out, > > please. > > As a test buffer, > > (i) open elisp.info in a default GUI window (34 lines); > > (ii) C-x 3 ; split it with a vertical divider. > > (iii) ] ; Move to next page in manual, "Introduction". > > (iv) M-x follow-mode. > > (v) C-u 20 C-v ; scroll-up a significant amount. > > (vi) Move point to the line beginning "* Caveats". > > (vii) M-x follow-scroll-down. > > Note that point is in a random place. This is a bug. > Thanks, I confirm this bug is fixed with your patch. > I've tested it with and without tab-line-mode in Info > with the header line. Thanks for the testing! I've committed the patch to the emacs-28 branch, and I'm closing the bug with this post. -- Alan Mackenzie (Nuremberg, Germany). ------------=_1636828982-20692-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 13 Nov 2021 17:46:43 +0000 Received: from localhost ([127.0.0.1]:48005 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mlx6x-0003qj-7T for submit@debbugs.gnu.org; Sat, 13 Nov 2021 12:46:43 -0500 Received: from lists.gnu.org ([209.51.188.17]:36868) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mlx6s-0003qY-HC for submit@debbugs.gnu.org; Sat, 13 Nov 2021 12:46:41 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41116) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mlx6s-0000OD-9D for bug-gnu-emacs@gnu.org; Sat, 13 Nov 2021 12:46:38 -0500 Received: from colin.muc.de ([193.149.48.1]:25292 helo=mail.muc.de) by eggs.gnu.org with smtp (Exim 4.90_1) (envelope-from ) id 1mlx6p-0000o0-Rs for bug-gnu-emacs@gnu.org; Sat, 13 Nov 2021 12:46:38 -0500 Received: (qmail 10966 invoked by uid 3782); 13 Nov 2021 17:46:19 -0000 Received: from acm.muc.de (p4fe15fc7.dip0.t-ipconnect.de [79.225.95.199]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Sat, 13 Nov 2021 18:46:19 +0100 Received: (qmail 27491 invoked by uid 1000); 13 Nov 2021 17:46:18 -0000 Date: Sat, 13 Nov 2021 17:46:18 +0000 To: bug-gnu-emacs@gnu.org, Juri Linkov Subject: follow-scroll-down leaves point in wrong place in a corner case. Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Submission-Agent: TMDA/1.3.x (Ph3nix) From: Alan Mackenzie X-Primary-Address: acm@muc.de Received-SPF: pass client-ip=193.149.48.1; envelope-from=acm@muc.de; helo=mail.muc.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.6 (-) X-Debbugs-Envelope-To: submit Cc: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.6 (--) Hello, Juri and Emacs. On the emacs-28 branch and master. This bug is a corner case, noted but not fixed in bug #51590. >From a post in that bug thread: [*] There is a situation which is not new, where if the buffer is too short to fill all the windows, and it is already scrolled up far, follow-scroll-down will scroll a correct amount, but leave point in a random position. I believe the following patch fixes this. Juri, could you try it out, please. As a test buffer, (i) open elisp.info in a default GUI window (34 lines); (ii) C-x 3 ; split it with a vertical divider. (iii) ] ; Move to next page in manual, "Introduction". (iv) M-x follow-mode. (v) C-u 20 C-v ; scroll-up a significant amount. (vi) Move point to the line beginning "* Caveats". (vii) M-x follow-scroll-down. Note that point is in a random place. This is a bug. The cause of the bug is that the current code is "optimised" for the case where there are enough buffer lines above point to scroll a full follow-page, yet neglects the case where this doesn't hold. The patch does away with this optimisation. diff --git a/lisp/follow.el b/lisp/follow.el index 2ca2c1f17b..3761275bbf 100644 --- a/lisp/follow.el +++ b/lisp/follow.el @@ -669,24 +669,30 @@ follow-scroll-down (t (let* ((orig-point (point)) (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 (or (null scroll-error-top-bottom) (bobp)) (signal 'beginning-of-buffer nil) (goto-char (point-min))) - (select-window win) - (goto-char start) - (vertical-motion (- (- (window-height win) - (if header-line-format 2 1) ; always mode-line - (if tab-line-format 1 0) - next-screen-context-lines))) - (set-window-start win (point)) - (if (< orig-point (window-end win t)) - (goto-char orig-point) - (goto-char start) - (vertical-motion (- next-screen-context-lines 1))) + (select-window (car windows)) + (dolist (win windows) + (setq lines + (+ lines + (- (window-height win) + (if header-line-format 2 1) ; Count mode-line, too. + (if tab-line-format 1 0))))) + (setq lines (- lines next-screen-context-lines)) + (goto-char start) + (let ((at-top (> (vertical-motion (- lines)) (- lines)))) + (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)))))) (put 'follow-scroll-down 'scroll-command t) -- Alan Mackenzie (Nuremberg, Germany). ------------=_1636828982-20692-1--