And prevent explicit projectile-project-root interfering with project switching.
This commit is contained in:
parent
db25224e18
commit
60ca118eb2
2 changed files with 40 additions and 53 deletions
|
@ -525,42 +525,46 @@ the user to open a file in the new project.
|
|||
This be hooked to `projectile-after-switch-project-hook'."
|
||||
(when dir
|
||||
(setq +workspaces--project-dir dir))
|
||||
(when (and persp-mode +workspaces--project-dir)
|
||||
(when projectile-before-switch-project-hook
|
||||
(with-temp-buffer
|
||||
;; Load the project dir-local variables into the switch buffer, so the
|
||||
;; action can make use of them
|
||||
(setq default-directory +workspaces--project-dir)
|
||||
(hack-dir-local-variables-non-file-buffer)
|
||||
(run-hooks 'projectile-before-switch-project-hook)))
|
||||
(unwind-protect
|
||||
(if (and (not (null +workspaces-on-switch-project-behavior))
|
||||
(or (eq +workspaces-on-switch-project-behavior t)
|
||||
(equal (safe-persp-name (get-current-persp)) persp-nil-name)
|
||||
(+workspace-buffer-list)))
|
||||
(let* ((persp
|
||||
(let ((project-name (doom-project-name +workspaces--project-dir)))
|
||||
(or (+workspace-get project-name t)
|
||||
(+workspace-new project-name))))
|
||||
(new-name (persp-name persp)))
|
||||
(+workspace-switch new-name)
|
||||
(with-current-buffer (doom-fallback-buffer)
|
||||
(setq default-directory +workspaces--project-dir))
|
||||
(unless current-prefix-arg
|
||||
(funcall +workspaces-switch-project-function +workspaces--project-dir))
|
||||
(+workspace-message
|
||||
(format "Switched to '%s' in new workspace" new-name)
|
||||
'success))
|
||||
(with-current-buffer (doom-fallback-buffer)
|
||||
(setq default-directory +workspaces--project-dir)
|
||||
(hack-dir-local-variables-non-file-buffer)
|
||||
(message "Switched to '%s'" (doom-project-name +workspaces--project-dir)))
|
||||
(with-demoted-errors "Workspace error: %s"
|
||||
(+workspace-rename (+workspace-current-name) (doom-project-name +workspaces--project-dir)))
|
||||
(unless current-prefix-arg
|
||||
(funcall +workspaces-switch-project-function +workspaces--project-dir)))
|
||||
(run-hooks 'projectile-after-switch-project-hook)
|
||||
(setq +workspaces--project-dir nil))))
|
||||
;; HACK Clear projectile-project-root, otherwise cached roots may interfere
|
||||
;; with project switch (see #3166)
|
||||
(let (projectile-project-root)
|
||||
(when (and persp-mode +workspaces--project-dir)
|
||||
(when projectile-before-switch-project-hook
|
||||
(with-temp-buffer
|
||||
;; Load the project dir-local variables into the switch buffer, so the
|
||||
;; action can make use of them
|
||||
(setq default-directory +workspaces--project-dir)
|
||||
(hack-dir-local-variables-non-file-buffer)
|
||||
(run-hooks 'projectile-before-switch-project-hook)))
|
||||
(unwind-protect
|
||||
(if (and (not (null +workspaces-on-switch-project-behavior))
|
||||
(or (eq +workspaces-on-switch-project-behavior t)
|
||||
(equal (safe-persp-name (get-current-persp)) persp-nil-name)
|
||||
(+workspace-buffer-list)))
|
||||
(let* ((persp
|
||||
(let ((project-name (doom-project-name +workspaces--project-dir)))
|
||||
(or (+workspace-get project-name t)
|
||||
(+workspace-new project-name))))
|
||||
(new-name (persp-name persp)))
|
||||
(+workspace-switch new-name)
|
||||
(with-current-buffer (doom-fallback-buffer)
|
||||
(setq default-directory +workspaces--project-dir)
|
||||
(hack-dir-local-variables-non-file-buffer))
|
||||
(unless current-prefix-arg
|
||||
(funcall +workspaces-switch-project-function +workspaces--project-dir))
|
||||
(+workspace-message
|
||||
(format "Switched to '%s' in new workspace" new-name)
|
||||
'success))
|
||||
(with-current-buffer (doom-fallback-buffer)
|
||||
(setq default-directory +workspaces--project-dir)
|
||||
(hack-dir-local-variables-non-file-buffer)
|
||||
(message "Switched to '%s'" (doom-project-name +workspaces--project-dir)))
|
||||
(with-demoted-errors "Workspace error: %s"
|
||||
(+workspace-rename (+workspace-current-name) (doom-project-name +workspaces--project-dir)))
|
||||
(unless current-prefix-arg
|
||||
(funcall +workspaces-switch-project-function +workspaces--project-dir)))
|
||||
(run-hooks 'projectile-after-switch-project-hook)
|
||||
(setq +workspaces--project-dir nil)))))
|
||||
|
||||
|
||||
;;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue