Function: treemacs--find-custom-node

treemacs--find-custom-node is a byte-compiled function defined in treemacs-core-utils.el.

Signature

(treemacs--find-custom-node PATH)

Documentation

Specialisation to find a custom node at the given PATH.

Source Code

;; Defined in ~/.emacs.d/elpa/treemacs-20251226.1307/treemacs-core-utils.el
(defun treemacs--find-custom-node (path)
  "Specialisation to find a custom node at the given PATH."
  (let* (;; go back here if the search fails
         (start (point))
         ;; (top-pos (treemacs-dom-node->position (treemacs-find-in-dom (car path))))
         ;; making a copy since the variable is a reference to a node actual path
         ;; and will be changed in-place here
         (goto-path (if (listp path) (copy-sequence path) (list 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))
    (-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)))
            (if (cdr goto-path)
                (progn
                  (push (-last-item  goto-path) manual-parts)
                  (setf goto-path (-butlast goto-path)))
              (setf goto-path (car goto-path)))
          (setf continue nil))))
    (let* ((btn (treemacs-dom-node->position dom-node))
           ;; 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))))