Function: projectile--index-directory-walk
projectile--index-directory-walk is a byte-compiled function defined
in projectile.el.
Signature
(projectile--index-directory-walk DIRECTORY PROGRESS-REPORTER RULES ACC-CELL)
Documentation
Recursive walker for projectile-index-directory.
DIRECTORY, PROGRESS-REPORTER and RULES carry the same state as the public entry point. ACC-CELL is a 1-element list whose car accumulates discovered file paths in reverse order.
Ignore matching is case-sensitive, so case-fold-search is pinned off
for the regexps matched below.
Source Code
;; Defined in ~/.emacs.d/elpa/projectile-20260820.1509/projectile.el
(defun projectile--index-directory-walk (directory progress-reporter rules acc-cell)
"Recursive walker for `projectile-index-directory'.
DIRECTORY, PROGRESS-REPORTER and RULES carry the same state as the
public entry point. ACC-CELL is a 1-element list whose car
accumulates discovered file paths in reverse order.
Ignore matching is case-sensitive, so `case-fold-search' is pinned off
for the regexps matched below."
;; Use ignore-errors to skip unreadable directories (e.g.
;; .Spotlight-V100 on macOS) instead of aborting the entire indexing
;; operation.
;; `directory-files-no-dot-files-regexp' filters out . and .. at the
;; C level so we don't have to do it again in the loop.
;; `directory-files-and-attributes' (rather than plain `directory-files')
;; gives us each entry's type in the same listing call, so we can tell
;; files from directories without a `file-directory-p' stat per entry -
;; that stat is a separate filesystem round-trip each, which dominates the
;; walk on large or remote (TRAMP) trees.
(let* ((case-fold-search nil)
(entries (ignore-errors
(directory-files-and-attributes
directory t directory-files-no-dot-files-regexp nil 'integer)))
(ignore-re (plist-get rules :ignore-re))
(ensure-re (plist-get rules :ensure-re))
(match-base-len (plist-get rules :match-base-len)))
(dolist (entry entries)
(let* ((f (car entry))
;; The type field is t for a directory, a string (the link
;; target) for a symlink, and nil for a regular file. For a
;; symlink we still defer to `file-directory-p' so that a link
;; pointing at a directory is traversed, matching the previous
;; follow-symlink behaviour; that extra stat only happens for
;; the rare symlink entry, not for every file.
(type (file-attribute-type (cdr entry)))
(directory-p (if (stringp type) (file-directory-p f) (eq type t)))
;; Ignore patterns match against the root-relative path, with
;; a trailing slash appended for directories so that
;; directory-only patterns (trailing `/') can match.
(match-name (and ignore-re
(concat (substring f match-base-len)
(and directory-p "/")))))
(unless (or (and match-name
(string-match-p ignore-re match-name)
(not (and ensure-re (string-match-p ensure-re match-name))))
(projectile--global-ignore-regexp-p f))
(progress-reporter-update progress-reporter)
(if directory-p
(projectile--index-directory-walk f progress-reporter
rules acc-cell)
(setcar acc-cell (cons f (car acc-cell)))))))))