Function: treemacs--prefetch-gitignore-cache

treemacs--prefetch-gitignore-cache is a byte-compiled function defined in treemacs-async.el.

Signature

(treemacs--prefetch-gitignore-cache PATH)

Documentation

Pre-load all the git-ignored files in the given PATH.

PATH is either the symbol all, in which case the state of all projects in the current workspace is gathered instead, or a single project's path, when that project has just been added to the workspace.

Required for treemacs-hide-gitignored-files-mode(var)/treemacs-hide-gitignored-files-mode(fun) to properly work with deferred git-mode, as otherwise ignored files will not be hidden on the first run because the git cache has yet to be filled.

Source Code

;; Defined in ~/.emacs.d/elpa/treemacs-20251226.1307/treemacs-async.el
(defun treemacs--prefetch-gitignore-cache (path)
  "Pre-load all the git-ignored files in the given PATH.

PATH is either the symbol `all', in which case the state of all projects in the
current workspace is gathered instead, or a single project's path, when that
project has just been added to the workspace.

Required for `treemacs-hide-gitignored-files-mode' to properly work with
deferred git-mode, as otherwise ignored files will not be hidden on the first
run because the git cache has yet to be filled."
  (if (eq path 'all)
      (setf path (-map #'treemacs-project->path
                       (treemacs-workspace->projects (treemacs-current-workspace))))
    (setf path (list path)))
  (pfuture-callback `(,treemacs-python-executable
                      "-O"
                      ,treemacs--find-ignored-files.py
                      ,treemacs-git-executable
                      ,@path)
    :on-error (ignore)
    :on-success
    (let ((ignore-pairs (read (pfuture-callback-output)))
          (ignored-files nil))
      (while ignore-pairs
        (let* ((root  (pop ignore-pairs))
               (file  (pop ignore-pairs))
               (cache (ht-get treemacs--git-cache root)))
          (unless cache
            (setf cache (make-hash-table :size 20 :test 'equal))
            (ht-set! treemacs--git-cache root cache))
          (ht-set! cache file 'treemacs-git-ignored-face)
          (push file ignored-files)))
      (treemacs-run-in-every-buffer
       (treemacs-save-position
        (dolist (file ignored-files)
          (-when-let (treemacs-is-path-visible? file)
            (treemacs-do-delete-single-node file))))))))