Rename LIMIT to DEPTH in tree-sitter functions (bug#61231)

I only changed the Lisp functions, internal functions are left
unchanged.

* doc/lispref/parsing.texi (Retrieving Nodes): Update manual.
* src/treesit.c (Ftreesit_search_subtree)
(Ftreesit_induce_sparse_tree): Change LIMIT to DEPTH.
This commit is contained in:
Yuan Fu 2023-02-09 23:25:57 -08:00
parent b39821fdce
commit f5789aefc2
No known key found for this signature in database
GPG key ID: 56E19BC57664A442
2 changed files with 18 additions and 18 deletions

View file

@ -734,7 +734,7 @@ is non-@code{nil}, it looks for smallest named child.
@heading Searching for node
@defun treesit-search-subtree node predicate &optional backward all limit
@defun treesit-search-subtree node predicate &optional backward all depth
This function traverses the subtree of @var{node} (including
@var{node} itself), looking for a node for which @var{predicate}
returns non-@code{nil}. @var{predicate} is a regexp that is matched
@ -745,9 +745,9 @@ the first node that matches, or @code{nil} if none does.
By default, this function only traverses named nodes, but if @var{all}
is non-@code{nil}, it traverses all the nodes. If @var{backward} is
non-@code{nil}, it traverses backwards (i.e., it visits the last child
first when traversing down the tree). If @var{limit} is
first when traversing down the tree). If @var{depth} is
non-@code{nil}, it must be a number that limits the tree traversal to
that many levels down the tree. If @var{limit} is @code{nil}, it
that many levels down the tree. If @var{depth} is @code{nil}, it
defaults to 1000.
@end defun
@ -805,7 +805,7 @@ Arguments @var{predicate}, @var{backward} and @var{all} are the same
as in @code{treesit-search-forward}.
@end defun
@defun treesit-induce-sparse-tree root predicate &optional process-fn limit
@defun treesit-induce-sparse-tree root predicate &optional process-fn depth
This function creates a sparse tree from @var{root}'s subtree.
It takes the subtree under @var{root}, and combs it so only the nodes
@ -836,8 +836,8 @@ b 1 2 b | | b c d
If @var{process-fn} is non-@code{nil}, instead of returning the
matched nodes, this function passes each node to @var{process-fn} and
uses the returned value instead. If non-@code{nil}, @var{limit} is
the number of levels to go down from @var{root}. If @var{limit} is
uses the returned value instead. If non-@code{nil}, @var{depth} is
the number of levels to go down from @var{root}. If @var{depth} is
@code{nil}, it defaults to 1000.
Each node in the returned tree looks like

View file

@ -3150,13 +3150,13 @@ the way. PREDICATE is a regexp string that matches against each
node's type, or a function that takes a node and returns nil/non-nil.
By default, only traverse named nodes, but if ALL is non-nil, traverse
all nodes. If BACKWARD is non-nil, traverse backwards. If LIMIT is
all nodes. If BACKWARD is non-nil, traverse backwards. If DEPTH is
non-nil, only traverse nodes up to that number of levels down in the
tree. If LIMIT is nil, default to 1000.
tree. If DEPTH is nil, default to 1000.
Return the first matched node, or nil if none matches. */)
(Lisp_Object node, Lisp_Object predicate, Lisp_Object backward,
Lisp_Object all, Lisp_Object limit)
Lisp_Object all, Lisp_Object depth)
{
CHECK_TS_NODE (node);
CHECK_TYPE (STRINGP (predicate) || FUNCTIONP (predicate),
@ -3167,10 +3167,10 @@ Return the first matched node, or nil if none matches. */)
/* We use a default limit of 1000. See bug#59426 for the
discussion. */
ptrdiff_t the_limit = treesit_recursion_limit;
if (!NILP (limit))
if (!NILP (depth))
{
CHECK_FIXNUM (limit);
the_limit = XFIXNUM (limit);
CHECK_FIXNUM (depth);
the_limit = XFIXNUM (depth);
}
treesit_initialize ();
@ -3322,8 +3322,8 @@ If PROCESS-FN is non-nil, it should be a function of one argument. In
that case, instead of returning the matched nodes, pass each node to
PROCESS-FN, and use its return value instead.
If non-nil, LIMIT is the number of levels to go down the tree from
ROOT. If LIMIT is nil or omitted, it defaults to 1000.
If non-nil, DEPTH is the number of levels to go down the tree from
ROOT. If DEPTH is nil or omitted, it defaults to 1000.
Each node in the returned tree looks like (NODE . (CHILD ...)). The
root of this tree might be nil, if ROOT doesn't match PREDICATE.
@ -3334,7 +3334,7 @@ PREDICATE can also be a function that takes a node and returns
nil/non-nil, but it is slower and more memory consuming than using
a regexp. */)
(Lisp_Object root, Lisp_Object predicate, Lisp_Object process_fn,
Lisp_Object limit)
Lisp_Object depth)
{
CHECK_TS_NODE (root);
CHECK_TYPE (STRINGP (predicate) || FUNCTIONP (predicate),
@ -3346,10 +3346,10 @@ a regexp. */)
/* We use a default limit of 1000. See bug#59426 for the
discussion. */
ptrdiff_t the_limit = treesit_recursion_limit;
if (!NILP (limit))
if (!NILP (depth))
{
CHECK_FIXNUM (limit);
the_limit = XFIXNUM (limit);
CHECK_FIXNUM (depth);
the_limit = XFIXNUM (depth);
}
treesit_initialize ();