I'm writing a simple minor mode (for personal use) which dynamically sets fringes according to current window width. I added a dedicated function to those hooks:

  • window-configuration-change-hook
  • window-setup-hook
  • switch-window-finish-hook
  • kill-buffer-hook

as well as to pre-redisplay-function and it works quite fine.

But there are external packages or in-built Emacs functions which pop up a buffer in other window (e.g. *help* buffers or magit diffs buffer) with focus remaining in current buffer and those buffers are not displayed properly (meaning: according to my intention) unless I switch to them and they gain a "selected window" status.

Is there a hook which controls redisplaying those "automatic" guests in the frame or, even better, a hook which would loop over all active windows after any change of windows configuration?

  • 2
    Does window-configuration-change-hook not get called for the frame? You could do a walk-windows in there.
    – rpluim
    Oct 22, 2018 at 15:28
  • Thanks, I seem to misunderstood the docs for this hook and took for granted that it will walk through all windows evaluating my func. I've rewritten my code adding WINDOW as an argument (since this hook requires it) and added (lambda () (walk-windows 'my-func) to the hook. Now it works just fine.
    – caseneuve
    Oct 22, 2018 at 16:00

1 Answer 1


The global value of window-configuration-change-hook is called once for the modified frame, and can be used to iterate over all the windows using walk-windows

  • 1
    After some refactoring I'd just add then when it comes to buffer-local settings walk-windows might be tricky: it does walk through all windows but selected-window remains the one which was at the beginning and so do all buffer-local variables: walk-windows would apply the buffer-local variables of the selected-window to any other window. For me it was not an intuitive behaviour (I was assuming then "walking" changes the selected window and respects buffer local vars). Anyway, (with-current-buffer (window-buffer WINDOW)) was the missing puzzle.
    – caseneuve
    Oct 22, 2018 at 21:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.