diff --git a/bufferlo.el b/bufferlo.el index e37ae9b..f62a1df 100644 --- a/bufferlo.el +++ b/bufferlo.el @@ -1057,10 +1057,12 @@ string, FACE is the face for STR." (when (eq bufferlo-prefer-local-buffers 'tabs) (bufferlo--set-switch-to-prev-buffer-skip)) ;; Include/exclude buffers - (add-hook 'after-make-frame-functions - #'bufferlo--include-exclude-buffers) (add-hook 'tab-bar-tab-post-open-functions #'bufferlo--tab-include-exclude-buffers) + (add-hook 'before-make-frame-hook + #'bufferlo--tab-include-exclude-buffers-inhibit) + (add-hook 'after-make-frame-functions + #'bufferlo--include-exclude-buffers) ;; Save/restore local buffer list (advice-add #'window-state-get :around #'bufferlo--window-state-get) (advice-add #'window-state-put :after #'bufferlo--window-state-put) @@ -1113,10 +1115,12 @@ string, FACE is the face for STR." (bufferlo--reset-switch-to-prev-buffer-skip)) (remove-hook 'after-make-frame-functions #'bufferlo--set-buffer-predicate) ;; Include/exclude buffers - (remove-hook 'after-make-frame-functions - #'bufferlo--include-exclude-buffers) (remove-hook 'tab-bar-tab-post-open-functions #'bufferlo--tab-include-exclude-buffers) + (remove-hook 'before-make-frame-hook + #'bufferlo--tab-include-exclude-buffers-inhibit) + (remove-hook 'after-make-frame-functions + #'bufferlo--include-exclude-buffers) ;; Save/restore local buffer list (advice-remove #'window-state-get #'bufferlo--window-state-get) (advice-remove #'window-state-put #'bufferlo--window-state-put) @@ -1388,6 +1392,7 @@ Includes hidden buffers." (defun bufferlo--include-exclude-buffers (frame) "Include and exclude buffers from the local buffer list of FRAME." + (bufferlo--tab-include-exclude-buffers-inhibit 'uninhibit) (let* ((include (bufferlo--merge-regexp-list (append '("a^") bufferlo-include-buffer-filters))) (exclude (bufferlo--merge-regexp-list @@ -1411,13 +1416,28 @@ Includes hidden buffers." buffers)) (set-frame-parameter frame 'buried-buffer-list nil))) +(defvar bufferlo--tab-include-exclude-buffers-inhibit nil + "Set to non-nil during `make-frame'. +This inhibits `bufferlo--tab-include-exclude-buffers' and is reset by +`bufferlo--include-exclude-buffers'. This cannot be let-bound unless we +advise `make-frame'.") + +(defun bufferlo--tab-include-exclude-buffers-inhibit (&optional uninhibit) + "Inhibit `bufferlo--tab-include-exclude-buffers' during make-frame. +`bufferlo--include-exclude-buffers' will be run by +`after-make-frame-functions'. + +If optional argument UNINHIBIT is non-nil, the inhibition is disabled." + (setq bufferlo--tab-include-exclude-buffers-inhibit (not uninhibit))) + (defun bufferlo--tab-include-exclude-buffers (ignore) "Include and exclude buffers from the buffer list of the current tab's frame. Argument IGNORE is for compatibility with `tab-bar-tab-post-open-functions'." (ignore ignore) ;; Reset the local buffer list unless we clone the tab (tab-duplicate). - (unless (eq tab-bar-new-tab-choice 'clone) - (bufferlo--include-exclude-buffers nil))) + (unless bufferlo--tab-include-exclude-buffers-inhibit + (unless (eq tab-bar-new-tab-choice 'clone) + (bufferlo--include-exclude-buffers nil)))) (defun bufferlo--current-buffers (frame) "Get the buffers of the current tab in FRAME."