You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/emacs-tree-sitter.org
+13-3Lines changed: 13 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -628,7 +628,17 @@ Tree-walking functions enable efficient traversal of the syntax tree.
628
628
*** Traversing All Descendant Nodes
629
629
These functions are high-level APIs that allow traversing the syntax tree in depth-first pre-order.
630
630
631
-
When dealing with a large number of nodes, working with node objects creates a huge pressure on the garbage collector. For better performance, it's advisable to extract and work with individual node properties.
631
+
When dealing with a large number of nodes, working with node objects creates a huge pressure on the garbage collector. For better performance, it's advisable to extract and work with individual node properties. The constant ~tsc-valid-node-props~ holds the list of all available property names.
632
+
# TODO: Make :exports results work with ox-hugo.
633
+
#+begin_src emacs-lisp
634
+
'(:type
635
+
:field ;node's field name within the parent node
636
+
:depth ;node's depth, relative to the iterator's start
- ~tsc-traverse-do~ /~(vars tree-or-node) body~/ :: Evaluate ~body~ with ~vars~ bound to corresponding properties of each traversed node.
634
644
#+begin_src emacs-lisp
@@ -637,7 +647,7 @@ When dealing with a large number of nodes, working with node objects creates a h
637
647
(insert (make-string depth \? ) ;indentation
638
648
(format "%S" type) "\n")))
639
649
#+end_src
640
-
- ~tsc-traverse-mapc~ /~func tree-or-node [props]~/ :: Call ~func~ for each traversed node, passing the node as the argument. If the vector of keywords ~props~ is specified, ~func~ receives a vector containing the node's properties instead. *Do not keep a reference to the vector*, as it is reused across invocations. Use ~pcase-let~ to extract the properties.
650
+
- ~tsc-traverse-mapc~ /~func tree-or-node [props]~/ :: Call ~func~ for each traversed node, passing the node as the argument. If ~props~ is a vector of property names, ~func~ receives a vector containing the node's properties instead. *Do not keep a reference to the vector*, as it is reused across invocations. Use ~pcase-let~ to extract the properties.
641
651
#+begin_src emacs-lisp
642
652
(tsc-traverse-mapc
643
653
(lambda (props)
@@ -648,7 +658,7 @@ When dealing with a large number of nodes, working with node objects creates a h
648
658
tree
649
659
[:type :depth :named-p])
650
660
#+end_src
651
-
- ~tsc-traverse-iter~ /~tree-or-node [props]~/ :: Create an iterator that yields traversed nodes. If the vector of keywords ~props~ is specified, the iterator yields a vector containing the node's properties instead. *Do not keep a reference to the vector*, as it is reused across iterations. Use ~pcase-let~ to extract the properties.
661
+
- ~tsc-traverse-iter~ /~tree-or-node [props]~/ :: Create an iterator that yields traversed nodes. If ~props~ is a vector of property names, the iterator yields a vector containing the node's properties instead. *Do not keep a reference to the vector*, as it is reused across iterations. Use ~pcase-let~ to extract the properties.
0 commit comments