Function: combobulate-find-node-in-subtree
combobulate-find-node-in-subtree is a natively compiled function
defined in combobulate-navigation.el.
Signature
(combobulate-find-node-in-subtree TREE NODE &optional STARTING-OFFSET)
Documentation
Find the subtree containing NODE in TREE.
TREE is a tree data structure in the form of a nested conses. NODE is an element that is expected to be found in TREE.
STARTING-OFFSET is the depth at which the search for NODE should start. If not provided, the search starts at the root level (depth 0).
The function returns the subtree containing NODE, or nil if NODE is not found.
This function uses combobulate-get-nodes-at-depth to retrieve
the nodes at each depth and combobulate-node-eq to compare NODE
with the nodes at each depth. The search terminates as soon as
NODE is found or all depths have been searched.
Source Code
;; Defined in /nix/store/b5fvrwzi3zvkabyzx0in6gw1cj963z46-emacs-packages-deps/share/emacs/site-lisp/combobulate-navigation.el
(defun combobulate-find-node-in-subtree (tree node &optional starting-offset)
"Find the subtree containing NODE in TREE.
TREE is a tree data structure in the form of a nested conses.
NODE is an element that is expected to be found in TREE.
STARTING-OFFSET is the depth at which the search for NODE should
start. If not provided, the search starts at the root
level (depth 0).
The function returns the subtree containing NODE, or nil if NODE
is not found.
This function uses `combobulate-get-nodes-at-depth' to retrieve
the nodes at each depth and `combobulate-node-eq' to compare NODE
with the nodes at each depth. The search terminates as soon as
NODE is found or all depths have been searched."
(let ((subtree)
(offset (or starting-offset 0)))
(catch 'done
(while (setq subtree (combobulate-get-nodes-at-depth tree offset))
(when (seq-position subtree node #'combobulate-node-eq)
(throw 'done subtree))
(cl-incf offset)))))