Function: treemacs-hide-gitignored-files-mode

treemacs-hide-gitignored-files-mode is an interactive and byte-compiled function defined in treemacs-async.el.

Signature

(treemacs-hide-gitignored-files-mode &optional ARG)

Documentation

Toggle treemacs-hide-gitignored-files-mode(var)/treemacs-hide-gitignored-files-mode(fun).

When enabled treemacs will hide files that are ignored by git.

Some form of treemacs-git-mode(var)/treemacs-git-mode(fun) *must* be enabled, otherwise this feature will have no effect.

Both extended and deferred git-mode settings will work in full (in case of deferred git-mode treemacs will pre-load the list of ignored files so they will be hidden even on the first run). The limitations of simple git-mode apply here as well: since it only knows about files and not directories only files will be hidden.

This is a global minor mode. If called interactively, toggle the Treemacs-Hide-Gitignored-Files mode mode. If the prefix argument is positive, enable the mode, and if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is toggle. Enable the mode if ARG is nil, omitted, or is a positive number. Disable the mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer, evaluate (default-value \=treemacs-hide-gitignored-files-mode)'.

The mode's hook is called both when the mode is enabled and when it is disabled.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/treemacs-20251226.1307/treemacs-async.el
(define-minor-mode treemacs-hide-gitignored-files-mode
  "Toggle `treemacs-hide-gitignored-files-mode'.

When enabled treemacs will hide files that are ignored by git.

Some form of `treemacs-git-mode' *must* be enabled, otherwise this feature will
have no effect.

Both `extended' and `deferred' git-mode settings will work in full (in case of
`deferred' git-mode treemacs will pre-load the list of ignored files so they
will be hidden even on the first run).  The limitations of `simple' git-mode
apply here as well: since it only knows about files and not directories only
files will be hidden."
  :init-value nil
  :global     t
  :lighter    nil
  :group      'treemacs-git
  (if treemacs-hide-gitignored-files-mode
      (progn
        (add-to-list 'treemacs-pre-file-insert-predicates
                     #'treemacs-is-file-git-ignored?)
        (when (and (eq 'deferred treemacs--git-mode)
                   (not (get 'treemacs-hide-gitignored-files-mode
                             :prefetch-done)))
          (treemacs--prefetch-gitignore-cache 'all)
          (put 'treemacs-hide-gitignored-files-mode :prefetch-done t)))
    (setf treemacs-pre-file-insert-predicates
          (delete #'treemacs-is-file-git-ignored?
                  treemacs-pre-file-insert-predicates)))
  (treemacs-run-in-every-buffer
   (treemacs--do-refresh (current-buffer) 'all))
  (when (called-interactively-p 'interactive)
    (treemacs-pulse-on-success "Git-ignored files will now be %s"
      (propertize
       (if treemacs-hide-gitignored-files-mode "hidden." "displayed.")
       'face 'font-lock-constant-face))) )