Function: projectile-replace--candidates
projectile-replace--candidates is a byte-compiled function defined in
projectile.el.
Signature
(projectile-replace--candidates TERM LITERAL CASE-FOLD DIRECTORIES)
Documentation
Return the files under DIRECTORIES worth scanning for TERM.
DIRECTORIES is a project root, or a list of them for a search spanning a group of projects, in which case each contributes its own file list and the result is de-duplicated - two members of a group can nest (a monorepo and a project inside it), and a file scanned twice would be replaced twice, corrupting it.
For a case-sensitive LITERAL search this narrows to files that contain
TERM, via projectile-files-with-string - which matches
case-insensitively, so the narrowed set is a safe superset that the scan
then filters exactly - intersected with the project's ignore-aware file
list. For a regexp search, or a case-insensitive literal search, it
returns the whole ignore-aware file list, since those can't be narrowed
by an external grep this way.
Source Code
;; Defined in ~/.emacs.d/elpa/projectile-20260820.1509/projectile.el
(defun projectile-replace--candidates (term literal case-fold directories)
"Return the files under DIRECTORIES worth scanning for TERM.
DIRECTORIES is a project root, or a list of them for a search spanning a
group of projects, in which case each contributes its own file list and
the result is de-duplicated - two members of a group can nest (a
monorepo and a project inside it), and a file scanned twice would be
replaced twice, corrupting it.
For a case-sensitive LITERAL search this narrows to files that contain
TERM, via `projectile-files-with-string' - which matches
case-insensitively, so the narrowed set is a safe superset that the scan
then filters exactly - intersected with the project's ignore-aware file
list. For a regexp search, or a case-insensitive literal search, it
returns the whole ignore-aware file list, since those can't be narrowed
by an external grep this way."
(delete-dups
(mapcan
(lambda (directory)
(let ((project-files (mapcar (lambda (f) (expand-file-name f directory))
(projectile-dir-files directory))))
(if (and literal (not case-fold))
(seq-filter (lambda (f) (member f project-files))
(projectile-files-with-string term directory))
(seq-remove (lambda (f) (or (file-directory-p f) (not (file-exists-p f))))
project-files))))
;; a recorded group can name a directory that has since been moved away
(seq-filter #'projectile--directory-p (ensure-list directories)))))