[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/tree-sitter 838fc77254 5/7: Make tree-sitter node type match cas
From: |
Yuan Fu |
Subject: |
feature/tree-sitter 838fc77254 5/7: Make tree-sitter node type match case-sensitive |
Date: |
Wed, 9 Nov 2022 18:52:04 -0500 (EST) |
branch: feature/tree-sitter
commit 838fc77254286de318b65602b31c6d3915594a8e
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>
Make tree-sitter node type match case-sensitive
* doc/lispref/parsing.texi (Retrieving Node): Update manual.
* src/treesit.c (treesit_traverse_match_predicate): Change to
fast_c_string_match.
(Ftreesit_search_subtree)
(Ftreesit_search_forward)
(Ftreesit_induce_sparse_tree): Update docstring.
---
doc/lispref/parsing.texi | 17 ++++++++---------
src/treesit.c | 12 +++++-------
2 files changed, 13 insertions(+), 16 deletions(-)
diff --git a/doc/lispref/parsing.texi b/doc/lispref/parsing.texi
index 0a0104b4be..bc2f0dda91 100644
--- a/doc/lispref/parsing.texi
+++ b/doc/lispref/parsing.texi
@@ -650,10 +650,9 @@ is non-@code{nil}, it looks for smallest named child.
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
-(case-insensitively) against each node's type, or a predicate function
-that takes a node and returns non-@code{nil} if the node matches. The
-function returns the first node that matches, or @code{nil} if none
-does.
+against each node's type, or a predicate function that takes a node
+and returns non-@code{nil} if the node matches. The function returns
+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
@@ -666,9 +665,9 @@ down the tree.
@defun treesit-search-forward start predicate &optional backward all
Like @code{treesit-search-subtree}, this function also traverses the
parse tree and matches each node with @var{predicate} (except for
-@var{start}), where @var{predicate} can be a (case-insensitive) regexp
-or a function. For a tree like the below where @var{start} is marked
-S, this function traverses as numbered from 1 to 12:
+@var{start}), where @var{predicate} can be a regexp or a function.
+For a tree like the below where @var{start} is marked S, this function
+traverses as numbered from 1 to 12:
@example
@group
@@ -723,8 +722,8 @@ 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
that match @var{predicate} are left. Like previous functions, the
@var{predicate} can be a regexp string that matches against each
-node's type case-insensitively, or a function that takes a node and
-return non-@code{nil} if it matches.
+node's type, or a function that takes a node and return non-@code{nil}
+if it matches.
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/src/treesit.c b/src/treesit.c
index 48d650f1fc..63785b2122 100644
--- a/src/treesit.c
+++ b/src/treesit.c
@@ -2476,7 +2476,7 @@ treesit_traverse_match_predicate (TSNode node,
Lisp_Object pred,
if (STRINGP (pred))
{
const char *type = ts_node_type (node);
- return fast_c_string_match_ignore_case (pred, type, strlen (type)) >= 0;
+ return fast_c_string_match (pred, type, strlen (type)) >= 0;
}
else
{
@@ -2594,8 +2594,7 @@ 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 case-insensitively, or a function that takes a node and
-returns nil/non-nil.
+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
@@ -2639,8 +2638,8 @@ DEFUN ("treesit-search-forward",
Start traversing the tree from node START, and match PREDICATE with
each node (except START itself) along the way. PREDICATE is a regexp
-string that matches against each node's type case-insensitively, or a
-function that takes a node and returns non-nil if it matches.
+string that matches against each node's type, or a function that takes
+a node and returns non-nil if it matches.
By default, only search for named nodes, but if ALL is non-nil, search
for all nodes. If BACKWARD is non-nil, search backwards.
@@ -2737,8 +2736,7 @@ DEFUN ("treesit-induce-sparse-tree",
This takes the subtree under ROOT, and combs 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
-case-insensitively.
+PREDICATE is a regexp string that matches against each node's type.
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 (5858921f40 -> eecc2d45b9), Yuan Fu, 2022/11/09
- feature/tree-sitter 663d768d44 6/7: * configure.ac: Change required tree-sitter version to 0.20.2., Yuan Fu, 2022/11/09
- feature/tree-sitter eecc2d45b9 7/7: ; Update tree-sitter HTML manuals in admin/notes, Yuan Fu, 2022/11/09
- feature/tree-sitter 077c664052 2/7: ; Fix treesit-query-range docstring, Yuan Fu, 2022/11/09
- feature/tree-sitter a7042fa051 4/7: New function fast_c_string_match and fast_c_string_match_internal, Yuan Fu, 2022/11/09
- feature/tree-sitter 838fc77254 5/7: Make tree-sitter node type match case-sensitive,
Yuan Fu <=
- feature/tree-sitter 2b4d46f99b 1/7: Mimic existing python-mode beg/end-of-defun behavior better, Yuan Fu, 2022/11/09
- feature/tree-sitter 2332c3eb55 3/7: Add tree-sitter shortdoc, Yuan Fu, 2022/11/09