[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/tree-sitter 10f96a8c57 05/12: Improve documentation of tree-sitt
From: |
Yuan Fu |
Subject: |
feature/tree-sitter 10f96a8c57 05/12: Improve documentation of tree-sitter search functions |
Date: |
Wed, 5 Oct 2022 22:52:20 -0400 (EDT) |
branch: feature/tree-sitter
commit 10f96a8c57b031b521ae8ba5a02413b94ece423b
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>
Improve documentation of tree-sitter search functions
* doc/lispref/parsing.texi (Retrieving Node): Update manual.
* src/treesit.c (treesit-search-subtree)
(treesit-search-forwardn)
(treesit-induce-sparse-tree): Mention case-insensitivity.
* lisp/treesit.el (treesit-simple-indent): Mention case-insensitivity.
---
doc/lispref/parsing.texi | 16 ++++++++--------
lisp/treesit.el | 4 ++--
src/treesit.c | 10 ++++++----
3 files changed, 16 insertions(+), 14 deletions(-)
diff --git a/doc/lispref/parsing.texi b/doc/lispref/parsing.texi
index 4ae2c4e341..05f4050b54 100644
--- a/doc/lispref/parsing.texi
+++ b/doc/lispref/parsing.texi
@@ -575,10 +575,10 @@ looks for named child.
@defun treesit-search-subtree node predicate &optional all backward limit
This function traverses the subtree of @var{node} (including
@var{node}), and match @var{predicate} with each node along the way.
-And @var{predicate} is a regexp that matches against each node's type,
-or a function that takes a node and returns nil/non-nil. If a node
-matches, that node is returned, if no node ever matches, nil is
-returned.
+And @var{predicate} is a regexp that matches (case-insensitively)
+against each node's type, or a function that takes a node and returns
+nil/non-nil. If a node matches, that node is returned, if no node
+ever matches, nil is returned.
By default, this function only traverses named nodes, if @var{all} is
non-nil, it traverses all nodes. If @var{backward} is non-nil, it
@@ -590,8 +590,8 @@ that number of levels down in the tree.
This function is somewhat similar to @code{treesit-search-subtree}.
It also traverse the parse tree and match each node with
@var{predicate} (except for @var{start}), where @var{predicate} can be
-a regexp or a function. For a tree like the below where @var{start}
-is marked 1, this function traverses as numbered:
+a (case-insensitive) regexp or a function. For a tree like the below
+where @var{start} is marked 1, this function traverses as numbered:
@example
@group
@@ -629,8 +629,8 @@ This function creates a sparse tree from @var{root}'s
subtree.
Basically, it takes the subtree under @var{root}, and combs it so only
the nodes that match @var{predicate} are left, like picking out grapes
on the vine. Like previous functions, @var{predicate} can be a regexp
-string that matches against each node's type, or a function that takes
-a node and return nil/non-nil.
+string that matches against each node's type case-insensitively, or a
+function that takes a node and return nil/non-nil.
For example, for a subtree on the left that consist of both numbers
and letters, if @var{predicate} is ``letter only'', the returned tree
diff --git a/lisp/treesit.el b/lisp/treesit.el
index 4f56a14387..100bf9ac67 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -703,8 +703,8 @@ indentation (target) is in green, current indentation is in
red."
Stops at the first node after point that matches PREDICATE.
PREDICATE can be either a regexp that matches against each node's
-type, or a function that takes a node and returns nil/non-nil for
-match/no match.
+type case-insensitively, or a function that takes a node and
+returns nil/non-nil for match/no match.
If a node matches, move to that node and return the node,
otherwise return nil. SIDE controls whether we move to the start
diff --git a/src/treesit.c b/src/treesit.c
index c9bccb123f..d72c99a974 100644
--- a/src/treesit.c
+++ b/src/treesit.c
@@ -1973,7 +1973,8 @@ DEFUN ("treesit-search-subtree",
Traverse the subtree of NODE, and match PREDICATE with each node along
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.
+node's type case-insensitively, or a function that takes a node and
+returns nil/non-nil.
By default, only traverse named nodes, if ALL is non-nil, traverse all
nodes. If BACKWARD is non-nil, traverse backwards. If LIMIT is
@@ -2018,8 +2019,8 @@ DEFUN ("treesit-search-forward",
Start traversing the tree from node START, and match PREDICATE with
each node along the way (except START). PREDICATE is a regexp string
-that matches against each node's type, or a function that takes a node
-and returns nil/non-nil.
+that matches against each node's type case-insensitively, or a
+function that takes a node and returns nil/non-nil.
By default, only search for named nodes, if ALL is non-nil, search for
all nodes. If BACKWARD is non-nil, search backwards.
@@ -2122,7 +2123,8 @@ DEFUN ("treesit-induce-sparse-tree",
Basically, take the subtree under ROOT, and comb it so only the nodes
that match PREDICATE are left, like picking out grapes on the vine.
-PREDICATE is a regexp string that matches against each node's type.
+PREDICATE is a regexp string that matches against each node's type
+case-insensitively.
For a subtree on the left that consist of both numbers and letters, if
PREDICATE is "is letter", the returned tree is the one on the right.
- feature/tree-sitter updated (9ed53535f5 -> 7ebbd4efc3), Yuan Fu, 2022/10/05
- feature/tree-sitter 23bb724c92 09/12: Add :override flag for tree-sitter font-lock, Yuan Fu, 2022/10/05
- feature/tree-sitter e504eabe88 02/12: Change tree-sitter indent anchor preset 'prev-line', Yuan Fu, 2022/10/05
- feature/tree-sitter 6a3caeab58 03/12: Remove treesit-query-in, Yuan Fu, 2022/10/05
- feature/tree-sitter 10f96a8c57 05/12: Improve documentation of tree-sitter search functions,
Yuan Fu <=
- feature/tree-sitter cb183f6467 11/12: Add tree-sitter admin notes, Yuan Fu, 2022/10/05
- feature/tree-sitter 96d44c4321 06/12: Add treesit-language-version, Yuan Fu, 2022/10/05
- feature/tree-sitter 9b5ecffeb0 04/12: Ignore some capture name in treesit-font-lock-fontify-region, Yuan Fu, 2022/10/05
- feature/tree-sitter 1ea503ed4b 10/12: Add :override flag for python tree-sitter font-lock settings, Yuan Fu, 2022/10/05
- feature/tree-sitter 253126bf33 07/12: Fix python tree-sitter font-lock, Yuan Fu, 2022/10/05
- feature/tree-sitter 6e60d46418 01/12: Fix tree-sitter manuals, Yuan Fu, 2022/10/05
- feature/tree-sitter 7a4380b905 08/12: ; * doc/lispref/parsing.texi (Language Definitions): Fix typo., Yuan Fu, 2022/10/05
- feature/tree-sitter 7ebbd4efc3 12/12: Merge branch 'master' into feature/tree-sitter, Yuan Fu, 2022/10/05