Function: projectile-files-with-string
projectile-files-with-string is a byte-compiled function defined in
projectile.el.
Signature
(projectile-files-with-string STRING DIRECTORY &optional FILE-EXT)
Documentation
Return a list of all files containing STRING in DIRECTORY.
Tries to use rg, ag, ack, git-grep, and grep in that order. If those are impossible (for instance on Windows), returns a list of all files in the project.
Source Code
;; Defined in ~/.emacs.d/elpa/projectile-20260310.858/projectile.el
(defun projectile-files-with-string (string directory &optional file-ext)
"Return a list of all files containing STRING in DIRECTORY.
Tries to use rg, ag, ack, git-grep, and grep in that order. If those
are impossible (for instance on Windows), returns a list of all
files in the project."
(if (projectile-unixy-system-p)
(let* ((search-term (shell-quote-argument string))
(cmd (cond ((executable-find "rg")
(projectile--rg-construct-command search-term file-ext))
((executable-find "ag")
(projectile--ag-construct-command search-term file-ext))
((executable-find "ack")
(projectile--ack-construct-command search-term file-ext))
((and (executable-find "git")
(eq (projectile-project-vcs) 'git))
(projectile--git-grep-construct-command search-term file-ext))
(t
(projectile--grep-construct-command search-term file-ext)))))
(projectile-files-from-cmd cmd directory))
;; we have to reject directories as a workaround to work with git submodules
(seq-remove
#'file-directory-p
(mapcar #'(lambda (file) (expand-file-name file directory))
(projectile-dir-files directory)))))