From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#18618: 25.0.50; `window-end win t` produces erroenous result with `window-scroll-functions` hook. Date: Sat, 29 May 2021 09:24:23 +0300 Message-ID: <83im326ors.fsf@gnu.org> References: <87lf7yus5t.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2804"; mail-complaints-to="usenet@ciao.gmane.io" Cc: esq@lawlist.com, 18618@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat May 29 08:25:23 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 1lmsPT-0000VH-CF for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 29 May 2021 08:25:23 +0200 Original-Received: from localhost ([::1]:38400 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lmsPS-0005gm-BU for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 29 May 2021 02:25:22 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39958) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lmsP8-0005dl-53 for bug-gnu-emacs@gnu.org; Sat, 29 May 2021 02:25:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:44282) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lmsP7-0001T4-TO for bug-gnu-emacs@gnu.org; Sat, 29 May 2021 02:25:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lmsP7-0001fE-Od for bug-gnu-emacs@gnu.org; Sat, 29 May 2021 02:25:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 29 May 2021 06:25:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 18618 X-GNU-PR-Package: emacs Original-Received: via spool by 18618-submit@debbugs.gnu.org id=B18618.16222694696336 (code B ref 18618); Sat, 29 May 2021 06:25:01 +0000 Original-Received: (at 18618) by debbugs.gnu.org; 29 May 2021 06:24:29 +0000 Original-Received: from localhost ([127.0.0.1]:55828 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lmsOa-0001e2-Mg for submit@debbugs.gnu.org; Sat, 29 May 2021 02:24:28 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:46200) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lmsOV-0001df-N0; Sat, 29 May 2021 02:24:27 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:35610) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lmsOQ-0000gB-6u; Sat, 29 May 2021 02:24:18 -0400 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:4794 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lmsOP-0001JH-Pf; Sat, 29 May 2021 02:24:18 -0400 In-Reply-To: <87lf7yus5t.fsf@gnus.org> (message from Lars Ingebrigtsen on Sat, 29 May 2021 05:37:18 +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:207504 Archived-At: tags 18618 notabug close 18618 thanks > From: Lars Ingebrigtsen > Date: Sat, 29 May 2021 05:37:18 +0200 > Cc: 18618@debbugs.gnu.org > > Keith David Bershatsky writes: > > > Steps to reproduce the issue. > > > > 1. Create a function that reports (e.g., a message) the value of `(window-end win t)` and attach that function to the `window-scroll-functions` hook. > > > > 2. Open a long file in either fundamental-mode or text-mode. > > > > 3. M-x end-of-buffer > > > > 4. M-x beginning-of-buffer > > > > The result of step 4 reports an erroneous window-end value that is at > > the very end of the buffer, instead of the correct window-end (i.e., > > which is much closer to the beginning of the buffer). > > (I'm going through old bug reports that unfortunately got no response at > the time.) > > This problem is still present in Emacs 28. Here's an easier test case: > > (defun foo (win _) > (message "End: %s" (window-end win t)) > nil) > (push 'foo window-scroll-functions) > > This reports the same number in both 3) and 4) when transient-mark-mode > is switched on, but not when it's off. It's also correct if that mode > is on, and the region is active. > > I haven't tried to debug further -- perhaps it's immediately obvious to > somebody what could be causing this glitch? This isn't supposed to work. The doc string of window-end says: Return position at which display currently ends in WINDOW. WINDOW must be a live window and defaults to the selected one. This is updated by redisplay, when it runs to completion. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ By contrast, window-scroll-functions is a hook run by the display engine in the middle of redisplaying a window, when the display engine concludes that it is about to scroll the window. At that point, the window's redisplay is by definition not complete yet, so this can only work by chance. Which is why window-scroll-functions' doc string says explicitly this doesn't work: Note that the value of ‘window-end’ is not valid when these functions are called. So Emacs behaves here as designed and as documented, and I'm therefore closing this bug.