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

From: Eli Zaretskii <[email-masked]>
Date: Sun, 12 May 2024 09:00:42 +0300

> From: Ihor Radchenko <[email-masked]>
> Cc: [email-masked], [email-masked]
> Date: Sat, 11 May 2024 19:09:34 +0000
> 
> Eli Zaretskii <[email-masked]> writes:
> 
> >> In my specific reproducer the point is not moved, AFAIK.
> >
> > Of course it can move: as the window is scrolled by
> > pixel-scroll-precision-interpolate, point can become invisible.  If
> > redisplay kicks in, it will move point to bring it back into the
> > viewport.
> 
> But it is not what happens in the recording!
> The point remains at the same line.

That's only what you see when redisplay shows you something.  That's
not all that happens.

> Or do you mean that the point is somehow moved around during the progn execution?

Of course, it does!  Even eval-buffer itself moves point.

> But it does not look like it is the case - when I try
> 
> (setq point-list nil)
> (setq current-line-list nil)
> (progn
>   (push (point) point-list)
>   (push (count-lines 1 (point)) current-line-list)
>   (require 'pixel-scroll)
>   (push (point) point-list)
>   (push (count-lines 1 (point)) current-line-list)
>   (pixel-scroll-precision-interpolate
>    (* -1 (line-pixel-height)
>       (max 0 (- (count-screen-lines (window-start) (point)) 2)))
>    nil 1)
>   (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.

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.

> > That the behavior changed recently doesn't yet mean the previous
> > behavior was correct and the new one is wrong.  It might mean your
> > code is based on incorrect assumptions, and just happened to work
> > previously by sheer luck.
> 
> 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?