Subject: Re: bug#76186: 31.0.50; (recenter 0) sometimes does not recenter as expected

From: Stephen Berman <[email-masked]>
Date: Sat, 22 Feb 2025 14:46:34 +0100

On Sat, 22 Feb 2025 15:32:28 +0200 Eli Zaretskii <[email-masked]> wrote:

>> From: Stephen Berman <[email-masked]>
>> Cc: [email-masked],  [email-masked]
>> Date: Sat, 22 Feb 2025 14:08:07 +0100
[...]
>> When I start Emacs like this:
>>
>> emacs -Q -l bug#76186.el
>>
>> and, if the mouse pointer is over the Emacs frame, do not touch the
>> mouse, then after 501 iterations the loop stops (I've also done tests
>> with more than 10000 iterations with the same results) and the message
>> "window-start=793, point-max=793 in run 501" is displayed, indicating
>> the expected result of `(recenter 0)'.  However, in the displayed
>> "sample" buffer, point-max is vertically centered in the window (as
>> after `(recenter)') and window-start is 671.
[...]
> Thanks.  I'm afraid I'm none the wiser, because I see none of the
> phenomena you describe on my system.  Whatever I do, the test always
> runs to completion, and the last screen shows point at EOB.

By "runs to completion" I suppose you mean 501 iterations (or whatever
you set n to)?  In this case is the message as above, with window-start
and point-max identical, or does the message show them differing?  The
latter would be unexpected unless the loop stopped before 501 (or n)
iterations.

> Some parts of what you describe seem to indicate that the problem is
> not with 'recenter' itself, but with the following redisplay cycle,
> which, for some reason, considers the window-start position
> inappropriate and recenters point on display.  But I have no idea why,
> and it is impossible to debug this when the problem happens as part of
> 500 iterations.

I agree, and the apparent ineffectiveness of Edebug in this case is also
frustrating.  I could try using gdb with the test configuration where I
consistly get the "unexpected recentering" after one iteration; can you
suggest where to set the break point and any other input that may be
helpful?

Steve Berman