Remove doom--cycle-real-buffers; refactor kill-this-buffer advice
cycle-real-buffers was a tidbit of complexity that was never necessary in the first place. This functionality was already available in the form of the frame buffer-predicate parameter, which controls where functions like next-buffer and other-buffer can land you. The only thing I have to do myself, is check for the condition where there are no more real buffers left to switch to, and in that case send you to the fallback-buffer.
This commit is contained in:
parent
ec7f20589a
commit
d1953e00c4
3 changed files with 10 additions and 53 deletions
|
@ -540,16 +540,20 @@ instead)."
|
|||
(not (eq (current-buffer) (doom-fallback-buffer))))
|
||||
|
||||
(defun doom*switch-to-fallback-buffer-maybe (orig-fn)
|
||||
"Advice for `kill-this-buffer'. If there are no real buffers left, switch to
|
||||
`doom-fallback-buffer'."
|
||||
"Advice for `kill-this-buffer'. If in a dedicated window, delete it. If there
|
||||
are no real buffers left, switch to `doom-fallback-buffer'. Otherwise, delegate
|
||||
to original `kill-this-buffer'."
|
||||
(let ((buf (current-buffer)))
|
||||
(cond ((window-dedicated-p)
|
||||
(delete-window))
|
||||
((doom-real-buffer-p buf)
|
||||
(previous-buffer)
|
||||
(doom--cycle-real-buffers
|
||||
(if (delq buf (doom-real-buffer-list)) -1))
|
||||
(kill-buffer buf))
|
||||
(or (kill-buffer buf)
|
||||
(previous-buffer))
|
||||
;; if there are no (real) buffers left to switch to, land on the
|
||||
;; fallback buffer.
|
||||
(unless (cl-set-difference (doom-real-buffer-list)
|
||||
(doom-visible-buffers))
|
||||
(switch-to-buffer (doom-fallback-buffer))))
|
||||
(t
|
||||
(funcall orig-fn)))))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue