Made doom-real-buffer-p flexible w/ doom-real-buffer-functions

This commit is contained in:
Henrik Lissner 2017-03-06 19:07:41 -05:00
parent a2ca5fb446
commit 24604d5495

View file

@ -3,6 +3,10 @@
(defvar-local doom-buffer--narrowed-origin nil) (defvar-local doom-buffer--narrowed-origin nil)
;;;###autoload
(defvar doom-real-buffer-functions '()
"A list of functions that are run to determine if a buffer is real.")
;;;###autoload ;;;###autoload
(defvar doom-fallback-buffer "*scratch*" (defvar doom-fallback-buffer "*scratch*"
"The name of the buffer to fall back to if no other buffers exist (will create "The name of the buffer to fall back to if no other buffers exist (will create
@ -120,9 +124,10 @@ buffers. If there's nothing left, switch to `doom-fallback-buffer'. See
(defun doom-real-buffer-p (&optional buffer-or-name) (defun doom-real-buffer-p (&optional buffer-or-name)
"Returns t if BUFFER-OR-NAME is a 'real' buffer. Real means it a) isn't a "Returns t if BUFFER-OR-NAME is a 'real' buffer. Real means it a) isn't a
popup window/buffer and b) isn't a special buffer." popup window/buffer and b) isn't a special buffer."
(when-let (buffer (ignore-errors (window-normalize-buffer buffer-or-name))) (let ((buf (window-normalize-buffer buffer-or-name)))
(not (or (doom-popup-p buffer) (or (run-hook-with-args-until-success 'doom-real-buffer-functions buf)
(string-match-p "^ ?\\*" (buffer-name buffer)))))) (not (or (doom-popup-p buf)
(string-match-p "^\\s-*\\*" (buffer-name buf)))))))
;;;###autoload ;;;###autoload
(defun doom/next-buffer () (defun doom/next-buffer ()