I'm in the process of writing an Emacs package that helps you controlling popup windows and have hit a minor roadblock while developing a new feature for it. Currently I'm using
window-configuration-change-hook to track certain buffers and their windows that have either been buried or closed, however this hook cannot catch if the buffer in question has been killed since this isn't a window configuration change.
edit: There is a
kill-buffer-hook that could help me solve this minor annoyance, however it's run differently than
window-configuration-change-hook is run after the window configuration changes,
kill-buffer-hook is run before the buffer is killed with the buffer selected. This means that if I add my function to both hooks, I cannot detect if the buffer has been killed because it hasn't been killed yet when the hook is run. That means I'd need to either use a different function in
kill-buffer-hook that operates on the selected buffer than in
window-configuration-change-hook where the selected buffer has different semantics or would need to know what hook has run it.