From 537cc9e1ed663c387fa87a0699f55aae4d5de64b Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sat, 30 Jun 2018 01:55:07 +0200 Subject: [PATCH] Rewrite doom-real-buffer-p; require first arg Because of how widely used this function is, I'd rather it be as explicit as possible to avoid bugs and to make it faster. --- core/autoload/buffers.el | 7 +++++-- modules/feature/workspaces/autoload/workspaces.el | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/core/autoload/buffers.el b/core/autoload/buffers.el index cc390b6a9..f1050c72a 100644 --- a/core/autoload/buffers.el +++ b/core/autoload/buffers.el @@ -93,7 +93,7 @@ If no project is active, return all buffers." (cl-remove-if-not #'doom-real-buffer-p (or buffer-list (doom-buffer-list)))) ;;;###autoload -(defun doom-real-buffer-p (&optional buffer-or-name) +(defun doom-real-buffer-p (buffer-or-name) "Returns t if BUFFER-OR-NAME is a 'real' buffer. A real buffer is a useful buffer; a first class citizen in Doom. Real ones @@ -110,7 +110,10 @@ The exact criteria for a real buffer is: non-nil. If BUFFER-OR-NAME is omitted or nil, the current buffer is tested." - (when-let* ((buf (ignore-errors (window-normalize-buffer buffer-or-name)))) + (or (bufferp buffer-or-name) + (stringp buffer-or-name) + (signal 'wrong-type-argument (list '(bufferp stringp) buffer-or-name))) + (when-let* ((buf (get-buffer buffer-or-name))) (and (not (doom-temp-buffer-p buf)) (or (buffer-local-value 'doom-real-buffer-p buf) (run-hook-with-args-until-success 'doom-real-buffer-functions buf) diff --git a/modules/feature/workspaces/autoload/workspaces.el b/modules/feature/workspaces/autoload/workspaces.el index 0b2adabaa..85f45306c 100644 --- a/modules/feature/workspaces/autoload/workspaces.el +++ b/modules/feature/workspaces/autoload/workspaces.el @@ -524,7 +524,7 @@ created." (if (not (persp-frame-list-without-daemon)) (+workspace-switch +workspaces-main t) (+workspace-switch (format "#%s" (+workspace--generate-id)) t) - (unless (doom-real-buffer-p) + (unless (doom-real-buffer-p (current-buffer)) (switch-to-buffer (doom-fallback-buffer))) (set-frame-parameter frame 'workspace (+workspace-current-name)) ;; ensure every buffer has a buffer-predicate