Subject: bug#32672: 27.0.50; image resize on window resizing

From: Juri Linkov <[email-masked]>
Date: Mon, 24 Sep 2018 21:31:13 +0300

>> But unfortunately it has no hook, and (info "(elisp) Buffers and Windows") says
>> that set-window-buffer runs window-configuration-change-hook (too general
>> for this task since called too often)
>
> Because we run it also whenever a window changes size which is silly.
> What else do we have 'window-size-change-functions' for?  I wanted to
> change that but apparently ducked out.

Maybe because taking out window size change notifications from
window-configuration-change-hook is a backward-incompatible change?

>> and window-scroll-functions (also called too often).
>
>> Regarding window-scroll-functions, it would be too strange to use
>> it to catch set-window-buffer calls.
>>
>> (info "(elisp) Window Hooks") says:
>>
>>    There are three actions that can change this: scrolling the window,
>>    switching buffers in the window, and changing the size of the window.
>>    The first two actions run ‘window-scroll-functions’; the last runs
>>    ‘window-size-change-functions’.
>>
>> Shouldn't the first two actions run separate hooks?

Please also answer this question.  I believe this is the crucial question
for this request.

>> Moreover, it seems window-scroll-functions doesn't work even
>> for its purpose: it's not called after scrolling, e.g. not called
>> after 'C-l' (recenter-top-bottom) - tried with different prefix args.
>
> Maybe because the buffer of the scrolled window is not current when
> you call it.

Sorry, actually it works, I missed the logged messages because the content
of the *Messages* buffer is not refreshed to show new logged messages
from the calls of the window-scroll-functions hook such as

  (add-to-list 'window-scroll-functions
               (lambda (window display-start)
                 (message "window-scroll-functions %S %S %S"
                          window (window-buffer window) display-start)))

This means that C-l (recenter-top-bottom) doesn't redisplay the frame -
which is strange since it calls 'recenter' with non-nil arg REDISPLAY.
Only after switching to the *Messages* buffer with 'C-x o' it gets
redisplayed and all previously emitted messages appear in it.