diff --git a/lisp/doom-ui.el b/lisp/doom-ui.el index e452b22de..7ef918cfa 100644 --- a/lisp/doom-ui.el +++ b/lisp/doom-ui.el @@ -225,7 +225,7 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original (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))) + (doom-visible-buffers nil t))) ;; if we end up back where we start (or previous-buffer ;; returns nil), we have nowhere left to go (memq (switch-to-prev-buffer nil t) (list buf 'nil))) diff --git a/lisp/lib/buffers.el b/lisp/lib/buffers.el index 5354b2002..93816f6dc 100644 --- a/lisp/lib/buffers.el +++ b/lisp/lib/buffers.el @@ -179,9 +179,13 @@ If DERIVED-P, test with `derived-mode-p', otherwise use `eq'." collect window)) ;;;###autoload -(defun doom-visible-buffers (&optional buffer-list) +(defun doom-visible-buffers (&optional buffer-list all-frames) "Return a list of visible buffers (i.e. not buried)." - (let ((buffers (delete-dups (mapcar #'window-buffer (window-list))))) + (let ((buffers + (delete-dups + (cl-loop for frame in (if all-frames (visible-frame-list) (list (selected-frame))) + if (window-list frame) + nconc (mapcar #'window-buffer it))))) (if buffer-list (cl-delete-if (lambda (b) (memq b buffer-list)) buffers)