Function: projectile-index-directory

projectile-index-directory is a byte-compiled function defined in projectile.el.

Signature

(projectile-index-directory DIRECTORY PATTERNS PROGRESS-REPORTER)

Documentation

Index DIRECTORY taking into account PATTERNS.

PATTERNS is a cons of the ignore and the ensure patterns, as returned by projectile-filtering-patterns; both are compiled into a single regexp each, so the per-entry check is one regexp match regardless of how many rules there are. The PROGRESS-REPORTER is updated while the function is executing.

Source Code

;; Defined in ~/.emacs.d/elpa/projectile-20260820.1509/projectile.el
(defun projectile-index-directory (directory patterns progress-reporter)
  "Index DIRECTORY taking into account PATTERNS.

PATTERNS is a cons of the ignore and the ensure patterns, as returned by
`projectile-filtering-patterns'; both are compiled into a single regexp
each, so the per-entry check is one regexp match regardless of how many
rules there are.  The PROGRESS-REPORTER is updated while the function is
executing."
  (let* (;; Ignore patterns match root-relative paths, so when DIRECTORY
         ;; is a subdirectory of the project (a dirconfig `+' keep entry)
         ;; the paths matched must stay relative to the project root, not
         ;; to the walked directory.  Fall back to DIRECTORY when it isn't
         ;; under the current project.
         (walk-base (file-name-as-directory (expand-file-name directory)))
         (project-root (projectile-project-p directory))
         (match-base (if (and project-root
                              (string-prefix-p (file-name-as-directory
                                                (expand-file-name project-root))
                                               walk-base))
                         (file-name-as-directory (expand-file-name project-root))
                       walk-base))
         (rules (list :ignore-re (projectile--compile-ignore-patterns (car patterns))
                      :ensure-re (projectile--compile-ignore-patterns (cdr patterns))
                      :match-base-len (length match-base)))
         ;; A 1-element list whose car is the accumulator.  Using a
         ;; mutable cell lets the recursive walker push results onto a
         ;; single shared list (O(N) total) instead of `apply append'-ing
         ;; per-level results (O(N*depth)).
         (acc-cell (list nil)))
    (projectile--index-directory-walk directory progress-reporter rules acc-cell)
    (nreverse (car acc-cell))))