Function: treemacs--expand-root-node
treemacs--expand-root-node is a byte-compiled function defined in
treemacs-rendering.el.
Signature
(treemacs--expand-root-node BTN &optional RECURSIVE)
Documentation
Expand the given root BTN.
Open every child-directory as well when RECURSIVE is non-nil.
BTN: Button RECURSIVE: Bool
Source Code
;; Defined in ~/.emacs.d/elpa/treemacs-20251226.1307/treemacs-rendering.el
(defun treemacs--expand-root-node (btn &optional recursive)
"Expand the given root BTN.
Open every child-directory as well when RECURSIVE is non-nil.
BTN: Button
RECURSIVE: Bool"
(let ((project (treemacs-button-get btn :project)))
(treemacs-with-writable-buffer
(treemacs-project->refresh-path-status! project))
(if (treemacs-project->is-unreadable? project)
(treemacs-pulse-on-failure
(format "%s is not readable."
(propertize (treemacs-project->path project) 'face 'font-lock-string-face)))
(let* ((path (treemacs-button-get btn :path))
(git-path (if (treemacs-button-get btn :symlink) (file-truename path) path))
(git-future (treemacs--git-status-process git-path project))
(flatten-future (treemacs--flattened-dirs-process path project))
(recursive (treemacs--prefix-arg-to-recurse-depth recursive)) )
(treemacs--maybe-recenter treemacs-recenter-after-project-expand
(treemacs--button-open
:immediate-insert nil
:button btn
:new-state 'root-node-open
:new-icon treemacs-icon-root-open
:open-action
(progn
;; TODO(2019/10/14): go back to post open
;; expand first because it creates a dom node entry
(treemacs-on-expand path btn)
(when (fboundp 'treemacs--apply-project-top-extensions)
(treemacs--apply-project-top-extensions btn project))
(when (fboundp 'treemacs--apply-project-bottom-extensions)
(save-excursion
(treemacs--apply-project-bottom-extensions btn project)))
(treemacs--create-branch
path
(1+ (treemacs-button-get btn :depth))
git-future
flatten-future
btn)
(treemacs--start-watching path)
;; Performing FS ops on a disconnected Tramp project
;; might have changed the state to connected.
(treemacs-with-writable-buffer
(treemacs-project->refresh-path-status! project))
(when (and (> recursive 0) (treemacs-project->is-readable? project))
(cl-decf recursive)
(--each (treemacs-collect-child-nodes btn)
(when (eq 'dir-node-closed (treemacs-button-get it :state))
(goto-char (treemacs-button-start it))
(treemacs--expand-dir-node it :git-future git-future :recursive recursive)))))))))))