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

From: Eli Zaretskii <[email-masked]>
Date: Fri, 28 Sep 2018 09:22:07 +0300

> From: Juri Linkov <[email-masked]>
> Cc: [email-masked]
> Date: Fri, 28 Sep 2018 01:59:04 +0300
> 
> >>      (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.
> 
> Then why REDISPLAY is non-nil, if it doesn't redisplay the frame?

There's a long history to this, you may wish to use "git -L" and look
at the discussions/bug reports related to 'recenter'.

The short answer is that this arrangement (which is new in Emacs 27)
has its main goal to allow "C-l" to redraw the entire frame when the
user so desires (by default, only on TTY frames), while avoiding the
frame redraw in most, if not all, other situations, because redrawing
a frame causes flickering.  This flickering is caused by Lisp programs
calling 'recenter', directly or indirectly.

> I thought that scrolling for the sake of window-scroll-functions
> implies the changes in the value of window-start, i.e. when
> an old value of window-start is not the same as its new value,
> this guarantees the call of window-scroll-functions.

That'd cause window-scroll-functions to be called in too many
unrelated situations, because almost every redisplay cycle changes the
value of window-start.  E.g., consider goto-char or goto-line or even
C-s that finds the match off-screen.

> The docstring of window-scroll-functions says:
> 
>   These functions are called whenever the ‘window-start’ marker is modified,
>   either to point into another buffer (e.g. via ‘set-window-buffer’) or another
>   place in the same buffer.

You've omitted the first line of the doc string:

  List of functions to call before redisplaying a window with scrolling.
                                                         ^^^^^^^^^^^^^^
> Maybe it will be called in the new hook window-state-change-functions
> proposed by Martin.

I hope not.