Skip to content

Project support

Multiple Consult search commands like ‘consult-grep’ try to discover the current project and search in the project top level directory by default, if a project is found. Otherwise they fall back to the ‘default-directory’. By default, Consult uses the Emacs built-in project discovery support (‘project-current’ and ‘project-root’). It is possible to configure alternative methods via the customization variable ‘consult-project-function’.

emacs-lisp
;; Optionally configure a different project root function.
;; 1. project.el (the default)
(setq consult-project-function #'consult--default-project--function)
;; 2. vc.el (vc-root-dir)
(setq consult-project-function (lambda (_) (vc-root-dir)))
;; 3. locate-dominating-file
(setq consult-project-function (lambda (_) (locate-dominating-file "." ".git")))
;; 4. projectile.el (projectile-project-root)
(autoload 'projectile-project-root "projectile")
(setq consult-project-function (lambda (_) (projectile-project-root)))
;; 5. Disable project support
(setq consult-project-function nil)