Subject: Re: bug#32839: 27.0.50; recenter doesn't redisplay

From: Eli Zaretskii <[email-masked]>
Date: Thu, 27 Sep 2018 09:44:43 +0300

> From: Juri Linkov <[email-masked]>
> Cc: [email-masked]
> Date: Thu, 27 Sep 2018 02:55:38 +0300
> 
> 1. recenter doesn't redraw the frame when it is called with
>    a non-nil REDISPLAY argument.
> 
>    In `recenter-top-bottom', when `recenter-last-op' is `top',
>    this gets called:
> 
>      (recenter this-scroll-margin t)
> 
>    When `this-scroll-margin' is 0, the actual call is:
> 
>      (recenter 0 t)
> 
>    Despite its REDISPLAY argument set to t, the frame is not redisplayed.

This is how 'recenter' is documented to behave:

  If ARG is omitted or nil, then recenter with point on the middle line
  of the selected window; if REDISPLAY & ‘recenter-redisplay’ are
  non-nil, also erase the entire frame and redraw it [...]

IOW, the frame is redrawn only when ARG is nil and REDISPLAY is
non-nil.

> 2. The second problem is that after the call to (recenter -1 t),
>    window-scroll-functions is called only when recenter moves the current
>    buffer line to the second-last window line (when the last window line is
>    partially visible).  But when the last window line is fully visible,
>    window-scroll-functions is not called after (recenter -1 t).

Depending on the exact dimensions of the window and the size of your
font, this can legitimately happen.

You see, the way 'recenter' works, it sets a couple of fields in the
window object which instruct the display engine to change the
window-start point.  The actual recentering happens during the very
next redisplay cycle, at which time the display engine sees these
fields and acts accordingly.  To redisplay a window, the display
engine has several methods at its disposal; starting with the cheapest
one, it attempts to find the first applicable one, and then uses it.
Only some of the methods are considered to use "scrolling", others
aren't.  So that's why window-scroll-functions might not be called
when the text was "scrolled" by 'recenter' and its derivatives.

Like I said: "scrolling" is only well-defined when you use the
scrolling functions and commands, like scroll-up, scroll-down-command,
etc.  It is not well-defined with other functions which move the
viewport, so window-scroll-functions may or may not be called when
those other functions are invoked.

Bottom line, I see no problem in the behavior described in this bug
report, and I think it should be closed.