diff options
| author | Juri Linkov | 2024-12-19 09:33:22 +0200 |
|---|---|---|
| committer | Juri Linkov | 2024-12-19 09:33:22 +0200 |
| commit | ea865c98cf3c8a4e0216a81be1b9357a48e7b9a3 (patch) | |
| tree | 6e1a348439a7631b77ea1ced6f8681f2317e29e9 | |
| parent | d930d7f8651897dc3130ff16731751691566d490 (diff) | |
| download | emacs-ea865c98cf3c8a4e0216a81be1b9357a48e7b9a3.tar.gz emacs-ea865c98cf3c8a4e0216a81be1b9357a48e7b9a3.zip | |
Add treesit thing 'sexp-list' to some ts-modes (bug#73404)
* 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/textmodes/html-ts-mode.el (html-ts-mode):
Add 'sexp-list' to treesit-thing-settings.
* lisp/progmodes/js.el (js--treesit-sexp-list-nodes): New variable.
| -rw-r--r-- | lisp/progmodes/c-ts-mode.el | 21 | ||||
| -rw-r--r-- | lisp/progmodes/js.el | 23 | ||||
| -rw-r--r-- | lisp/progmodes/ruby-ts-mode.el | 41 | ||||
| -rw-r--r-- | lisp/textmodes/html-ts-mode.el | 1 |
4 files changed, 86 insertions, 0 deletions
diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 5e3194dd82e..cf1721d66ee 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el | |||
| @@ -1139,6 +1139,27 @@ if `c-ts-mode-emacs-sources-support' is non-nil." | |||
| 1139 | `(;; It's more useful to include semicolons as sexp so | 1139 | `(;; It's more useful to include semicolons as sexp so |
| 1140 | ;; that users can move to the end of a statement. | 1140 | ;; that users can move to the end of a statement. |
| 1141 | (sexp (not ,(rx (or "{" "}" "[" "]" "(" ")" ",")))) | 1141 | (sexp (not ,(rx (or "{" "}" "[" "]" "(" ")" ",")))) |
| 1142 | (sexp-list | ||
| 1143 | ,(regexp-opt '("preproc_params" | ||
| 1144 | "preproc_parenthesized_expression" | ||
| 1145 | "preproc_argument_list" | ||
| 1146 | "attribute_declaration" | ||
| 1147 | "declaration_list" | ||
| 1148 | "parenthesized_declarator" | ||
| 1149 | "parenthesized_field_declarator" | ||
| 1150 | "parenthesized_type_declarator" | ||
| 1151 | "abstract_parenthesized_declarator" | ||
| 1152 | "compound_statement" | ||
| 1153 | "enumerator_list" | ||
| 1154 | "field_declaration_list" | ||
| 1155 | "parameter_list" | ||
| 1156 | "argument_list" | ||
| 1157 | "parenthesized_expression" | ||
| 1158 | "initializer_list" | ||
| 1159 | "subscript_designator" | ||
| 1160 | "subscript_range_designator" | ||
| 1161 | "string_literal") | ||
| 1162 | 'symbols)) | ||
| 1142 | ;; compound_statement makes us jump over too big units | 1163 | ;; compound_statement makes us jump over too big units |
| 1143 | ;; of code, so skip that one, and include the other | 1164 | ;; of code, so skip that one, and include the other |
| 1144 | ;; statements. | 1165 | ;; statements. |
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 5515b58269a..1b6565f66c2 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el | |||
| @@ -3866,6 +3866,28 @@ See `treesit-thing-settings' for more information.") | |||
| 3866 | "Nodes that designate sexps in JavaScript. | 3866 | "Nodes that designate sexps in JavaScript. |
| 3867 | See `treesit-thing-settings' for more information.") | 3867 | See `treesit-thing-settings' for more information.") |
| 3868 | 3868 | ||
| 3869 | (defvar js--treesit-sexp-list-nodes | ||
| 3870 | '("export_clause" | ||
| 3871 | "named_imports" | ||
| 3872 | "statement_block" | ||
| 3873 | "_for_header" | ||
| 3874 | "switch_body" | ||
| 3875 | "parenthesized_expression" | ||
| 3876 | "object" | ||
| 3877 | "object_pattern" | ||
| 3878 | "array" | ||
| 3879 | "array_pattern" | ||
| 3880 | "jsx_expression" | ||
| 3881 | "_jsx_string" | ||
| 3882 | "string" | ||
| 3883 | "regex" | ||
| 3884 | "arguments" | ||
| 3885 | "class_body" | ||
| 3886 | "formal_parameters" | ||
| 3887 | "computed_property_name") | ||
| 3888 | "Nodes that designate lists in JavaScript. | ||
| 3889 | See `treesit-thing-settings' for more information.") | ||
| 3890 | |||
| 3869 | (defvar js--treesit-jsdoc-beginning-regexp (rx bos "/**") | 3891 | (defvar js--treesit-jsdoc-beginning-regexp (rx bos "/**") |
| 3870 | "Regular expression matching the beginning of a jsdoc block comment.") | 3892 | "Regular expression matching the beginning of a jsdoc block comment.") |
| 3871 | 3893 | ||
| @@ -3909,6 +3931,7 @@ See `treesit-thing-settings' for more information.") | |||
| 3909 | (setq-local treesit-thing-settings | 3931 | (setq-local treesit-thing-settings |
| 3910 | `((javascript | 3932 | `((javascript |
| 3911 | (sexp ,(js--regexp-opt-symbol js--treesit-sexp-nodes)) | 3933 | (sexp ,(js--regexp-opt-symbol js--treesit-sexp-nodes)) |
| 3934 | (sexp-list ,(js--regexp-opt-symbol js--treesit-sexp-list-nodes)) | ||
| 3912 | (sentence ,(js--regexp-opt-symbol js--treesit-sentence-nodes)) | 3935 | (sentence ,(js--regexp-opt-symbol js--treesit-sentence-nodes)) |
| 3913 | (text ,(js--regexp-opt-symbol '("comment" | 3936 | (text ,(js--regexp-opt-symbol '("comment" |
| 3914 | "string_fragment")))))) | 3937 | "string_fragment")))))) |
diff --git a/lisp/progmodes/ruby-ts-mode.el b/lisp/progmodes/ruby-ts-mode.el index 58a7eab0d1a..4ef0cb18eae 100644 --- a/lisp/progmodes/ruby-ts-mode.el +++ b/lisp/progmodes/ruby-ts-mode.el | |||
| @@ -1195,6 +1195,47 @@ leading double colon is not added." | |||
| 1195 | ) | 1195 | ) |
| 1196 | eol) | 1196 | eol) |
| 1197 | #'ruby-ts--sexp-p)) | 1197 | #'ruby-ts--sexp-p)) |
| 1198 | (sexp-list | ||
| 1199 | ,(cons (rx | ||
| 1200 | bol | ||
| 1201 | (or | ||
| 1202 | "begin_block" | ||
| 1203 | "end_block" | ||
| 1204 | "method" | ||
| 1205 | "singleton_method" | ||
| 1206 | "method_parameters" | ||
| 1207 | "parameters" | ||
| 1208 | "block_parameters" | ||
| 1209 | "class" | ||
| 1210 | "singleton_class" | ||
| 1211 | "module" | ||
| 1212 | "do" | ||
| 1213 | "case" | ||
| 1214 | "case_match" | ||
| 1215 | "array_pattern" | ||
| 1216 | "find_pattern" | ||
| 1217 | "hash_pattern" | ||
| 1218 | "parenthesized_pattern" | ||
| 1219 | "expression_reference_pattern" | ||
| 1220 | "if" | ||
| 1221 | "unless" | ||
| 1222 | "begin" | ||
| 1223 | "parenthesized_statements" | ||
| 1224 | "argument_list" | ||
| 1225 | "do_block" | ||
| 1226 | "block" | ||
| 1227 | "destructured_left_assignment" | ||
| 1228 | "interpolation" | ||
| 1229 | "string" | ||
| 1230 | "string_array" | ||
| 1231 | "symbol_array" | ||
| 1232 | "delimited_symbol" | ||
| 1233 | "regex" | ||
| 1234 | "heredoc_body" | ||
| 1235 | "array" | ||
| 1236 | "hash") | ||
| 1237 | eol) | ||
| 1238 | #'ruby-ts--sexp-p)) | ||
| 1198 | (text ,(lambda (node) | 1239 | (text ,(lambda (node) |
| 1199 | (or (member (treesit-node-type node) | 1240 | (or (member (treesit-node-type node) |
| 1200 | '("comment" "string_content" "heredoc_content")) | 1241 | '("comment" "string_content" "heredoc_content")) |
diff --git a/lisp/textmodes/html-ts-mode.el b/lisp/textmodes/html-ts-mode.el index f78fbdde1da..875ab267fd8 100644 --- a/lisp/textmodes/html-ts-mode.el +++ b/lisp/textmodes/html-ts-mode.el | |||
| @@ -108,6 +108,7 @@ Return nil if there is no name or if NODE is not a defun node." | |||
| 108 | "text" | 108 | "text" |
| 109 | "attribute" | 109 | "attribute" |
| 110 | "value"))) | 110 | "value"))) |
| 111 | (sexp-list ,(regexp-opt '("element")) 'symbols) | ||
| 111 | (sentence "tag") | 112 | (sentence "tag") |
| 112 | (text ,(regexp-opt '("comment" "text")))))) | 113 | (text ,(regexp-opt '("comment" "text")))))) |
| 113 | 114 | ||