aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBasil L. Contovounesios2023-06-03 11:25:05 +0100
committerBasil L. Contovounesios2023-07-08 17:05:05 +0100
commit8ffe8422c53e196787c6f404e4cadc7029a7fbd9 (patch)
treebb18dd7b85cc4eb63fd85f6d44736323b4922732 /src
parentac57358762b42a7f0d7f70ce55ed0e7c4b540d16 (diff)
downloademacs-8ffe8422c53e196787c6f404e4cadc7029a7fbd9.tar.gz
emacs-8ffe8422c53e196787c6f404e4cadc7029a7fbd9.zip
Minor tree-sitter cleanups
* lisp/treesit.el (treesit-fontify-with-override): Fix docstring grammar. Remove redundant precondition (bug#64052). * src/treesit.c (Ftreesit_parser_set_included_ranges): Fix typo in commentary. (treesit_predicate_equal, treesit_predicate_match) (treesit_predicate_pred): Avoid fixnum roundtrip by using list_length in place of Flength. Make error messages more accurate. (treesit_eval_predicates): Quote predicate names in error message.
Diffstat (limited to 'src')
-rw-r--r--src/treesit.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/treesit.c b/src/treesit.c
index d7ccab85908..1f694e47201 100644
--- a/src/treesit.c
+++ b/src/treesit.c
@@ -1649,7 +1649,7 @@ buffer. */)
1649 TSRange *treesit_ranges = xmalloc (sizeof (TSRange) * len); 1649 TSRange *treesit_ranges = xmalloc (sizeof (TSRange) * len);
1650 struct buffer *buffer = XBUFFER (XTS_PARSER (parser)->buffer); 1650 struct buffer *buffer = XBUFFER (XTS_PARSER (parser)->buffer);
1651 1651
1652 /* We can use XFUXNUM, XCAR, XCDR freely because we have checked 1652 /* We can use XFIXNUM, XCAR, XCDR freely because we have checked
1653 the input by treesit_check_range_argument. */ 1653 the input by treesit_check_range_argument. */
1654 1654
1655 for (int idx = 0; !NILP (ranges); idx++, ranges = XCDR (ranges)) 1655 for (int idx = 0; !NILP (ranges); idx++, ranges = XCDR (ranges))
@@ -2546,10 +2546,10 @@ static bool
2546treesit_predicate_equal (Lisp_Object args, struct capture_range captures, 2546treesit_predicate_equal (Lisp_Object args, struct capture_range captures,
2547 Lisp_Object *signal_data) 2547 Lisp_Object *signal_data)
2548{ 2548{
2549 if (XFIXNUM (Flength (args)) != 2) 2549 if (list_length (args) != 2)
2550 { 2550 {
2551 *signal_data = list2 (build_string ("Predicate `equal' requires " 2551 *signal_data = list2 (build_string ("Predicate `equal' requires "
2552 "two arguments but only given"), 2552 "two arguments but got"),
2553 Flength (args)); 2553 Flength (args));
2554 return false; 2554 return false;
2555 } 2555 }
@@ -2581,10 +2581,10 @@ static bool
2581treesit_predicate_match (Lisp_Object args, struct capture_range captures, 2581treesit_predicate_match (Lisp_Object args, struct capture_range captures,
2582 Lisp_Object *signal_data) 2582 Lisp_Object *signal_data)
2583{ 2583{
2584 if (XFIXNUM (Flength (args)) != 2) 2584 if (list_length (args) != 2)
2585 { 2585 {
2586 *signal_data = list2 (build_string ("Predicate `match' requires two " 2586 *signal_data = list2 (build_string ("Predicate `match' requires two "
2587 "arguments but only given"), 2587 "arguments but got"),
2588 Flength (args)); 2588 Flength (args));
2589 return false; 2589 return false;
2590 } 2590 }
@@ -2646,11 +2646,11 @@ static bool
2646treesit_predicate_pred (Lisp_Object args, struct capture_range captures, 2646treesit_predicate_pred (Lisp_Object args, struct capture_range captures,
2647 Lisp_Object *signal_data) 2647 Lisp_Object *signal_data)
2648{ 2648{
2649 if (XFIXNUM (Flength (args)) < 2) 2649 if (list_length (args) < 2)
2650 { 2650 {
2651 *signal_data = list2 (build_string ("Predicate `pred' requires " 2651 *signal_data = list2 (build_string ("Predicate `pred' requires "
2652 "at least two arguments, " 2652 "at least two arguments, "
2653 "but was only given"), 2653 "but only got"),
2654 Flength (args)); 2654 Flength (args));
2655 return false; 2655 return false;
2656 } 2656 }
@@ -2671,7 +2671,7 @@ treesit_predicate_pred (Lisp_Object args, struct capture_range captures,
2671 return !NILP (CALLN (Fapply, fn, nodes)); 2671 return !NILP (CALLN (Fapply, fn, nodes));
2672} 2672}
2673 2673
2674/* If all predicates in PREDICATES passes, return true; otherwise 2674/* If all predicates in PREDICATES pass, return true; otherwise
2675 return false. If everything goes fine, don't touch SIGNAL_DATA; if 2675 return false. If everything goes fine, don't touch SIGNAL_DATA; if
2676 error occurs, set it to a suitable signal data. */ 2676 error occurs, set it to a suitable signal data. */
2677static bool 2677static bool
@@ -2696,7 +2696,7 @@ treesit_eval_predicates (struct capture_range captures, Lisp_Object predicates,
2696 { 2696 {
2697 *signal_data = list3 (build_string ("Invalid predicate"), 2697 *signal_data = list3 (build_string ("Invalid predicate"),
2698 fn, build_string ("Currently Emacs only supports" 2698 fn, build_string ("Currently Emacs only supports"
2699 " equal, match, and pred" 2699 " `equal', `match', and `pred'"
2700 " predicates")); 2700 " predicates"));
2701 pass = false; 2701 pass = false;
2702 } 2702 }