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.
This commit is contained in:
parent
3965df56e8
commit
12dc195774
1 changed files with 6 additions and 3 deletions
|
@ -212,7 +212,8 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original
|
||||||
(cond ((eq buf (doom-fallback-buffer))
|
(cond ((eq buf (doom-fallback-buffer))
|
||||||
(message "Can't kill the fallback buffer.")
|
(message "Can't kill the fallback buffer.")
|
||||||
t)
|
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))))
|
(let ((visible-p (delq (selected-window) (get-buffer-window-list buf nil t))))
|
||||||
(unless visible-p
|
(unless visible-p
|
||||||
(when (and (buffer-modified-p buf)
|
(when (and (buffer-modified-p buf)
|
||||||
|
@ -221,8 +222,10 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original
|
||||||
buf))))
|
buf))))
|
||||||
(user-error "Aborted")))
|
(user-error "Aborted")))
|
||||||
(let ((inhibit-redisplay t)
|
(let ((inhibit-redisplay t)
|
||||||
buffer-list-update-hook)
|
buffer-list-update-hook
|
||||||
(when (or ;; if there aren't more real buffers than visible buffers,
|
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.
|
;; then there are no real, non-visible buffers left.
|
||||||
(not (cl-set-difference (doom-real-buffer-list)
|
(not (cl-set-difference (doom-real-buffer-list)
|
||||||
(doom-visible-buffers nil t)))
|
(doom-visible-buffers nil t)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue