Function: treemacs--expand-dir-node

treemacs--expand-dir-node is a byte-compiled function defined in treemacs-rendering.el.

Signature

(treemacs--expand-dir-node BTN &key GIT-FUTURE FLATTEN-FUTURE RECURSIVE)

Documentation

Open the node given by BTN.

BTN: Button GIT-FUTURE: Pfuture|HashMap FLATTEN-FUTURE: Pfuture|HashMap RECURSIVE: Bool

Source Code

;; Defined in ~/.emacs.d/elpa/treemacs-20251226.1307/treemacs-rendering.el
(cl-defun treemacs--expand-dir-node
    (btn
     &key
     git-future
     flatten-future
     recursive)
  "Open the node given by BTN.

BTN: Button
GIT-FUTURE: Pfuture|HashMap
FLATTEN-FUTURE: Pfuture|HashMap
RECURSIVE: Bool"
  (-let [path (treemacs-button-get btn :path)]
    (if (not (file-readable-p path))
        (treemacs-pulse-on-failure "Directory %s is not readable."
          (propertize path 'face 'font-lock-string-face))
      (let* ((project (treemacs-project-of-node btn))
             (git-future (if (treemacs-button-get btn :symlink)
                             (treemacs--git-status-process (file-truename path) project)
                           (or git-future (treemacs--git-status-process path project))))
             (flatten-future (or flatten-future
                                 (treemacs--flattened-dirs-process path project)))
             (recursive (treemacs--prefix-arg-to-recurse-depth recursive))
             (base-dir-name (treemacs--filename (treemacs-button-get btn :key))))
        (treemacs--button-open
         :immediate-insert nil
         :button btn
         :new-state 'dir-node-open
         :new-icon (treemacs-icon-for-dir base-dir-name 'open)
         :open-action
         (progn
           ;; do on-expand first so buttons that need collapsing can quickly find their parent
           (treemacs-on-expand path btn)
           (when (fboundp 'treemacs--apply-directory-top-extensions)
             (treemacs--apply-directory-top-extensions btn path))
           (goto-char
            (treemacs--create-branch
             path (1+ (treemacs-button-get btn :depth))
             git-future flatten-future btn))
           (when (fboundp 'treemacs--apply-directory-bottom-extensions)
             (treemacs--apply-directory-bottom-extensions btn path))
           (treemacs--start-watching path)
           (when (> recursive 0)
             (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))))))))))