aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2025-06-05 14:25:06 +0300
committerEli Zaretskii2025-06-05 14:25:06 +0300
commit5bf6585de23a7efc1a01d907704325e702e9410a (patch)
tree293aba41e9bffb07915299443faddf09f88ac0c4
parent7d0a605a70215acd79f920d1c250d6ea4e40bb78 (diff)
downloademacs-5bf6585de23a7efc1a01d907704325e702e9410a.tar.gz
emacs-5bf6585de23a7efc1a01d907704325e702e9410a.zip
; Improve documentation of treesit nodes
* doc/lispref/parsing.texi (Retrieving Nodes): Fix and describe the printed representation of treesit nodes.
-rw-r--r--doc/lispref/parsing.texi12
1 files changed, 10 insertions, 2 deletions
diff --git a/doc/lispref/parsing.texi b/doc/lispref/parsing.texi
index 374eeb28b7a..2ff2e5f6160 100644
--- a/doc/lispref/parsing.texi
+++ b/doc/lispref/parsing.texi
@@ -644,6 +644,14 @@ Nodes are not automatically updated when the associated buffer is
644modified, and there is no way to update a node once it is retrieved. 644modified, and there is no way to update a node once it is retrieved.
645Using an outdated node signals the @code{treesit-node-outdated} error. 645Using an outdated node signals the @code{treesit-node-outdated} error.
646 646
647@cindex printed representation, of treesit nodes
648The printed representation of a tree-sitter node uses the hash notation
649described in @ref{Printed Representation}. It looks like
650@w{@samp{#<treesit-node @var{type} in @var{pos1}-@var{pos2}>}}, where
651@var{type} is the type of the node (which comes from the tree-sitter
652grammar used by the buffer), and @var{pos1} and @var{pos2} are buffer
653positions of the node's span. Tree-sitter nodes have no read syntax.
654
647@heading Retrieving nodes from syntax tree 655@heading Retrieving nodes from syntax tree
648@cindex retrieving tree-sitter nodes 656@cindex retrieving tree-sitter nodes
649@cindex syntax tree, retrieving nodes 657@cindex syntax tree, retrieving nodes
@@ -684,7 +692,7 @@ Example:
684@group 692@group
685;; Find the node at point in a C parser's syntax tree. 693;; Find the node at point in a C parser's syntax tree.
686(treesit-node-at (point) 'c) 694(treesit-node-at (point) 'c)
687 @result{} #<treesit-node (primitive_type) in 23-27> 695 @result{} #<treesit-node primitive_type in 23-27>
688@end group 696@end group
689@end example 697@end example
690@end defun 698@end defun
@@ -791,7 +799,7 @@ This function finds the child of @var{node} whose field name is
791@group 799@group
792;; Get the child that has "body" as its field name. 800;; Get the child that has "body" as its field name.
793(treesit-node-child-by-field-name node "body") 801(treesit-node-child-by-field-name node "body")
794 @result{} #<treesit-node (compound_statement) in 45-89> 802 @result{} #<treesit-node compound_statement in 45-89>
795@end group 803@end group
796@end example 804@end example
797@end defun 805@end defun