emacs/test/lisp/progmodes/c-ts-mode-resources/indent.erts
Yuan Fu 7292b24c80
Fix c-ts-mode indentation
Not the subject of it, but mentioned in bug#61893.

* lisp/progmodes/c-ts-mode.el (c-ts-mode--anchor-prev-sibling): Skip
the sibling if it doesn't start on it's own line.
* test/lisp/progmodes/c-ts-mode-resources/indent.erts: New test.
2023-03-05 15:01:54 -08:00

420 lines
5 KiB
Text

Code:
(lambda ()
(c-ts-mode)
(setq-local indent-tabs-mode nil)
(setq-local c-ts-mode-indent-offset 2)
(c-ts-mode-set-style 'gnu)
(indent-region (point-min) (point-max)))
Point-Char: |
Name: Basic
=-=
int
main (void)
{
return 0;
}
=-=-=
Name: Hanging Braces (GNU Style)
=-=
int
main (void)
{
if (true)
{
}
}
=-=-=
Name: Labels (GNU Style)
=-=
int
main (void)
{
label:
return 0;
if (true)
{
label:
return 0;
}
else
{
if (true)
{
label:
return 0;
}
}
}
=-=-=
Name: For Loop with Multi-line Condition (GNU Style)
=-=
int main()
{
for (int i = 0;
i < b;
i++)
{
return 0;
}
}
=-=-=
Name: If-Else (GNU Style)
=-=
int main()
{
if (true)
{
return 0;
}
else
{
return 1;
}
}
=-=-=
Name: Concecutive blocks (GNU Style) (bug#60873)
=-=
int
main (int argc,
char *argv[])
{
{
int i = 0;
}
}
=-=-=
Name: Bracket-less Block-Statement (GNU Style) (bug#61026)
=-=
int main() {
while (true)
if (true)
{
puts ("Hello");
}
for (int i=0;
i<5;
i++)
if (true)
{
puts ("Hello");
}
do
if (true)
{
puts ("Hello");
}
while (true);
if (true)
if (true)
{
puts ("Hello");
}
}
=-=-=
Name: Multiline Parameter List (bug#60398)
=-=
int f2(int x,
int y) {
return x + y;
};
=-=-=
Name: Semi-colon in While Loop (bug#61291)
=-=
while (true)
;
for (int i = 0;
i < 5;
i++)
;
=-=-=
Name: Bracketless Simple Statement
=-=
for (int i = 0; i < 5; i++)
continue;
while (true)
return 1;
do
i++;
while (true)
=-=-=
Name: Nested If-Else
=-=
if (true)
return 0;
else if (false)
return 1;
else if (true)
return 2;
else if (false)
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)
=-=
/**
* @some_func:
* @arg1:
*/
=-=-=
Name: Multiline Block Comments 2 (bug#60270)
=-=
/*
some comment
*/
=-=-=
Name: Multiline Block Comments 3 (bug#60270)
=-=
/* some comment
*/
=-=-=
Name: Multiline Block Comments 4 (bug#60270)
=-=
/*
* Some comment
*/
=-=-=
Name: Multiline Block Comments 5 (bug#60270)
=-=
/*
line one
line 2
*/
=-=
/*
line one
line 2
*/
=-=-=
Name: Block Comment prefixes (Bug#61314)
=-=-=
/*
- item1
- item2
- item3
*/
=-=-=
/*
- item1
- item2
- item3
*/
=-=-=
Code:
(lambda ()
(c-ts-mode)
(setq-local indent-tabs-mode nil)
(setq-local c-ts-mode-indent-offset 8)
(c-ts-mode-set-style 'linux)
(indent-region (point-min) (point-max)))
Name: Labels (Linux Style)
=-=-=
int main (void)
{
label:
return 0;
if (true) {
label:
return 0;
}
else {
if (true) {
label:
return 0;
}
}
}
=-=-=
Name: Bracket-less Block-Statement (Linux Style) (bug#61026)
=-=-=
int main() {
while (true)
if (true) {
puts ("Hello");
}
for (int i=0;
i<5;
i++)
if (true) {
puts ("Hello");
}
do
if (true) {
puts ("Hello");
}
while (true);
if (true)
if (true) {
puts ("Hello");
}
}
=-=-=
Name: Complicated mixed bracket matching indentation (bug#61142)
=-=
void foo(
int foo) {
for (;;)
return 5;
if (a == 0
&& b == 1
&& foo)
{
return 0;
}
else if (a == 1)
{
return 1;
}
else if (true)
return 5;
else
{
if (a == 0
&& b == 1
&& foo)
for (
int i = 0;
i < 5;
i++)
if (true)
do
i = 5;
while (true);
else if (false)
{
return 6;
}
else
if (true
&& false)
return 6;
}
}
=-=-=
Name: Initializer List (Linux Style) (Bug#61398)
=-=
int main()
{
const char *emoticons[][2] = {
{":-)", "SLIGHTLY SMILING FACE"},
{";-)", "WINKING FACE"},
{":-(", "SLIGHTLY FROWNING FACE"},
};
}
=-=-=
Code:
(lambda ()
(c++-ts-mode)
(setq-local indent-tabs-mode nil)
(setq-local c-ts-mode-indent-offset 2)
(indent-region (point-min) (point-max)))
Name: Declaration List (Namespace) (Bug#61635)
=-=
namespace test {
class Name {
};
}
=-=-=
Code:
(lambda ()
(c-ts-mode)
(setq-local indent-tabs-mode nil)
(setq-local c-ts-mode-indent-offset 2)
(c-ts-mode-set-style 'gnu)
(indent-for-tab-command))
Name: Empty Line
=-=
int main()
{
|
}
=-=-=
Name: Empty Line Previous Sibling
=-=
int main()
{
int a = 1;
|
}
=-=-=
Name: Prev-Sibling But Not Trailing Comment
=-=
static int
required_matrix_height (struct window *w)
{
#ifdef HAVE_WINDOW_SYSTEM
if (FRAME_WINDOW_P (f))
{
return 0;
}
#endif /* Don't align to this comment. */
|
}
=-=-=