aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortake <bararararatty@gmail.com>2026-01-09 22:35:28 +0900
committerGitHub <noreply@github.com>2026-01-09 15:35:28 +0200
commitf19262ae3f2764f10a4d087497058cdb9a0fd3df (patch)
treed7c0d0460b3f71a8281e92246484a7052b5340d5
parent613f0332ec4079914e27b1ddbef9cb7a957a7ffe (diff)
Add projectile-cache-file to projectile-globally-ignored-files default (#1966)
- Include projectile-cache-file in projectile-globally-ignored-files default - Add :safe predicate to allow dir-locals configuration - Add tests for default values and :safe predicate validation - Update related file and test matching functions to use let* variants - Improve variable binding consistency and future compatibility
-rw-r--r--CHANGELOG.md5
-rw-r--r--projectile.el9
-rw-r--r--test/projectile-test.el27
3 files changed, 35 insertions, 6 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index cf1cea3..184a8ed 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,10 +7,11 @@
* [#1837](https://github.com/bbatsov/projectile/issues/1837): Add `eat` project terminal commands with keybindings `x x` and `x 4 x`.
### Changes
-
-* Set `projectile-auto-discover` to `nil` by default (to avoid startup slowdowns in some situations).
+* [#1958](https://github.com/bbatsov/projectile/issues/1958): Exclude `.projectile-cache.eld` from search results (ripgrep/ag/grep) by default.
* [#1957](https://github.com/bbatsov/projectile/pull/1957): Add `:caller` information to calls to `ivy-read` (used by packages like `ivy-rich`).
+* [#1954](https://github.com/bbatsov/projectile/issues/1954): update ELisp for usage.html / "Removal of missing projects"
* [#1947](https://github.com/bbatsov/projectile/issues/1947): `projectile-project-name` should be marked as safe.
+* Set `projectile-auto-discover` to `nil` by default (to avoid startup slowdowns in some situations).
* [#1943](https://github.com/bbatsov/projectile/pull/1943): Consider `projectile-indexing-method` to be safe as a dir-local variable if it is one of the preset values.
* [#1936](https://github.com/bbatsov/projectile/issues/1936): Do not require selecting a project when using `M-x projectile-invalidate-cache`, since there is a global cache that is also cleared by that command, even when not operating on any specific project.
diff --git a/projectile.el b/projectile.el
index 176e731..5d8ce40 100644
--- a/projectile.el
+++ b/projectile.el
@@ -405,10 +405,11 @@ Similar to '#' in .gitignore files."
:package-version '(projectile . "2.2.0"))
(defcustom projectile-globally-ignored-files
- (list projectile-tags-file-name)
+ (list projectile-tags-file-name projectile-cache-file)
"A list of files globally ignored by projectile.
Note that files aren't filtered if `projectile-indexing-method'
is set to `alien'."
+ :safe (lambda (x) (not (remq t (mapcar #'stringp x))))
:group 'projectile
:type '(repeat string))
@@ -2802,7 +2803,7 @@ If KIND is not provided, a list of possible kinds can be chosen."
:caller 'projectile-read-file))))
(error "No related files found")))
- (if-let ((candidates (projectile--related-files file kind)))
+ (if-let* ((candidates (projectile--related-files file kind)))
(projectile-expand-root (projectile--choose-from-candidates candidates :caller 'projectile-read-file))
(error
"No matching related file as `%s' found for project type `%s'"
@@ -4237,12 +4238,12 @@ The precedence for determining implementation files to return is:
(defun projectile-find-matching-test (impl-file)
"Compute the name of the test matching IMPL-FILE."
- (when-let ((candidates (projectile--find-matching-test impl-file)))
+ (when-let* ((candidates (projectile--find-matching-test impl-file)))
(projectile--choose-from-candidates candidates :caller 'projectile-read-file)))
(defun projectile-find-matching-file (test-file)
"Compute the name of a file matching TEST-FILE."
- (when-let ((candidates (projectile--find-matching-file test-file)))
+ (when-let* ((candidates (projectile--find-matching-file test-file)))
(projectile--choose-from-candidates candidates :caller 'projectile-read-file)))
(defun projectile-grep-default-files ()
diff --git a/test/projectile-test.el b/test/projectile-test.el
index f135154..4ebe3bd 100644
--- a/test/projectile-test.el
+++ b/test/projectile-test.el
@@ -352,6 +352,32 @@ Just delegates OPERATION and ARGS for all operations except for`shell-command`'.
(expect (projectile-ignored-file-p "/path/to/project/TAGS") :to-be-truthy)
(expect (projectile-ignored-file-p "/path/to/project/foo.el") :not :to-be-truthy)))
+(describe "projectile-globally-ignored-files"
+ (it "includes TAGS file by default"
+ (expect (member projectile-tags-file-name projectile-globally-ignored-files) :to-be-truthy))
+ (it "includes cache file by default"
+ (expect (member projectile-cache-file projectile-globally-ignored-files) :to-be-truthy))
+ (it "causes cache file to be ignored via projectile-ignored-file-p"
+ (spy-on 'projectile-ignored-files :and-return-value
+ (list (concat "/path/to/project/" projectile-cache-file)
+ (concat "/path/to/project/" projectile-tags-file-name)))
+ (expect (projectile-ignored-file-p (concat "/path/to/project/" projectile-cache-file)) :to-be-truthy)
+ (expect (projectile-ignored-file-p "/path/to/project/source.el") :not :to-be-truthy)))
+
+(describe "projectile-globally-ignored-files :safe predicate"
+ (it "accepts list of strings as safe"
+ (let ((pred (get 'projectile-globally-ignored-files 'safe-local-variable)))
+ (expect (funcall pred '("file1" "file2")) :to-be-truthy)))
+ (it "rejects list containing non-strings as unsafe"
+ (let ((pred (get 'projectile-globally-ignored-files 'safe-local-variable)))
+ (expect (funcall pred '("file1" 123)) :not :to-be-truthy)))
+ (it "accepts empty list as safe"
+ (let ((pred (get 'projectile-globally-ignored-files 'safe-local-variable)))
+ (expect (funcall pred '()) :to-be-truthy)))
+ (it "rejects non-list as unsafe"
+ (let ((pred (get 'projectile-globally-ignored-files 'safe-local-variable)))
+ (expect (funcall pred "not-a-list") :not :to-be-truthy))))
+
(describe "projectile-ignored-files"
(it "returns list of ignored files"
(spy-on 'projectile-project-root :and-return-value "/path/to/project")
@@ -365,6 +391,7 @@ Just delegates OPERATION and ARGS for all operations except for`shell-command`'.
(projectile-ignored-files '("TAGS" "file\d+\\.log")))
(expect (projectile-ignored-files) :not :to-equal files)
(expect (projectile-ignored-files) :to-equal '("/path/to/project/TAGS"
+ "/path/to/project/.projectile-cache.eld"
"/path/to/project/foo.js"
"/path/to/project/bar.rb")))))