feature/workspaces: fix switch-project #388

+ Fix recursive find-file-in-project prompt with counsel-projectile.
+ Fix duplicate-workspace error (just switches to that workspace, rather
  than trying to create one).
+ Fix dashboard replacing current buffer when switching to
  a pre-existing project workspace.
This commit is contained in:
Henrik Lissner 2018-01-31 04:54:42 -05:00
parent c52cb38385
commit c97c460ce2
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -490,30 +490,32 @@ workspace for a new project, before prompting to open a file."
(when persp-mode (when persp-mode
(let ((+workspaces--project-dir project) (let ((+workspaces--project-dir project)
(inhibit-message t)) (inhibit-message t))
(+workspaces|switch-to-project))) (+workspaces|switch-to-project))))
(counsel-projectile-switch-project-action project)
(+workspace-message
(format "Switched to '%s' in new workspace" new-name)
'success))
;;;###autoload ;;;###autoload
(defun +workspaces|switch-to-project () (defun +workspaces|switch-to-project ()
"Creates a workspace dedicated to a new project. Should be hooked to "Creates a workspace dedicated to a new project. If one already exists, switch
`projectile-after-switch-project-hook'." to it. Should be hooked to `projectile-after-switch-project-hook'."
(when (and persp-mode +workspaces--project-dir) (when (and persp-mode +workspaces--project-dir)
(unwind-protect (unwind-protect
(let* ((persp (let (persp-p)
(let ((default-directory +workspaces--project-dir)) (let* ((persp
(+workspace-new (projectile-project-name)))) (let* ((default-directory +workspaces--project-dir)
(new-name (persp-name persp))) projectile-project-name
(+workspace-switch new-name) projectile-require-project-root
(switch-to-buffer (doom-fallback-buffer)) projectile-cached-buffer-file-name
(call-interactively projectile-cached-project-root
(or (command-remapping #'projectile-find-file) (project-name (projectile-project-name)))
#'projectile-find-file)) (or (setq persp-p (+workspace-get project-name t))
(+workspace-message (+workspace-new project-name))))
(format "Switched to '%s' in new workspace" new-name) (new-name (persp-name persp)))
'success)) (+workspace-switch new-name)
(unless persp-p
(switch-to-buffer (doom-fallback-buffer)))
(doom-project-find-file +workspaces--project-dir)
(+workspace-message
(format "Switched to '%s' in new workspace" new-name)
'success)))
(setq +workspaces--project-dir nil)))) (setq +workspaces--project-dir nil))))