unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: esq@lawlist.com, 18618@debbugs.gnu.org
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	[thread overview]
Message-ID: <83im326ors.fsf@gnu.org> (raw)
In-Reply-To: <87lf7yus5t.fsf@gnus.org> (message from Lars Ingebrigtsen on Sat,  29 May 2021 05:37:18 +0200)

tags 18618 notabug
close 18618
thanks

> From: Lars Ingebrigtsen <larsi@gnus.org>
> Date: Sat, 29 May 2021 05:37:18 +0200
> Cc: 18618@debbugs.gnu.org
> 
> Keith David Bershatsky <esq@lawlist.com> 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.





  reply	other threads:[~2021-05-29  6:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-03  1:06 bug#18618: 25.0.50; `window-end win t` produces erroenous result with `window-scroll-functions` hook Keith David Bershatsky
2014-10-03  2:11 ` bug#18618: " Keith David Bershatsky
2021-05-29  3:37 ` bug#18618: 25.0.50; " Lars Ingebrigtsen
2021-05-29  6:24   ` Eli Zaretskii [this message]
2021-05-29  6:16 ` Keith David Bershatsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83im326ors.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=18618@debbugs.gnu.org \
    --cc=esq@lawlist.com \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).