Function: projectile-index-directory

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

Signature

(projectile-index-directory DIRECTORY PATTERNS PROGRESS-REPORTER &optional IGNORED-FILES IGNORED-DIRECTORIES GLOBALLY-IGNORED-DIRECTORIES)

Documentation

Index DIRECTORY taking into account PATTERNS.

The function calls itself recursively until all sub-directories have been indexed. The PROGRESS-REPORTER is updated while the function is executing. The list of IGNORED-FILES and IGNORED-DIRECTORIES may optionally be provided.

Source Code

;; Defined in ~/.emacs.d/elpa/projectile-20260310.858/projectile.el
(defun projectile-index-directory (directory patterns progress-reporter &optional ignored-files ignored-directories globally-ignored-directories)
  "Index DIRECTORY taking into account PATTERNS.

The function calls itself recursively until all sub-directories
have been indexed.  The PROGRESS-REPORTER is updated while the
function is executing.  The list of IGNORED-FILES and
IGNORED-DIRECTORIES may optionally be provided."
  ;; we compute the ignored files and directories only once and then we reuse the
  ;; pre-computed values in the subsequent recursive invocations of the function
  (let ((ignored-files (or ignored-files (projectile-ignored-files)))
        (ignored-directories (or ignored-directories (projectile-ignored-directories)))
        (globally-ignored-directories (or globally-ignored-directories (projectile-globally-ignored-directory-names))))
    (apply #'append
           (mapcar
            (lambda (f)
              (let ((local-f (file-name-nondirectory (directory-file-name f))))
                (unless (or (and patterns (projectile-ignored-rel-p f directory patterns))
                            (member local-f '("." "..")))
                  (progress-reporter-update progress-reporter)
                  (if (file-directory-p f)
                      (unless (projectile-ignored-directory-p
                               (file-name-as-directory f)
                               ignored-directories
                               local-f
                               globally-ignored-directories)
                        (projectile-index-directory f patterns progress-reporter ignored-files ignored-directories globally-ignored-directories))
                    (unless (projectile-ignored-file-p f ignored-files)
                      (list f))))))
            ;; Use ignore-errors to skip unreadable directories (e.g.
            ;; .Spotlight-V100 on macOS) instead of aborting the entire
            ;; indexing operation.
            (ignore-errors (directory-files directory t))))))