Subject: bug#70386: 30.0.50; (recenter 0 t) does not put point on top of the window

From: Ihor Radchenko <[email-masked]>
Date: Sun, 12 May 2024 06:17:49 +0000

Eli Zaretskii <[email-masked]> writes:

>>   (push (point) point-list)
>>   (push (count-lines 1 (point)) current-line-list)
>>   ;; Call original recenter for final adjustment.
>>   (recenter 0 t)
>>   (push (point) point-list)
>>   (push (count-lines 1 (point)) current-line-list))
>> 
>> point-list ; -> 757 757 757 757
>> current-line-list ; -> 21 21 21 21
>
> Try harder, that's not all the truth.  In particular, what happens
> during the interpolation is not shown.

Why does it need to matter? Right before calling recenter, the point is
at 757, as you can see from point-list in my test.
Or do _previous_ point positions affect `recenter'?

> In addition, the way 'recenter' works, it is not guaranteed that point
> will end up on the line you ask it to place point.  It's a "best
> effort", no more.

May you please explain how I am supposed to know this from reading the
docstring?

    With a numeric prefix argument ARG, recenter putting point on screen line ARG
    relative to the selected window.  If ARG is negative, it counts up from the
    bottom of the window.  (ARG should be less than the height of the window.)

>> Maybe. But I do believe that my reproducer demonstrates a bug.
>
> Why do you still believe that?  What will it take to convince you that
> in the situation your recipe creates the result can sometimes be not
> what you want?

At least, a docstring that explains what `recenter' does better.
And even then, when scrolling current line to be on the top (which is
what (recenter 0 t) supposed to do), as a user, I will be surprised that
the current line remains at line 21! - what kind of "best effort" is
that when the result if off by 21 lines? surely, Emacs can do better.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>