feature/workspaces: fix counsel-projectile-switch-project actions

This commit is contained in:
Henrik Lissner 2018-02-06 13:50:26 -05:00
parent a2feac51b2
commit 1db29a951e
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 13 additions and 13 deletions

View file

@ -488,16 +488,7 @@ created."
(setq +workspaces--project-dir default-directory)) (setq +workspaces--project-dir default-directory))
;;;###autoload ;;;###autoload
(defun +workspaces|switch-counsel-project-action (project) (defun +workspaces|switch-to-project (&optional inhibit-prompt)
"A `counsel-projectile-switch-project-action' that creates a dedicated
workspace for a new project, before prompting to open a file."
(when persp-mode
(let ((+workspaces--project-dir project)
(inhibit-message t))
(+workspaces|switch-to-project))))
;;;###autoload
(defun +workspaces|switch-to-project ()
"Creates a workspace dedicated to a new project. If one already exists, switch "Creates a workspace dedicated to a new project. If one already exists, switch
to it. Should be hooked to `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)
@ -516,7 +507,8 @@ to it. Should be hooked to `projectile-after-switch-project-hook'."
(+workspace-switch new-name) (+workspace-switch new-name)
(unless persp-p (unless persp-p
(switch-to-buffer (doom-fallback-buffer))) (switch-to-buffer (doom-fallback-buffer)))
(doom-project-find-file +workspaces--project-dir) (unless inhibit-prompt
(doom-project-find-file +workspaces--project-dir))
(+workspace-message (+workspace-message
(format "Switched to '%s' in new workspace" new-name) (format "Switched to '%s' in new workspace" new-name)
'success))) 'success)))
@ -527,6 +519,14 @@ to it. Should be hooked to `projectile-after-switch-project-hook'."
;; Advice ;; Advice
;; ;;
;;;###autoload
(defun +workspaces*switch-counsel-project-action (project)
"A `counsel-projectile-switch-project-action' that creates a dedicated
workspace for a new project, before prompting to open a file."
(let ((+workspaces--project-dir project)
(inhibit-message t))
(+workspaces|switch-to-project 'inhibit-prompt)))
;;;###autoload ;;;###autoload
(defun +workspaces*autosave-real-buffers (orig-fn &rest args) (defun +workspaces*autosave-real-buffers (orig-fn &rest args)
"Don't autosave if no real buffers are open." "Don't autosave if no real buffers are open."

View file

@ -98,8 +98,8 @@ Uses `+workspaces-main' to determine the name of the main workspace."
(add-hook 'delete-frame-functions #'+workspaces|delete-associated-workspace) (add-hook 'delete-frame-functions #'+workspaces|delete-associated-workspace)
;; per-project workspaces ;; per-project workspaces
(setq projectile-switch-project-action #'+workspaces|set-project-action (setq projectile-switch-project-action #'+workspaces|set-project-action)
counsel-projectile-switch-project-action #'+workspaces|switch-counsel-project-action) (advice-add #'counsel-projectile-switch-project-by-name :before #'+workspaces*switch-counsel-project-action)
(add-hook 'projectile-after-switch-project-hook #'+workspaces|switch-to-project) (add-hook 'projectile-after-switch-project-hook #'+workspaces|switch-to-project)
;; ;;