bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#32672: 27.0.50; image resize on window resizing


From: martin rudalics
Subject: bug#32672: 27.0.50; image resize on window resizing
Date: Mon, 24 Sep 2018 10:22:45 +0200

> But when I tried
>
>    (advice-add 'select-window :before
>                (lambda (window &optional norecord)
>                  (message "select-window %S" window)))
>
> it's clear it's unsuitable either.  It's not called when needed,
> e.g. when a window displays a new buffer after navigating to it
> with 'C-x <C-left>' (previous-buffer).

Because the selected window does not change, obviously.

> However, I get exactly what is needed with
>
>    (advice-add 'set-window-buffer :before
>                (lambda (window buffer-or-name &optional keep-margins)
>                  (message "set-window-buffer %S %S" window buffer-or-name)))
>
> It's called every time when a buffer is displayed in a window.
>
> 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.

> 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?
>
> 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.

I don't know what to do.  We run hooks too often and do not provide
sufficient information when running them.  Sometimes we even hide
information when running a hook.  The problem is that changing the
current situation will have us either run even more hooks or cause
protests when a hook is no more run where it was run before.

martin






reply via email to

[Prev in Thread] Current Thread [Next in Thread]