Function: treemacs--expand-file-node

treemacs--expand-file-node is an autoloaded and byte-compiled function defined in treemacs-tags.el.

Signature

(treemacs--expand-file-node BTN &optional RECURSIVE)

Documentation

Open tag items for file BTN.

Recursively open all tags below BTN when RECURSIVE is non-nil.

Source Code

;; Defined in ~/.emacs.d/elpa/treemacs-20251226.1307/treemacs-tags.el
;;;###autoload
(defun treemacs--expand-file-node (btn &optional recursive)
  "Open tag items for file BTN.
Recursively open all tags below BTN when RECURSIVE is non-nil."
  (let* ((path (treemacs-button-get btn :path))
         (parent-dom-node (treemacs-find-in-dom path))
         (recursive (treemacs--prefix-arg-to-recurse-depth recursive)))
    (-if-let (index (treemacs--get-imenu-index path))
        (treemacs--button-open
         :button btn
         :immediate-insert t
         :new-state 'file-node-open
         :open-action
         (treemacs--create-buttons
          :nodes index
          :extra-vars
          ((node-prefix (concat prefix treemacs-icon-tag-closed))
           (leaf-prefix (concat prefix treemacs-icon-tag-leaf)))
          :depth (1+ (treemacs-button-get btn :depth))
          :node-name item
          :node-action (if (imenu--subalist-p item)
                           (treemacs--insert-tag-node item (list path (car item)) node-prefix btn depth)
                         (treemacs--insert-tag-leaf item (list path (car item)) leaf-prefix btn depth)))
         :post-open-action
         (progn
           (-let [dom-nodes
                  (--map (treemacs-dom-node->create!
                          :key (list path (car it))
                          :parent parent-dom-node)
                         index)]
             (-each dom-nodes #'treemacs-dom-node->insert-into-dom!)
             (setf (treemacs-dom-node->children parent-dom-node)
                   (nconc dom-nodes (treemacs-dom-node->children parent-dom-node))))
           (treemacs-on-expand path btn)
           (treemacs--reentry path)
           (end-of-line)
           (when (> recursive 0)
             (cl-decf recursive)
             (--each (treemacs-collect-child-nodes btn)
               (when (eq 'tag-node-closed (treemacs-button-get it :state))
                 (goto-char (treemacs-button-start it))
                 (treemacs--expand-tag-node it t))))))
      (treemacs-pulse-on-failure "No tags found for %s" (propertize path 'face 'font-lock-string-face)))))