From 12dc1957746a32cdeac0388808d88812f47e3b9d Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 11 Jul 2024 15:22:12 -0400 Subject: [PATCH] fix: kill-current-buffer: respect kill-buffer-query-functions This advice is intended to fake the death of buffers that are visible in other windows, and prevent Emacs from switching to a non-real buffer after it's killed/buried. It shouldn't even try to do any of this if `kill-buffer-query-functions` fails, even if it is a fake death. --- lisp/doom-ui.el | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lisp/doom-ui.el b/lisp/doom-ui.el index 6f4aa5eee..fa3bb02e9 100644 --- a/lisp/doom-ui.el +++ b/lisp/doom-ui.el @@ -212,7 +212,8 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original (cond ((eq buf (doom-fallback-buffer)) (message "Can't kill the fallback buffer.") t) - ((doom-real-buffer-p buf) + ((and (doom-real-buffer-p buf) + (run-hook-with-args-until-failure 'kill-buffer-query-functions)) (let ((visible-p (delq (selected-window) (get-buffer-window-list buf nil t)))) (unless visible-p (when (and (buffer-modified-p buf) @@ -221,8 +222,10 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original buf)))) (user-error "Aborted"))) (let ((inhibit-redisplay t) - buffer-list-update-hook) - (when (or ;; if there aren't more real buffers than visible buffers, + buffer-list-update-hook + kill-buffer-query-functions) + (when (or + ;; if there aren't more real buffers than visible buffers, ;; then there are no real, non-visible buffers left. (not (cl-set-difference (doom-real-buffer-list) (doom-visible-buffers nil t)))