Fix save-buffer prompt occurring after buffer is buried

This commit is contained in:
Henrik Lissner 2018-02-11 03:58:57 -05:00
parent 24bf471f55
commit 4566dea4b3
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -554,15 +554,18 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original
((eq buf (doom-fallback-buffer))
(message "Can't kill the fallback buffer."))
((doom-real-buffer-p buf)
(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)))
;; if we end up back where we start (or previous-buffer
;; returns nil), we have nowhere left to go
(memq (previous-buffer) (list buf 'nil)))
(switch-to-buffer (doom-fallback-buffer)))
(kill-buffer buf))
(if (and (buffer-modified-p buf)
(not (y-or-n-p "Buffer %s is modified; kill anyway?")))
(message "Aborted")
(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)))
;; if we end up back where we start (or previous-buffer
;; returns nil), we have nowhere left to go
(memq (previous-buffer) (list buf 'nil)))
(switch-to-buffer (doom-fallback-buffer)))
(kill-buffer buf)))
(t
(funcall orig-fn)))))