aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJuri Linkov2025-01-10 09:33:49 +0200
committerJuri Linkov2025-01-10 09:33:49 +0200
commit42a5ac3b513ff03c64c9609fc7e79c2b7932b2a4 (patch)
tree06b2ef0583b21d7095a476c22c1fb936fa375741 /src
parent351b6ac16d29459c5800bd980d428e61ee43cb7d (diff)
downloademacs-42a5ac3b513ff03c64c9609fc7e79c2b7932b2a4.tar.gz
emacs-42a5ac3b513ff03c64c9609fc7e79c2b7932b2a4.zip
Use the treesit thing 'list' with symbol property 'treesit-thing-symbol'
* doc/lispref/parsing.texi (User-defined Things): Mention new functions 'treesit-forward-list', 'treesit-down-list', 'treesit-up-list', 'treesit-show-paren-data' that use the thing 'list' with the symbol property 'treesit-thing-symbol' (bug#73404). * lisp/treesit.el: Put the property 'treesit-thing-symbol' on the symbol 'list'. (treesit--forward-list-with-default, treesit-down-list) (treesit-up-list, treesit-navigate-thing) (treesit-show-paren-data--categorize, treesit-major-mode-setup): Replace 'sexp-list' with 'list'. * lisp/progmodes/c-ts-mode.el (c-ts-mode--thing-settings): * lisp/progmodes/js.el (js-ts-mode): * lisp/progmodes/ruby-ts-mode.el (ruby-ts-mode): * lisp/progmodes/typescript-ts-mode.el (typescript-ts-base-mode) (tsx-ts-mode): * lisp/textmodes/html-ts-mode.el (html-ts-mode): Replace 'sexp-list' with 'list'. * src/treesit.c (treesit_traverse_validate_predicate) (treesit_traverse_match_predicate): Check if the 'pred' symbol has the property 'Qtreesit_thing_symbol'. (syms_of_treesit): New symbol 'Qtreesit_thing_symbol'.
Diffstat (limited to 'src')
-rw-r--r--src/treesit.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/treesit.c b/src/treesit.c
index b3214dad836..878c1f0b340 100644
--- a/src/treesit.c
+++ b/src/treesit.c
@@ -3618,7 +3618,8 @@ treesit_traverse_validate_predicate (Lisp_Object pred,
3618 } 3618 }
3619 if (STRINGP (pred)) 3619 if (STRINGP (pred))
3620 return true; 3620 return true;
3621 else if (FUNCTIONP (pred)) 3621 else if (FUNCTIONP (pred)
3622 && !(SYMBOLP (pred) && !NILP (Fget (pred, Qtreesit_thing_symbol))))
3622 return true; 3623 return true;
3623 else if (SYMBOLP (pred)) 3624 else if (SYMBOLP (pred))
3624 { 3625 {
@@ -3722,7 +3723,8 @@ treesit_traverse_match_predicate (TSTreeCursor *cursor, Lisp_Object pred,
3722 const char *type = ts_node_type (node); 3723 const char *type = ts_node_type (node);
3723 return fast_c_string_match (pred, type, strlen (type)) >= 0; 3724 return fast_c_string_match (pred, type, strlen (type)) >= 0;
3724 } 3725 }
3725 else if (FUNCTIONP (pred)) 3726 else if (FUNCTIONP (pred)
3727 && !(SYMBOLP (pred) && !NILP (Fget (pred, Qtreesit_thing_symbol))))
3726 { 3728 {
3727 Lisp_Object lisp_node = make_treesit_node (parser, node); 3729 Lisp_Object lisp_node = make_treesit_node (parser, node);
3728 return !NILP (CALLN (Ffuncall, pred, lisp_node)); 3730 return !NILP (CALLN (Ffuncall, pred, lisp_node));
@@ -4333,6 +4335,8 @@ syms_of_treesit (void)
4333 DEFSYM (Qtreesit_invalid_predicate, "treesit-invalid-predicate"); 4335 DEFSYM (Qtreesit_invalid_predicate, "treesit-invalid-predicate");
4334 DEFSYM (Qtreesit_predicate_not_found, "treesit-predicate-not-found"); 4336 DEFSYM (Qtreesit_predicate_not_found, "treesit-predicate-not-found");
4335 4337
4338 DEFSYM (Qtreesit_thing_symbol, "treesit-thing-symbol");
4339
4336 DEFSYM (Qor, "or"); 4340 DEFSYM (Qor, "or");
4337 4341
4338#ifdef WINDOWSNT 4342#ifdef WINDOWSNT