[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/projectile a3dbe329da 2/3: Find project files bottom-up
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/projectile a3dbe329da 2/3: Find project files bottom-up |
Date: |
Sat, 5 Nov 2022 12:59:12 -0400 (EDT) |
branch: elpa/projectile
commit a3dbe329daa3f2f18bd7515927a93f70634df0ee
Author: Greg Pfeil <greg@technomadic.org>
Commit: Bozhidar Batsov <bozhidar@batsov.dev>
Find project files bottom-up
Previously, the directory it found would depend on the order of
`projectile-project-root-files-bottom-up` (or the provided list).
given a directory structure
foo
├── .a
└── bar
└── .a
└── baz
└── .b
`(projectile-root-bottom-up ".../foo/bar/baz/" '(".a" ".b"))` would return
`".../foo/bar/"`, because the current definition looks for any `".a"`
before it
looks for ".b".
With this change, it traverses the directory structure once, looking for any
element of the list before moving up a level. So now the same call returns
`".../foo/bar/baz/"`, which matches the documented behavior of returning the
bottommost matched directory.
Fixes #1796
---
CHANGELOG.md | 1 +
projectile.el | 9 +++++++--
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bf391bd5c9..771475815c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,7 @@
### Bug fixed
+* [#1796](https://github.com/bbatsov/projectile/issues/1796): Fix
`projectile-root-bottom-up` doesn’t always find bottom-most file
* [#1799](https://github.com/bbatsov/projectile/pull/1799): Fix
`projectile-open-projects` lists projects for which all buffers are closed.
* [#1806](https://github.com/bbatsov/projectile/pull/1806): Fix
`projectile-project-type` to return the correct project type even when we pass
it the DIR arg. As a result of the fix,
`projectile-expand-root`, `projectile-detect-project-type`,
`projectile-verify-files` , `projectile-verify-file`
`projectile-verify-file-wildcard`, `projectile-cabal-project-p`,
diff --git a/projectile.el b/projectile.el
index 4a4ee8d07c..4a4faa7651 100644
--- a/projectile.el
+++ b/projectile.el
@@ -1203,8 +1203,13 @@ Return the first (topmost) matched directory or nil if
not found."
"Identify a project root in DIR by bottom-up search for files in LIST.
If LIST is nil, use `projectile-project-root-files-bottom-up' instead.
Return the first (bottommost) matched directory or nil if not found."
- (cl-some (lambda (name) (projectile-locate-dominating-file dir name))
- (or list projectile-project-root-files-bottom-up)))
+ (projectile-locate-dominating-file
+ dir
+ (lambda (directory)
+ (when (file-readable-p directory)
+ (let ((files (mapcar (lambda (file) (expand-file-name file directory))
+ (or list
projectile-project-root-files-bottom-up))))
+ (cl-some (lambda (file) (and file (file-readable-p file))) files))))))
(defun projectile-root-top-down-recurring (dir &optional list)
"Identify a project root in DIR by recurring top-down search for files in
LIST.