Add persp-current-project-root
This commit is contained in:
parent
96c97971ed
commit
8420a8cb9b
|
@ -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
|
||||
|
|
|
@ -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)))
|
||||
|
|
Loading…
Reference in New Issue