diff --git a/modules/feature/workspaces/autoload/workspaces.el b/modules/feature/workspaces/autoload/workspaces.el index 8a55d622c..1c96a7143 100644 --- a/modules/feature/workspaces/autoload/workspaces.el +++ b/modules/feature/workspaces/autoload/workspaces.el @@ -549,7 +549,9 @@ This be hooked to `projectile-after-switch-project-hook'." (setq +workspaces--project-dir dir)) (when (and persp-mode +workspaces--project-dir) (unwind-protect - (if (+workspace-buffer-list) + (if (and (not (null +workspaces-on-switch-project-behavior)) + (or (eq +workspaces-on-switch-project-behavior t) + (+workspace-buffer-list))) (let* (persp-p (persp (let ((project-name (doom-project-name +workspaces--project-dir))) diff --git a/modules/feature/workspaces/config.el b/modules/feature/workspaces/config.el index f6df57581..a42f7e62e 100644 --- a/modules/feature/workspaces/config.el +++ b/modules/feature/workspaces/config.el @@ -25,6 +25,16 @@ new project directory.") "The basename of the file to store single workspace perspectives. Will be stored in `persp-save-dir'.") +(defvar +workspaces-on-switch-project-behavior 'non-empty + "Controls the behavior of workspaces when switching to a new project. + +Can be one of the following: + +t Always create a new workspace for the project +'non-empty Only create a new workspace if the current one has no buffers + associated with it. +nil Never create a new workspace on project switch.") + ;; If emacs is passed --restore, restore the last session on startup. This is ;; used by the `+workspace/restart-emacs-then-restore' command. (defun +workspaces-restore-last-session (&rest _)