about summary refs log tree commit diff stats
path: root/.emacs.d
diff options
context:
space:
mode:
Diffstat (limited to '.emacs.d')
-rw-r--r--.emacs.d/lisp/init-minibuffer.el7
-rw-r--r--.emacs.d/lisp/init-project.el6
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)))