Fix indentation for closing bracket in c-ts-mode (bug#61398)
* lisp/progmodes/c-ts-mode.el: (c-ts-mode--indent-styles): Move the rule earlier. (c-ts-base-mode): Add move block type. * test/lisp/progmodes/c-ts-mode-resources/indent.erts: New tests.
This commit is contained in:
parent
f49caaa892
commit
f2114e8d89
2 changed files with 35 additions and 3 deletions
|
@ -272,6 +272,11 @@ MODE is either `c' or `cpp'."
|
||||||
;; Indent the body of namespace definitions.
|
;; Indent the body of namespace definitions.
|
||||||
((parent-is "declaration_list") parent-bol c-ts-mode-indent-offset)))
|
((parent-is "declaration_list") parent-bol c-ts-mode-indent-offset)))
|
||||||
|
|
||||||
|
;; Closing bracket. This should be before initializer_list
|
||||||
|
;; (and probably others) rule because that rule (and other
|
||||||
|
;; similar rules) will match the closing bracket. (Bug#61398)
|
||||||
|
((node-is "}") point-min c-ts-common-statement-offset)
|
||||||
|
|
||||||
;; int[5] a = { 0, 0, 0, 0 };
|
;; int[5] a = { 0, 0, 0, 0 };
|
||||||
((parent-is "initializer_list") parent-bol c-ts-mode-indent-offset)
|
((parent-is "initializer_list") parent-bol c-ts-mode-indent-offset)
|
||||||
;; Statement in enum.
|
;; Statement in enum.
|
||||||
|
@ -281,8 +286,6 @@ MODE is either `c' or `cpp'."
|
||||||
|
|
||||||
;; Statement in {} blocks.
|
;; Statement in {} blocks.
|
||||||
((parent-is "compound_statement") point-min c-ts-common-statement-offset)
|
((parent-is "compound_statement") point-min c-ts-common-statement-offset)
|
||||||
;; Closing bracket.
|
|
||||||
((node-is "}") point-min c-ts-common-statement-offset)
|
|
||||||
;; Opening bracket.
|
;; Opening bracket.
|
||||||
((node-is "compound_statement") point-min c-ts-common-statement-offset)
|
((node-is "compound_statement") point-min c-ts-common-statement-offset)
|
||||||
;; Bug#61291.
|
;; Bug#61291.
|
||||||
|
@ -768,7 +771,9 @@ the semicolon. This function skips the semicolon."
|
||||||
(setq-local c-ts-common-indent-type-regexp-alist
|
(setq-local c-ts-common-indent-type-regexp-alist
|
||||||
`((block . ,(rx (or "compound_statement"
|
`((block . ,(rx (or "compound_statement"
|
||||||
"field_declaration_list"
|
"field_declaration_list"
|
||||||
"enumerator_list")))
|
"enumerator_list"
|
||||||
|
"initializer_list"
|
||||||
|
"field_declaration_list")))
|
||||||
(if . "if_statement")
|
(if . "if_statement")
|
||||||
(else . ("if_statement" . "alternative"))
|
(else . ("if_statement" . "alternative"))
|
||||||
(do . "do_statement")
|
(do . "do_statement")
|
||||||
|
|
|
@ -182,6 +182,20 @@ else if (false)
|
||||||
return 3;
|
return 3;
|
||||||
=-=-=
|
=-=-=
|
||||||
|
|
||||||
|
Name: Initializer List (Bug#61398)
|
||||||
|
|
||||||
|
=-=
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
const char *emoticons[][2] =
|
||||||
|
{
|
||||||
|
{":-)", "SLIGHTLY SMILING FACE"},
|
||||||
|
{";-)", "WINKING FACE"},
|
||||||
|
{":-(", "SLIGHTLY FROWNING FACE"},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
=-=-=
|
||||||
|
|
||||||
Name: Multiline Block Comments 1 (bug#60270)
|
Name: Multiline Block Comments 1 (bug#60270)
|
||||||
|
|
||||||
=-=
|
=-=
|
||||||
|
@ -327,3 +341,16 @@ void foo(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
=-=-=
|
=-=-=
|
||||||
|
|
||||||
|
Name: Initializer List (Linux Style) (Bug#61398)
|
||||||
|
|
||||||
|
=-=
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
const char *emoticons[][2] = {
|
||||||
|
{":-)", "SLIGHTLY SMILING FACE"},
|
||||||
|
{";-)", "WINKING FACE"},
|
||||||
|
{":-(", "SLIGHTLY FROWNING FACE"},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
=-=-=
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue