; Improve documentation of tree-sitter node comparison

* doc/lispref/parsing.texi (Accessing Node Information):
* src/treesit.c (Ftreesit_node_eq): Improve documentation of node
comparison.
This commit is contained in:
Eli Zaretskii 2023-01-13 09:13:24 +02:00
parent e8a89a18b6
commit dfb38fb2ee
2 changed files with 10 additions and 4 deletions

View file

@ -929,9 +929,13 @@ Here are some predicates on tree-sitter nodes:
Checks if @var{object} is a tree-sitter syntax node. Checks if @var{object} is a tree-sitter syntax node.
@end defun @end defun
@cindex compare tree-sitter syntax nodes
@cindex tree-sitter nodes, comparing
@defun treesit-node-eq node1 node2 @defun treesit-node-eq node1 node2
Checks if @var{node1} and @var{node2} are the same node in a syntax Checks if @var{node1} and @var{node2} refer to the same node in a
tree. This function uses the same equivalence metric as @code{equal}. tree-sitter syntax tree. This function uses the same equivalence
metric as @code{equal}. You can also compare nodes using @code{equal}
(@pxref{Equality Predicates}).
@end defun @end defun
@heading Property information @heading Property information

View file

@ -2167,9 +2167,11 @@ bool treesit_node_eq (Lisp_Object node1, Lisp_Object node2)
DEFUN ("treesit-node-eq", DEFUN ("treesit-node-eq",
Ftreesit_node_eq, Ftreesit_node_eq,
Streesit_node_eq, 2, 2, 0, Streesit_node_eq, 2, 2, 0,
doc: /* Return non-nil if NODE1 and NODE2 are the same node. doc: /* Return non-nil if NODE1 and NODE2 refer to the same node.
If any one of NODE1 and NODE2 is nil, return nil. If any one of NODE1 and NODE2 is nil, return nil.
This function uses the same equivalence metric as `equal'. */) This function uses the same equivalence metric as `equal', and returns
non-nil if NODE1 and NODE2 refer to the same node in a syntax tree
produced by tree-sitter. */)
(Lisp_Object node1, Lisp_Object node2) (Lisp_Object node1, Lisp_Object node2)
{ {
if (NILP (node1) || NILP (node2)) if (NILP (node1) || NILP (node2))