Subject: bug#22404: 25.1.50; Forcing `window-scroll-functions` to run.

From: Eli Zaretskii <[email-masked]>
Date: Tue, 02 Feb 2016 20:43:13 +0200

> Date:  Tue, 02 Feb 2016 10:16:23 -0800
> From:  Keith David Bershatsky <[email-masked]>
> Cc:  [email-masked]
> 
> A forced redisplay every command loop would pose two (2) major problems as far as I am aware.  The first issue will be that an unfinished display will be visible to the user for a split second before it gets finished with whatever code follows the first visible redisplay

That depends where the hook will be called.  If it is called before
the changed contents is delivered to the glass, you won't see any such
adverse effects, exactly like you don't see them today when
window-scroll-functions are called after a large portion of redisplay
already happened.

> The second issue will be a significant slow-down in performance that will be mostly visible to the user when using rapid-fire keystrokes, or simply moving the cursor with the arrow keys by holding the arrow key in any of the four directions.  A forced redisplay is something that should be used sparingly, but not every command loop.

Emacs display engine is highly optimized: if there's nothing to do
when it is called the second time, it will detect that very quickly
and return without doing anything.  Specifically, if only cursor
motion happened, redisplay is very fast.

And the hook doesn't have to be dumb and call the second redisplay
every time.  It can be smarter, and only do so if it actually made
some changes, like moved an overlay or scrolled the window.  In the
latter case, the comparison with just moving cursor is no longer
valid.

So if such problems do exist, they will need to be reported with
specific use cases, because in general the current code already deals
with this.

> The four (4) values I seek *may* be available via Lisp depending upon where the `post-redisplay-hook` is placed.  I'd be happy to run some tests once you have decided upon a proposed location for the hook.

I don't understand the "maybe" part.  We are talking about values that
are easily obtained from any Lisp program, so what are the problems
you envision?