diff options
| author | Juri Linkov | 2025-02-12 20:31:22 +0200 |
|---|---|---|
| committer | Juri Linkov | 2025-02-12 20:31:22 +0200 |
| commit | 44c11cd4241ffc8636135bc41ac718101666d34d (patch) | |
| tree | ebd0debd5cfe42f9e0645bb267ea4adc15723a28 | |
| parent | b514ec87b618e4ee9a95b248eb55c5e0cc69949c (diff) | |
| download | emacs-44c11cd4241ffc8636135bc41ac718101666d34d.tar.gz emacs-44c11cd4241ffc8636135bc41ac718101666d34d.zip | |
Fix treesit-outline related settings
* lisp/treesit.el (treesit-outline-level): Use level 1 by default
since treesit-outline--at-point now always returns the current node.
* lisp/progmodes/ruby-ts-mode.el (ruby-ts-mode):
Use 'bos' instead of 'bol'. Add "singleton_class" to
'treesit-outline-predicate'. Use new condition 'named' in
'treesit-outline-predicate' (bug#74963).
| -rw-r--r-- | lisp/progmodes/ruby-ts-mode.el | 99 | ||||
| -rw-r--r-- | lisp/treesit.el | 5 |
2 files changed, 52 insertions, 52 deletions
diff --git a/lisp/progmodes/ruby-ts-mode.el b/lisp/progmodes/ruby-ts-mode.el index 15394f28b27..551271275d7 100644 --- a/lisp/progmodes/ruby-ts-mode.el +++ b/lisp/progmodes/ruby-ts-mode.el | |||
| @@ -1168,7 +1168,7 @@ leading double colon is not added." | |||
| 1168 | (setq-local treesit-thing-settings | 1168 | (setq-local treesit-thing-settings |
| 1169 | `((ruby | 1169 | `((ruby |
| 1170 | (sexp ,(cons (rx | 1170 | (sexp ,(cons (rx |
| 1171 | bol | 1171 | bos |
| 1172 | (or | 1172 | (or |
| 1173 | "class" | 1173 | "class" |
| 1174 | "singleton_class" | 1174 | "singleton_class" |
| @@ -1211,49 +1211,48 @@ leading double colon is not added." | |||
| 1211 | "instance_variable" | 1211 | "instance_variable" |
| 1212 | "global_variable" | 1212 | "global_variable" |
| 1213 | ) | 1213 | ) |
| 1214 | eol) | 1214 | eos) |
| 1215 | #'ruby-ts--sexp-p)) | 1215 | #'ruby-ts--sexp-p)) |
| 1216 | (list | 1216 | (list ,(cons (rx |
| 1217 | ,(cons (rx | 1217 | bos |
| 1218 | bol | 1218 | (or |
| 1219 | (or | 1219 | "begin_block" |
| 1220 | "begin_block" | 1220 | "end_block" |
| 1221 | "end_block" | 1221 | "method" |
| 1222 | "method" | 1222 | "singleton_method" |
| 1223 | "singleton_method" | 1223 | "method_parameters" |
| 1224 | "method_parameters" | 1224 | "parameters" |
| 1225 | "parameters" | 1225 | "block_parameters" |
| 1226 | "block_parameters" | 1226 | "class" |
| 1227 | "class" | 1227 | "singleton_class" |
| 1228 | "singleton_class" | 1228 | "module" |
| 1229 | "module" | 1229 | "do" |
| 1230 | "do" | 1230 | "case" |
| 1231 | "case" | 1231 | "case_match" |
| 1232 | "case_match" | 1232 | "array_pattern" |
| 1233 | "array_pattern" | 1233 | "find_pattern" |
| 1234 | "find_pattern" | 1234 | "hash_pattern" |
| 1235 | "hash_pattern" | 1235 | "parenthesized_pattern" |
| 1236 | "parenthesized_pattern" | 1236 | "expression_reference_pattern" |
| 1237 | "expression_reference_pattern" | 1237 | "if" |
| 1238 | "if" | 1238 | "unless" |
| 1239 | "unless" | 1239 | "begin" |
| 1240 | "begin" | 1240 | "parenthesized_statements" |
| 1241 | "parenthesized_statements" | 1241 | "argument_list" |
| 1242 | "argument_list" | 1242 | "do_block" |
| 1243 | "do_block" | 1243 | "block" |
| 1244 | "block" | 1244 | "destructured_left_assignment" |
| 1245 | "destructured_left_assignment" | 1245 | "interpolation" |
| 1246 | "interpolation" | 1246 | "string" |
| 1247 | "string" | 1247 | "string_array" |
| 1248 | "string_array" | 1248 | "symbol_array" |
| 1249 | "symbol_array" | 1249 | "delimited_symbol" |
| 1250 | "delimited_symbol" | 1250 | "regex" |
| 1251 | "regex" | 1251 | "heredoc_body" |
| 1252 | "heredoc_body" | 1252 | "array" |
| 1253 | "array" | 1253 | "hash") |
| 1254 | "hash") | 1254 | eos) |
| 1255 | eol) | 1255 | #'ruby-ts--list-p)) |
| 1256 | #'ruby-ts--list-p)) | ||
| 1257 | (text ,(lambda (node) | 1256 | (text ,(lambda (node) |
| 1258 | (or (member (treesit-node-type node) | 1257 | (or (member (treesit-node-type node) |
| 1259 | '("comment" "string_content" "heredoc_content")) | 1258 | '("comment" "string_content" "heredoc_content")) |
| @@ -1275,12 +1274,14 @@ leading double colon is not added." | |||
| 1275 | 1274 | ||
| 1276 | ;; Outline minor mode. | 1275 | ;; Outline minor mode. |
| 1277 | (setq-local treesit-outline-predicate | 1276 | (setq-local treesit-outline-predicate |
| 1278 | (rx bos (or "singleton_method" | 1277 | `(and ,(rx bos (or "singleton_method" |
| 1279 | "method" | 1278 | "method" |
| 1280 | "alias" | 1279 | "alias" |
| 1281 | "class" | 1280 | "singleton_class" |
| 1282 | "module") | 1281 | "class" |
| 1283 | eos)) | 1282 | "module") |
| 1283 | eos) | ||
| 1284 | named)) | ||
| 1284 | ;; Restore default values of outline variables | 1285 | ;; Restore default values of outline variables |
| 1285 | ;; to use `treesit-outline-predicate'. | 1286 | ;; to use `treesit-outline-predicate'. |
| 1286 | (kill-local-variable 'outline-regexp) | 1287 | (kill-local-variable 'outline-regexp) |
diff --git a/lisp/treesit.el b/lisp/treesit.el index 49b81a2c87f..e67e2cc43f6 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el | |||
| @@ -3501,7 +3501,7 @@ when a major mode sets it.") | |||
| 3501 | treesit-simple-imenu-settings)) | 3501 | treesit-simple-imenu-settings)) |
| 3502 | 3502 | ||
| 3503 | (defun treesit-outline--at-point () | 3503 | (defun treesit-outline--at-point () |
| 3504 | "Return the outline heading at the current line." | 3504 | "Return the outline heading node at the current line." |
| 3505 | (let* ((pred treesit-outline-predicate) | 3505 | (let* ((pred treesit-outline-predicate) |
| 3506 | (bol (pos-bol)) | 3506 | (bol (pos-bol)) |
| 3507 | (eol (pos-eol)) | 3507 | (eol (pos-eol)) |
| @@ -3551,8 +3551,7 @@ For BOUND, MOVE, BACKWARD, LOOKING-AT, see the descriptions in | |||
| 3551 | (defun treesit-outline-level () | 3551 | (defun treesit-outline-level () |
| 3552 | "Return the depth of the current outline heading." | 3552 | "Return the depth of the current outline heading." |
| 3553 | (let* ((node (treesit-outline--at-point)) | 3553 | (let* ((node (treesit-outline--at-point)) |
| 3554 | (level (if (treesit-node-match-p node treesit-outline-predicate) | 3554 | (level 1)) |
| 3555 | 1 0))) | ||
| 3556 | (while (setq node (treesit-parent-until node treesit-outline-predicate)) | 3555 | (while (setq node (treesit-parent-until node treesit-outline-predicate)) |
| 3557 | (setq level (1+ level))) | 3556 | (setq level (1+ level))) |
| 3558 | (if (zerop level) 1 level))) | 3557 | (if (zerop level) 1 level))) |