Refactor doom-real-buffer-p

This commit is contained in:
Henrik Lissner 2017-02-08 02:18:31 -05:00
parent 3bf3a36e3a
commit f2944aca92

View file

@ -141,18 +141,21 @@ See `doom-real-buffer-p' for what 'real' means."
(switch-to-buffer destbuf))) (switch-to-buffer destbuf)))
;;;###autoload ;;;###autoload
(defun doom-real-buffer-p (&optional buffer) (defun doom-real-buffer-p (&optional buffer-or-name)
"Returns whether BUFFER a 'real' buffer or not. Real means: a) it isn't a "Returns t if BUFFER-OR-NAME is a 'real' buffer. Real means:
popup (or temporary) window and b) it isn't a special buffer (e.g. scratch or
*messages* buffer). See `doom-buffers-unreal-alist'." a) it isn't a popup (or temporary) window
(setq buffer (or (and (bufferp buffer) buffer) b) it isn't a special buffer (e.g. scratch or *messages* buffer)
(and (stringp buffer) (get-buffer buffer)) c) and its major-mode or buffer-name-matching regexp isn't in
(current-buffer))) `doom-buffers-unreal'."
(when (buffer-live-p buffer) (let ((buffer (window-normalize-buffer buffer-or-name)))
(with-current-buffer buffer (when (buffer-live-p buffer)
(not (or (apply #'derived-mode-p (-filter 'symbolp doom-buffers-unreal-alist)) (not (or (doom-popup-p (get-buffer-window buffer))
(--any? (string-match-p it (buffer-name buffer)) (eq (buffer-name buffer) doom-fallback-buffer)
(-filter 'stringp doom-buffers-unreal-alist))))))) (--any? (and (stringp it) (string-match-p it (buffer-name buffer)))
doom-buffers-unreal)
(with-current-buffer buffer
(apply 'derived-mode-p (-filter 'symbolp doom-buffers-unreal))))))))
;;;###autoload ;;;###autoload
(defun doom/next-buffer () (defun doom/next-buffer ()