minad / consult

:mag: consult.el - Consulting completing-read
GNU General Public License v3.0
1.12k stars 98 forks source link

Support project.el external roots #972

Closed fargiolas closed 1 month ago

fargiolas commented 1 month ago

Probably not so popular in this monorepo days but project.el supports setting one or more external roots to grep and find files into just like if they belonged to the main project. See project-or-external-find-file and project-or-external-find-regexp .

It would be nice if consult would honor this setting and extend find and grep commands to external roots if set.

This is mostly an enhancement, at the moment I'm getting the desired effect with (this actually discards the dir argument but works for me as I'm using it only for projects anyway):

(defun fa/consult-ripgrep (&optional dir initial)
  (interactive "P")
  (let ((dirs (append (list (consult--project-root))
                      (project-external-roots (project-current)))))
    (consult--grep "Ripgrep" #'consult--ripgrep-make-builder dirs initial)))

(defun fa/consult-fd (&optional dir initial)
  (interactive "P")
  (let ((dirs (append (list (consult--project-root))
                      (project-external-roots (project-current)))))
    (consult-fd dirs initial)))