summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYuan Fu <casouri@gmail.com>2023-04-13 18:45:07 -0700
committerYuan Fu <casouri@gmail.com>2023-04-13 18:47:41 -0700
commitde34de3b35cbe1da6fb035b93081e0564b3c7b3f (patch)
tree58da547b9fcfd362eb252c35c024cc6298a4db7e /src
parent3ef54c64fa8e7236458228db09fe7192350cbeb6 (diff)
downloademacs-de34de3b35cbe1da6fb035b93081e0564b3c7b3f.tar.gz
Fix previous commit on tree-sitter
* src/treesit.c: (treesit_traverse_validate_predicate): Don't accept symbols. (treesit_traverse_match_predicate): Don't accept symbols, and use correct variable for the regexp and pred check. * test/src/treesit-tests.el: (treesit-search-forward-predicate): Fix the test.
Diffstat (limited to 'src')
-rw-r--r--src/treesit.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/src/treesit.c b/src/treesit.c
index 45b5ab15390..d0d9c50c14f 100644
--- a/src/treesit.c
+++ b/src/treesit.c
@@ -3148,9 +3148,7 @@ treesit_traverse_validate_predicate (Lisp_Object pred,
{
if (STRINGP (pred))
return true;
- /* We want to allow cl-labels-defined functions, so we allow
- symbols. */
- else if (FUNCTIONP (pred) || SYMBOLP (pred))
+ else if (FUNCTIONP (pred))
return true;
else if (CONSP (pred))
{
@@ -3194,8 +3192,7 @@ treesit_traverse_validate_predicate (Lisp_Object pred,
}
return true;
}
- /* We allow the function to be a symbol to support cl-label. */
- else if (STRINGP (car) && (FUNCTIONP (cdr) || SYMBOLP (cdr)))
+ else if (STRINGP (car) && FUNCTIONP (cdr))
return true;
}
*signal_data = list2 (build_string ("Invalid predicate, see TODO for "
@@ -3230,9 +3227,7 @@ treesit_traverse_match_predicate (TSTreeCursor *cursor, Lisp_Object pred,
const char *type = ts_node_type (node);
return fast_c_string_match (pred, type, strlen (type)) >= 0;
}
- /* We want to allow cl-labels-defined functions, so we allow
- symbols. */
- else if (FUNCTIONP (pred) || SYMBOLP (pred))
+ else if (FUNCTIONP (pred))
{
Lisp_Object lisp_node = make_treesit_node (parser, node);
return !NILP (CALLN (Ffuncall, pred, lisp_node));
@@ -3255,17 +3250,15 @@ treesit_traverse_match_predicate (TSTreeCursor *cursor, Lisp_Object pred,
}
return false;
}
- /* We want to allow cl-labels-defined functions, so we allow
- symbols. */
- else if (STRINGP (car) && (FUNCTIONP (cdr) || SYMBOLP (cdr)))
+ else if (STRINGP (car) && FUNCTIONP (cdr))
{
/* A bit of code duplication here, but should be fine. */
const char *type = ts_node_type (node);
- if (!(fast_c_string_match (pred, type, strlen (type)) >= 0))
+ if (!(fast_c_string_match (car, type, strlen (type)) >= 0))
return false;
Lisp_Object lisp_node = make_treesit_node (parser, node);
- if (NILP (CALLN (Ffuncall, pred, lisp_node)))
+ if (NILP (CALLN (Ffuncall, cdr, lisp_node)))
return false;
return true;