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: Juri Linkov
Subject: bug#32672: 27.0.50; image resize on window resizing
Date: Sun, 23 Sep 2018 23:39:56 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu)

> I'm afraid that 'buffer-list-update-hook' is too coarse for your
> purpose - it gets called too often for unrelated events like creating
> or killing some completely unrelated buffer.

I agree that 'buffer-list-update-hook' is unsuitable for this task.

> If you think that running a hook after selecting a window with
> NORECORD nil would fit the bill better, let's try it.  Many people
> have asked for such a hook and we always rejected it (Bug#7381,
> Bug#16436).  Maybe it is time to reconsider.

In (info "(elisp) Selecting Windows") I see explanations why
there is no separate hook whenever a window gets selected.

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

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





reply via email to

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