Function: treemacs--find-custom-dir-node
treemacs--find-custom-dir-node is a byte-compiled function defined in
treemacs-core-utils.el.
Signature
(treemacs--find-custom-dir-node PATH)
Documentation
Move to the directory extension node at PATH.
Source Code
;; Defined in ~/.emacs.d/elpa/treemacs-20251226.1307/treemacs-core-utils.el
(cl-macrolet
((define-find-custom-node (name project-form doc)
`(defun ,name (path)
,doc
(let* (;; go back here if the search fails
(project ,project-form)
(start (prog1 (point) (goto-char (treemacs-project->position project))))
;; 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))
;; 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 (counter = 0)
;; all the while collecting the parts of the path that beed manual expanding
(-let [continue t]
(while continue
(setf dom-node (treemacs-find-in-dom goto-path))
(if (or (null dom-node)
;; dom node might exist, but a leaf's position is not always known
(null (treemacs-dom-node->position dom-node)))
(progn
(push (-last-item goto-path) manual-parts)
(setf goto-path (-butlast goto-path))
(unless (cdr goto-path) (setf goto-path (car goto-path))))
(setf continue nil))))
(let* ((btn (--if-let (treemacs-dom-node->position dom-node)
it
(treemacs-project->position project)))
;; 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))
(treemacs-dom-node->set-position! (treemacs-find-in-dom path) search-result)
search-result))))))
(define-find-custom-node treemacs--find-custom-project-node (pop path)
"Move to the project extension node at PATH.")
(define-find-custom-node treemacs--find-custom-dir-node (treemacs--find-project-for-path (car path))
"Move to the directory extension node at PATH."))