Function: treemacs-narrow-to-current-file

treemacs-narrow-to-current-file is an interactive and byte-compiled function defined in treemacs-interface.el.

Signature

(treemacs-narrow-to-current-file)

Documentation

Close everything except the view on the current file.

This command is best understood as a combination of treemacs-collapse-all-projects followed by treemacs-find-file.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/treemacs-20251226.1307/treemacs-interface.el
(defun treemacs-narrow-to-current-file ()
  "Close everything except the view on the current file.
This command is best understood as a combination of
`treemacs-collapse-all-projects' followed by `treemacs-find-file'."
  (interactive)
  (treemacs-unless-let (buffer (treemacs-get-local-buffer))
      (treemacs-log-failure "There is no treemacs buffer")
    (let* ((treemacs-pulse-on-success nil)
           (treemacs-pulse-on-failure nil)
           (treemacs--no-messages t))
      (with-current-buffer buffer
        (treemacs-collapse-all-projects :forget-all))
      (treemacs-find-file))))