Subject: bug#17678: 24.4.50; Feature Request -- calculate new `window-start` & `window-end` before visual redisplay

From: Eli Zaretskii <[email-masked]>
Date: Fri, 13 Jun 2014 20:55:51 +0300

> Date:  Fri, 13 Jun 2014 09:22:07 -0700
> From:  Keith David Bershatsky <[email-masked]>
> Cc:  [email-masked]
> 
> The `window-scroll-functions` hook would be more useful if the value of `window-start` could be obtained *before* running the `post-command-hook`.  At the present time, it would appear that the `post-command-hook` runs *before* the `window-scroll-functions` hook.  Therefore, the `post-command-hook` cannot presently use the `window-start` value produced from the `window-scroll-functions` hook (which occurs *after* the `post-command-hook` has already finished).

Yes, post-command-hook runs before window-scroll-functions.  That's
because post-command-hook runs immediately after a command execution
is finished and Emacs is about to return to the command loop, while
window-scroll-functions run as part of redisplay, which is entered
whenever Emacs is idle, i.e., after the return to the command loop.

Unfortunately, what you are asking for is not possible with the
current design of Emacs, because window-start is computed as part of
redisplay (it is one of the most important functions of redisplay to
compute that).

OTOH, I don't understand why do you need what you ask for.  For
example, why can't you do whatever you need from
window-scroll-functions, instead of doing some of it in
post-command-hook?  Perhaps you should describe the problem you are
trying to solve in more detail.