diff options
author | David Morgan <djm_uk@protonmail.com> | 2021-10-05 08:07:10 +0100 |
---|---|---|
committer | David Morgan <djm_uk@protonmail.com> | 2021-10-05 08:07:10 +0100 |
commit | 8420a8cb9b6db70b45db126194129e179990ee49 (patch) | |
tree | 9591af767e88a2b9cedd2090676a84d94bb590f6 /.emacs.d/lisp | |
parent | 96c97971ed6471272b2b197e234ad493e6ab1214 (diff) | |
download | dotfiles-8420a8cb9b6db70b45db126194129e179990ee49.tar.gz |
Add persp-current-project-root
Diffstat (limited to '.emacs.d/lisp')
-rw-r--r-- | .emacs.d/lisp/init-minibuffer.el | 7 | ||||
-rw-r--r-- | .emacs.d/lisp/init-project.el | 6 |
2 files changed, 7 insertions, 6 deletions
diff --git a/.emacs.d/lisp/init-minibuffer.el b/.emacs.d/lisp/init-minibuffer.el index 3b01339..57f617c 100644 --- a/.emacs.d/lisp/init-minibuffer.el +++ b/.emacs.d/lisp/init-minibuffer.el @@ -280,12 +280,7 @@ DEFS is a plist associating completion categories to commands." (setq consult-narrow-key "<") - (setq consult-project-root-function - (lambda () - (if-let (project (project-current)) - (project-root project) - (when-let (persp (persp-name (persp-curr))) - (car (seq-filter (lambda (pr) (string-match-p persp pr)) (project-known-project-roots))))))) + (setq consult-project-root-function #'persp-current-project-root) ;; Switches perspective if we select a buffer from another perspective, but note that previewing ;; a buffer adds it to the current perspective, so preview should be disabled before removing diff --git a/.emacs.d/lisp/init-project.el b/.emacs.d/lisp/init-project.el index a8dd2eb..100f9bf 100644 --- a/.emacs.d/lisp/init-project.el +++ b/.emacs.d/lisp/init-project.el @@ -84,6 +84,12 @@ (persp-buffers-in-mode (seq-filter mode-pred persp-buffers))) (when (not (seq-empty-p persp-buffers-in-mode)) (switch-to-buffer (car persp-buffers-in-mode))))) + (defun persp-current-project-root () + "Return the current project root, falling back to finding it using the perpsective" + (if-let (project (project-current)) + (project-root project) + (when-let (persp (persp-name (persp-curr))) + (car (seq-filter (lambda (pr) (string-match-p persp pr)) (project-known-project-roots)))))) (defun switch-project (proj) "Switch to project or already open project perspective." (interactive (list (project-prompt-project-dir))) |