From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#51590: follow-mode is broken with header-line and tab-line Date: Thu, 04 Nov 2021 19:29:28 +0200 Organization: LINKOV.NET Message-ID: <86pmrf3l9m.fsf_-_@mail.linkov.net> References: <86bl31xfl9.fsf@mail.linkov.net> <83h7ctgk93.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16029"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) Cc: 51590@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Nov 04 18:40:30 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1migj0-00040Y-CA for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 04 Nov 2021 18:40:30 +0100 Original-Received: from localhost ([::1]:49076 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1migiy-00032M-BL for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 04 Nov 2021 13:40:28 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44908) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1migha-0002Rg-M1 for bug-gnu-emacs@gnu.org; Thu, 04 Nov 2021 13:39:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:60003) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mighZ-0001hP-Mt for bug-gnu-emacs@gnu.org; Thu, 04 Nov 2021 13:39:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mighZ-0001V8-Jc for bug-gnu-emacs@gnu.org; Thu, 04 Nov 2021 13:39:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 04 Nov 2021 17:39:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51590 X-GNU-PR-Package: emacs Original-Received: via spool by 51590-submit@debbugs.gnu.org id=B51590.16360474905671 (code B ref 51590); Thu, 04 Nov 2021 17:39:01 +0000 Original-Received: (at 51590) by debbugs.gnu.org; 4 Nov 2021 17:38:10 +0000 Original-Received: from localhost ([127.0.0.1]:43314 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1miggk-0001TO-2I for submit@debbugs.gnu.org; Thu, 04 Nov 2021 13:38:10 -0400 Original-Received: from relay12.mail.gandi.net ([217.70.178.232]:47977) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1miggT-0001S1-RS; Thu, 04 Nov 2021 13:38:08 -0400 Original-Received: (Authenticated sender: juri@linkov.net) by relay12.mail.gandi.net (Postfix) with ESMTPSA id EF6D6200003; Thu, 4 Nov 2021 17:37:46 +0000 (UTC) In-Reply-To: <83h7ctgk93.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 03 Nov 2021 20:35:36 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:218913 Archived-At: --=-=-= Content-Type: text/plain retitle 51590 follow-mode is broken with header-line and tab-line quit >> The most low-level function of follow-mode is follow-calc-win-end. >> When global-tab-line-mode is enabled, follow-calc-win-end >> returns the same values as when global-tab-line-mode is disabled. > > Can you step through that function and see which part is misbehaving > there? > >> I don't understand what more low-level function doesn't take >> into account the height of the tab-line. Maybe the problem is >> in pos-visible-in-window-p? Or maybe different values returned >> by window-inside-pixel-edges and window-end? > > I don't know the answer, but I see that header-line-format is > mentioned in one place in follow.el, and that is not a good sign... Indeed, I tested with the header-line, and it has the same problem, so retitled this bug report. After trial and error, I arrived to the following patch that completely fixes these problems. However, I can't explain how it works. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=follow-line-height.patch diff --git a/lisp/follow.el b/lisp/follow.el index b64f4cb734..327c66d5ff 100644 --- a/lisp/follow.el +++ b/lisp/follow.el @@ -679,6 +679,7 @@ follow-scroll-down (goto-char start) (vertical-motion (- (- (window-height win) (if header-line-format 2 1) + (if tab-line-format 2 1) next-screen-context-lines))) (set-window-start win (point)) (goto-char start) @@ -946,8 +947,10 @@ follow-calc-win-end used." (let* ((win (or win (selected-window))) (edges (window-inside-pixel-edges win)) - (ht (- (nth 3 edges) (nth 1 edges))) - (last-line-pos (posn-point (posn-at-x-y 0 (1- ht) win)))) + (ht (+ (- (nth 3 edges) (nth 1 edges)) + (window-header-line-height win) + (window-tab-line-height win))) + (last-line-pos (posn-point (posn-at-x-y 0 (- ht 1) win)))) (if (pos-visible-in-window-p last-line-pos win) (let ((end (window-end win t))) (list end (pos-visible-in-window-p (point-max) win))) --=-=-=--