1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-26 07:33:47 +00:00

Fix c-ts-mode indentation

Turns out I shouldn't have removed the explicit rules.  Anyway, now it
indents properly.

* lisp/progmodes/c-ts-mode.el (c-ts-mode--indent-styles): Add rules.
* test/lisp/progmodes/c-ts-mode-resources/indent.erts: Add tests
This commit is contained in:
Yuan Fu 2023-02-05 17:05:21 -08:00
parent d68ff6016d
commit 7cb92b5398
No known key found for this signature in database
GPG Key ID: 56E19BC57664A442
2 changed files with 20 additions and 0 deletions

View File

@ -287,6 +287,12 @@ MODE is either `c' or `cpp'."
((node-is "compound_statement") point-min c-ts-common-statement-offset)
;; Bug#61291.
((match "expression_statement" nil "body") point-min c-ts-common-statement-offset)
;; These rules are for cases where the body is bracketless.
;; Tested by the "Bracketless Simple Statement" test.
((parent-is "if_statement") point-min c-ts-common-statement-offset)
((parent-is "for_statement") point-min c-ts-common-statement-offset)
((parent-is "while_statement") point-min c-ts-common-statement-offset)
((parent-is "do_statement") point-min c-ts-common-statement-offset)
,@(when (eq mode 'cpp)
`(((node-is "field_initializer_list") parent-bol ,(* c-ts-mode-indent-offset 2)))))))

View File

@ -155,6 +155,20 @@ for (int i = 0;
;
=-=-=
Name: Bracketless Simple Statement
=-=
for (int i = 0; i < 5; i++)
continue;
while (true)
return 1;
do
i++;
while (true)
=-=-=
Name: Multiline Block Comments 1 (bug#60270)
=-=