Trigger doom-switch-buffer-hook on kill-current-buffer

Fixes the dashboard not loading when killing a file opened at
startup, i.e. `emacs FILE1` and landing in *doom*.
This commit is contained in:
Henrik Lissner 2021-05-28 16:22:26 -04:00
parent 69ea5c2020
commit 0d9b4a7da0

View file

@ -246,29 +246,29 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original
(message "Can't kill the fallback buffer.") (message "Can't kill the fallback buffer.")
t) t)
((doom-real-buffer-p buf) ((doom-real-buffer-p buf)
(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))))
(doom-inhibit-switch-buffer-hooks t)
(inhibit-redisplay t)
buffer-list-update-hook)
(unless visible-p (unless visible-p
(when (and (buffer-modified-p buf) (when (and (buffer-modified-p buf)
(not (y-or-n-p (not (y-or-n-p
(format "Buffer %s is modified; kill anyway?" (format "Buffer %s is modified; kill anyway?"
buf)))) buf))))
(user-error "Aborted"))) (user-error "Aborted")))
(when (or ;; if there aren't more real buffers than visible buffers, (let ((inhibit-redisplay t)
;; then there are no real, non-visible buffers left. (doom-inhibit-switch-buffer-hooks t)
(not (cl-set-difference (doom-real-buffer-list) buffer-list-update-hook)
(doom-visible-buffers))) (when (or ;; if there aren't more real buffers than visible buffers,
;; if we end up back where we start (or previous-buffer ;; then there are no real, non-visible buffers left.
;; returns nil), we have nowhere left to go (not (cl-set-difference (doom-real-buffer-list)
(memq (switch-to-prev-buffer nil t) (list buf 'nil))) (doom-visible-buffers)))
(switch-to-buffer (doom-fallback-buffer))) ;; if we end up back where we start (or previous-buffer
(unless visible-p ;; returns nil), we have nowhere left to go
(with-current-buffer buf (memq (switch-to-prev-buffer nil t) (list buf 'nil)))
(restore-buffer-modified-p nil)) (switch-to-buffer (doom-fallback-buffer)))
(kill-buffer buf)) (unless visible-p
(run-hooks 'buffer-list-update-hook) (with-current-buffer buf
(restore-buffer-modified-p nil))
(kill-buffer buf)))
(run-hooks 'doom-switch-buffer-hook 'buffer-list-update-hook)
t))))) t)))))