Function: projectile-project-files
projectile-project-files is a byte-compiled function defined in
projectile.el.
Signature
(projectile-project-files PROJECT-ROOT)
Documentation
Return a list of files for the PROJECT-ROOT.
Source Code
;; Defined in ~/.emacs.d/elpa/projectile-20260310.858/projectile.el
(defun projectile-project-files (project-root)
"Return a list of files for the PROJECT-ROOT."
(let (files)
;; If the cache is too stale, don't use it.
(when projectile-files-cache-expire
(let ((cache-time
(gethash project-root projectile-projects-cache-time)))
(when (or (null cache-time)
(< (+ cache-time projectile-files-cache-expire)
(projectile-time-seconds)))
(remhash project-root projectile-projects-cache)
(remhash project-root projectile-projects-cache-time))))
;; Use the cache, if requested and available.
(when projectile-enable-caching
(setq files (or (gethash project-root projectile-projects-cache)
;; load the cache from disk only if persistent cache is
;; enabled
(and (eq projectile-enable-caching 'persistent)
(projectile-load-project-cache project-root)))))
;; Calculate the list of files.
(when (null files)
(when projectile-enable-caching
(message "Projectile is initializing cache for %s ..." project-root))
(setq files
(if (eq projectile-indexing-method 'alien)
;; In alien mode we can just skip reading
;; .projectile and find all files in the root dir.
(projectile-dir-files-alien project-root)
;; If a project is defined as a list of subfolders
;; then we'll have the files returned for each subfolder,
;; so they are relative to the project root.
;;
;; TODO: That's pretty slow and we need to improve it.
;; One options would be to pass explicitly the subdirs
;; to commands like `git ls-files` which would return
;; files paths relative to the project root.
(mapcan
(lambda (dir)
(mapcar (lambda (f)
(file-relative-name (concat dir f)
project-root))
(projectile-dir-files dir)))
(projectile-get-project-directories project-root))))
;; Save the cached list.
(when projectile-enable-caching
(projectile-cache-project project-root files)))
;;; Sorting
;;
;; Files can't be cached in sorted order as some sorting schemes
;; require dynamic data. Sorting is ignored completely when in
;; alien mode.
(if (eq projectile-indexing-method 'alien)
files
(projectile-sort-files files))))