diff --git a/modules/feature/workspaces/autoload/workspaces.el b/modules/feature/workspaces/autoload/workspaces.el index 85f45306c..9308c738c 100644 --- a/modules/feature/workspaces/autoload/workspaces.el +++ b/modules/feature/workspaces/autoload/workspaces.el @@ -484,17 +484,6 @@ the next." ;; Hooks ;; -;;;###autoload -(defun +workspaces|auto-add-buffer () - "Auto-associate buffers with perspectives upon opening them. - -Allows a perspective-specific buffer list via `+workspaces-buffer-list'." - (when (and persp-mode - (not persp-temporarily-display-buffer) - (doom-real-buffer-p)) - (persp-add-buffer (current-buffer) (get-current-persp) nil) - (force-mode-line-update t))) - ;;;###autoload (defun +workspaces|delete-associated-workspace (&optional frame) "Delete workspace associated with current frame. diff --git a/modules/feature/workspaces/config.el b/modules/feature/workspaces/config.el index 5f5e9f005..d751fc4d6 100644 --- a/modules/feature/workspaces/config.el +++ b/modules/feature/workspaces/config.el @@ -93,6 +93,12 @@ Uses `+workspaces-main' to determine the name of the main workspace." persp-auto-resume-time -1 ; Don't auto-load on startup persp-auto-save-opt (if noninteractive 0 1)) ; auto-save on kill + ;; Ensure buffers we've opened/switched to are auto-added to the current + ;; perspective + (setq persp-add-buffer-on-find-file t + persp-add-buffer-on-after-change-major-mode t) + (add-hook 'persp-add-buffer-on-after-change-major-mode-filter-functions #'doom-unreal-buffer-p) + ;; bootstrap (defun +workspaces|init-persp-mode () (cond (persp-mode @@ -100,17 +106,10 @@ Uses `+workspaces-main' to determine the name of the main workspace." ;; kill-buffer-query-functions (remove-hook 'kill-buffer-query-functions 'persp-kill-buffer-query-function) (add-hook 'kill-buffer-query-functions 'persp-kill-buffer-query-function t) - - ;; Ensure buffers we've opened/switched to are auto-added to the - ;; current perspective - (add-hook 'doom-after-switch-buffer-hook #'+workspaces|auto-add-buffer) - ;; Remap `buffer-list' to current workspace's buffers in ;; `doom-buffer-list' (advice-add #'doom-buffer-list :override #'+workspace-buffer-list)) - (t - (remove-hook 'doom-after-switch-buffer-hook #'+workspaces|auto-add-buffer) - (advice-remove #'doom-buffer-list #'+workspace-buffer-list)))) + ((advice-remove #'doom-buffer-list #'+workspace-buffer-list)))) (add-hook 'persp-mode-hook #'+workspaces|init-persp-mode) (defun +workspaces|leave-nil-perspective (&rest _) diff --git a/modules/feature/workspaces/test/test-workspaces.el b/modules/feature/workspaces/test/test-workspaces.el index c04cc7a56..4e50901da 100644 --- a/modules/feature/workspaces/test/test-workspaces.el +++ b/modules/feature/workspaces/test/test-workspaces.el @@ -79,10 +79,6 @@ (expect (+workspace-contains-buffer-p in1))) (it "returns nil for buffers outside of current workspace" (expect (+workspace-contains-buffer-p out1) :to-be nil)) - (it "automatically adds interactively opened buffers" - (expect (+workspace-contains-buffer-p out1) :to-be nil) - (with-current-buffer out1 (+workspaces|auto-add-buffer)) - (expect (+workspace-contains-buffer-p out1))) (xit "returns a list of orphaned buffers" (expect (+workspace-orphaned-buffer-list) :to-contain out2)))