GNU bug report logs -
#75949
kill-buffer-quit-windows breaks kill-buffer-hook
Previous Next
Reported by: Juri Linkov <juri <at> linkov.net>
Date: Thu, 30 Jan 2025 17:14:02 UTC
Severity: normal
Fixed in version 31.0.50
Done: Juri Linkov <juri <at> linkov.net>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Please try to evaluate in the *scratch* buffer:
(progn
(setopt kill-buffer-quit-windows t)
(view-echo-area-messages)
(pop-to-buffer-same-window (get-buffer-create "foo"))
(add-hook 'kill-buffer-hook (lambda () (message "%S" (current-buffer))))
(add-hook 'kill-buffer-hook (lambda () (kill-buffer (get-buffer "bar")))
nil t)
(display-buffer (get-buffer-create "bar"))
(switch-to-buffer (get-buffer "*scratch*"))
(kill-buffer (get-buffer "foo")))
Then observe in the *Messages* buffer that the hook 'kill-buffer-hook'
is run in the *scratch* buffer that is never killed.
Afterwards try to set kill-buffer-quit-windows back to the default value nil,
and evaluate again. Then everything is correct.
It seems that kill-buffer-quit-windows somehow messes up the current buffer
while running 'kill-buffer-hook'.
This is a distilled test case from the real problem
in treesit--explorer-kill-explorer-buffer
that prevents (add-hook 'kill-buffer-hook #'save-place-to-alist)
from saving places in the right buffer.
This bug report was last modified 111 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.