From 9cb55368183b54039b083c5fc75c3d9d869e297c Mon Sep 17 00:00:00 2001 From: Bozhidar Batsov Date: Thu, 3 Dec 2020 11:14:04 +0200 Subject: Rename projectile-project-root-files-functions to projectile-project-root-functions --- doc/modules/ROOT/pages/projects.adoc | 12 ++++++------ projectile.el | 11 ++++++++--- test/projectile-test.el | 32 ++++++++++++++++---------------- 3 files changed, 30 insertions(+), 25 deletions(-) diff --git a/doc/modules/ROOT/pages/projects.adoc b/doc/modules/ROOT/pages/projects.adoc index 4e523f9..e04a628 100644 --- a/doc/modules/ROOT/pages/projects.adoc +++ b/doc/modules/ROOT/pages/projects.adoc @@ -16,7 +16,7 @@ While Projectile aims to recognize most project types out-of-the-box, it's also flexible configuration-wise, and you can easily alter the project detection logic. TIP: If you'd like to override the default project detection functions you should -check out `projectile-project-root-files-functions`. We'll discuss how to tweak in more +check out `projectile-project-root-functions`. We'll discuss how to tweak in more details later in the documentation. === Version Control Systems @@ -438,17 +438,17 @@ Each helper means `projectile-related-files-fn-helper-name` function. Project detection is pretty simple - Projectile just runs a list of project detection functions -(`projectile-project-root-files-functions`) until one of them returns +(`projectile-project-root-functions`) until one of them returns a project directory. This list of functions is customizable, and while Projectile has some defaults for it, you can tweak it however you see fit. -Let's take a closer look at `projectile-project-root-files-functions`: +Let's take a closer look at `projectile-project-root-functions`: [source,elisp] ---- -(defcustom projectile-project-root-files-functions +(defcustom projectile-project-root-functions '(projectile-root-local projectile-root-bottom-up projectile-root-top-down @@ -464,7 +464,7 @@ precedence with respect to project detection. Let's examine the defaults: * `projectile-root-local` looks for project path set via the buffer-local variable `projectile-project-root`. Typically you'd set this variable via `.dir-locals.el` and it will take precedence over everything else. -* `projectile-root-bottom-up` will start looking for a project marker file/folder(e.g. `.projectile`, `.hg`, `.git`) from the current folder (a.k.a. `default-directory` in Emacs lingo) up the directory tree. It will return the first match it discovers. The assumption is pretty simple - the root marker appear only once, at the root folder of a project. If a root marker appear in several nested folders (e.g. you've got nested git projects), the bottom-most (closest to the current dir) match has precedence. You can customize the root markers recognized by this function via `projectile-project-root-files-functions` +* `projectile-root-bottom-up` will start looking for a project marker file/folder(e.g. `.projectile`, `.hg`, `.git`) from the current folder (a.k.a. `default-directory` in Emacs lingo) up the directory tree. It will return the first match it discovers. The assumption is pretty simple - the root marker appear only once, at the root folder of a project. If a root marker appear in several nested folders (e.g. you've got nested git projects), the bottom-most (closest to the current dir) match has precedence. You can customize the root markers recognized by this function via `projectile-project-root-functions` * `projectile-root-top-down` is similar, but it will return the top-most (farthest from the current directory) match. It's configurable via `projectile-project-root-files` and all project manifest markers like `pom.xml`, `Gemfile`, `project.clj`, etc go there. @@ -482,7 +482,7 @@ Re-ordering those functions will alter the project detection, but you can also r (let ((default-directory dir)) (vc-root-dir))) -(setq projectile-project-root-files-functions '(projectile-vc-root-dir)) +(setq projectile-project-root-functions '(projectile-vc-root-dir)) ---- == Ignoring files diff --git a/projectile.el b/projectile.el index e9f0e87..b31d10e 100644 --- a/projectile.el +++ b/projectile.el @@ -342,12 +342,17 @@ containing a root file." :group 'projectile :type '(repeat string)) -(defcustom projectile-project-root-files-functions +(define-obsolete-variable-alias 'projectile-project-root-files-functions 'projectile-project-root-functions "2.4") + +(defcustom projectile-project-root-functions '(projectile-root-local projectile-root-bottom-up projectile-root-top-down projectile-root-top-down-recurring) - "A list of functions for finding project roots." + "A list of functions for finding project root folders. +The functions will be ran until one of them returns a project folder. +Reordering the default functions will alter the project discovery +algorithm." :group 'projectile :type '(repeat function)) @@ -1125,7 +1130,7 @@ If DIR is not supplied its set to the current directory by default." (let ((value (funcall func (file-truename dir)))) (puthash cache-key value projectile-project-root-cache) value)))) - projectile-project-root-files-functions))) + projectile-project-root-functions))) ;; set cached to none so is non-nil so we don't try ;; and look it up again 'none)))) diff --git a/test/projectile-test.el b/test/projectile-test.el index 4c926a0..4d63585 100644 --- a/test/projectile-test.el +++ b/test/projectile-test.el @@ -481,16 +481,16 @@ You'd normally combine this with `projectile-test-with-sandbox'." (let ((projectile-project-root-files-bottom-up '("somefile" ".projectile")) (projectile-project-root-files '("otherfile" "framework.conf" "requirements.txt")) (projectile-project-root-files-top-down-recurring '(".svn" ".foo")) - (projectile-project-root-files-functions '(projectile-root-bottom-up - projectile-root-top-down - projectile-root-top-down-recurring))) + (projectile-project-root-functions '(projectile-root-bottom-up + projectile-root-top-down + projectile-root-top-down-recurring))) (projectile-test-should-root-in "projectA" "projectA/requirements/a/b/c/d/e/f/g") (projectile-test-should-root-in "projectA" "projectA/src/framework/lib") (projectile-test-should-root-in "projectA" "projectA/src/html") - (setq projectile-project-root-files-functions '(projectile-root-top-down - projectile-root-top-down-recurring - projectile-root-bottom-up)) + (setq projectile-project-root-functions '(projectile-root-top-down + projectile-root-top-down-recurring + projectile-root-bottom-up)) (projectile-test-should-root-in "projectA/requirements/a/b/c" "projectA/requirements/a/b/c/d/e/f/g") (projectile-test-should-root-in "projectA/src/framework" @@ -501,9 +501,9 @@ You'd normally combine this with `projectile-test-with-sandbox'." (let ((projectile-project-root-files-bottom-up '("somefile" ".projectile")) (projectile-project-root-files '("otherfile" "noframework.conf")) (projectile-project-root-files-top-down-recurring '(".svn" ".foo")) - (projectile-project-root-files-functions '(projectile-root-top-down-recurring - projectile-root-bottom-up - projectile-root-top-down))) + (projectile-project-root-functions '(projectile-root-top-down-recurring + projectile-root-bottom-up + projectile-root-top-down))) (projectile-test-should-root-in "projectA/src" "projectA/src/framework/lib") (projectile-test-should-root-in "projectA/src" "projectA/src/html") (projectile-test-should-root-in "projectA/" "projectA/build/framework/lib")) @@ -511,18 +511,18 @@ You'd normally combine this with `projectile-test-with-sandbox'." (let ((projectile-project-root-files-bottom-up '("somefile" "override")) (projectile-project-root-files '("otherfile" "anotherfile")) (projectile-project-root-files-top-down-recurring '("someotherfile" "yetanotherfile")) - (projectile-project-root-files-functions '(projectile-root-bottom-up - projectile-root-top-down - projectile-root-top-down-recurring))) + (projectile-project-root-functions '(projectile-root-bottom-up + projectile-root-top-down + projectile-root-top-down-recurring))) (projectile-test-should-root-in default-directory "projectA/src/framework/lib") (projectile-test-should-root-in default-directory "projectA/src/html")) (let ((projectile-project-root-files-bottom-up '("somecoolfile")) (projectile-project-root-files nil) (projectile-project-root-files-top-down-recurring '(".svn")) - (projectile-project-root-files-functions '(projectile-root-bottom-up - projectile-root-top-down - projectile-root-top-down-recurring))) + (projectile-project-root-functions '(projectile-root-bottom-up + projectile-root-top-down + projectile-root-top-down-recurring))) (projectile-test-should-root-in "projectA/src/" "projectA/src/") (projectile-test-should-root-in "projectA/src/" "projectA/src/html")))))) @@ -1486,7 +1486,7 @@ You'd normally combine this with `projectile-test-with-sandbox'." ;; verify that indexing only invokes these funcs once during recursion (spy-on 'projectile-ignored-files :and-call-through) (spy-on 'projectile-ignored-directories :and-call-through) - + (projectile-dir-files-native "projectA/") (expect 'projectile-ignored-files :to-have-been-called-times 1) (expect 'projectile-ignored-directories :to-have-been-called-times 1))))) -- cgit v1.0