From dfb38fb2ee623a78f7e7e15e0b6f11e4768cef48 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Fri, 13 Jan 2023 09:13:24 +0200 Subject: [PATCH] ; 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. --- doc/lispref/parsing.texi | 8 ++++++-- src/treesit.c | 6 ++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/doc/lispref/parsing.texi b/doc/lispref/parsing.texi index ecba833eb8f..e4a25249829 100644 --- a/doc/lispref/parsing.texi +++ b/doc/lispref/parsing.texi @@ -929,9 +929,13 @@ Here are some predicates on tree-sitter nodes: Checks if @var{object} is a tree-sitter syntax node. @end defun +@cindex compare tree-sitter syntax nodes +@cindex tree-sitter nodes, comparing @defun treesit-node-eq node1 node2 -Checks if @var{node1} and @var{node2} are the same node in a syntax -tree. This function uses the same equivalence metric as @code{equal}. +Checks if @var{node1} and @var{node2} refer to the same node in a +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 @heading Property information diff --git a/src/treesit.c b/src/treesit.c index d2db91604ab..33a7e3c8528 100644 --- a/src/treesit.c +++ b/src/treesit.c @@ -2167,9 +2167,11 @@ bool treesit_node_eq (Lisp_Object node1, Lisp_Object node2) DEFUN ("treesit-node-eq", Ftreesit_node_eq, 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. -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) { if (NILP (node1) || NILP (node2)) -- 2.39.2