Fix new workspace when switching projects #314

This commit is contained in:
Henrik Lissner 2017-12-30 01:18:41 -05:00
parent 707b69540d
commit b6eec664bb
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 15 additions and 4 deletions

View file

@ -51,7 +51,6 @@ immediately runs it on the current candidate (ending the ivy session)."
[remap recentf-open-files] #'counsel-recentf
[remap imenu] #'counsel-imenu
[remap bookmark-jump] #'counsel-bookmark
[remap projectile-switch-project] #'counsel-projectile-switch-project
[remap projectile-find-file] #'counsel-projectile-find-file
[remap imenu-anywhere] #'ivy-imenu-anywhere
[remap execute-extended-command] #'counsel-M-x

View file

@ -47,10 +47,22 @@ renamed.")
;; per-frame and per-project workspaces
(setq persp-init-new-frame-behaviour-override nil
persp-interactive-init-frame-behaviour-override #'+workspace-on-new-frame
projectile-switch-project-action #'projectile-find-file)
persp-interactive-init-frame-behaviour-override #'+workspace-on-new-frame)
(add-hook 'delete-frame-functions #'+workspaces|delete-associated-workspace-maybe)
(advice-add #'projectile-switch-project-by-name :around #'+workspaces*switch-project-by-name)
(defun +workspaces|per-project (&optional root)
"Open a new workspace when switching to another project.
Ensures the scratch (or dashboard) buffers are CDed into the project's root."
(when persp-mode
(let ((cwd default-directory))
(+workspace-switch (projectile-project-name) t)
(switch-to-buffer (doom-fallback-buffer))
(setq default-directory cwd)
(+workspace-message
(format "Switched to '%s' in new workspace" (+workspace-current-name))
'success))))
(setq projectile-switch-project-action #'+workspaces|per-project)
;; only auto-save when real buffers are present
(advice-add #'persp-asave-on-exit :around #'+workspaces*autosave-real-buffers)