Function: treemacs--find-custom-top-level-node
treemacs--find-custom-top-level-node is a byte-compiled function
defined in treemacs-core-utils.el.
Signature
(treemacs--find-custom-top-level-node PATH)
Documentation
Find the position of the top level extension node at PATH.
Source Code
;; Defined in ~/.emacs.d/elpa/treemacs-20251226.1307/treemacs-core-utils.el
(defun treemacs--find-custom-top-level-node (path)
"Find the position of the top level extension node at PATH."
(let* ((root-key (cadr path))
;; go back here if the search fails
;; the root key isn't really a project, it's just the :root-key-form
(start (prog1 (point) (goto-char (treemacs-project->position root-key))))
;; making a copy since the variable is a reference to a node actual path
;; and will be changed in-place here
(goto-path (copy-sequence path))
(counter (1- (length goto-path)))
;; manual as in to be expanded manually after we moved to the next closest node we can find
;; in the dom
(manual-parts nil)
(dom-node nil))
;; Try to move as close as possible to the followed node, starting with its immediate parent
;; keep moving upwards in the path we move to until reaching the root of the project. Root of
;; project is met when counter is one, (not zero like with other nodes), since the root path of
;; top-level extensions is of form (:CUSTOM Root-Key), already containing two elements.
(while (and (> counter 1)
(null dom-node))
(setq dom-node (treemacs-find-in-dom goto-path)
counter (1- counter))
(cond
((null dom-node)
(push (nth (1+ counter) goto-path) manual-parts)
(setcdr (nthcdr counter goto-path) nil))
((and dom-node (null (treemacs-dom-node->position dom-node)))
(setq dom-node nil)
(push (nth (1+ counter) goto-path) manual-parts)
(setcdr (nthcdr counter goto-path) nil))))
(let* ((btn (if dom-node
(treemacs-dom-node->position dom-node)
(treemacs-project->position root-key)))
;; do the rest manually
(search-result (if manual-parts
(treemacs--follow-path-elements btn manual-parts)
(goto-char btn))))
(if (eq 'follow-failed search-result)
(prog1 nil
(goto-char start))
search-result))))