* bug#60270: 29.0.60; c-ts-mode: Comments are not indented right on auto indentation
2022-12-23 9:30 bug#60270: 29.0.60; c-ts-mode: Comments are not indented right on auto indentation Mohammed Sadiq
@ 2022-12-24 8:33 ` Yuan Fu
2022-12-24 9:49 ` Mohammed Sadiq
2022-12-24 22:32 ` Yuan Fu
` (5 subsequent siblings)
6 siblings, 1 reply; 20+ messages in thread
From: Yuan Fu @ 2022-12-24 8:33 UTC (permalink / raw)
To: sadiq; +Cc: 60270
Mohammed Sadiq <sadiq@sadiqpk.org> writes:
> In c-ts-mode, comments are indented wrong. Say for example, if a C
> source file contains the following content:
>
> /**
> * @some_func:
> * @arg1:
> */
>
>
> and if I select all and indent with C-x h TAB, I get the following:
>
> /**
> * @some_func:
> * @arg1:
> */
>
> But I expect to get the following:
>
> /**
> * @some_func:
> * @arg1:
> */
Should be fixed now, please give it a try :-)
Yuan
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#60270: 29.0.60; c-ts-mode: Comments are not indented right on auto indentation
2022-12-24 8:33 ` Yuan Fu
@ 2022-12-24 9:49 ` Mohammed Sadiq
0 siblings, 0 replies; 20+ messages in thread
From: Mohammed Sadiq @ 2022-12-24 9:49 UTC (permalink / raw)
To: Yuan Fu; +Cc: 60270
On 2022-12-24 14:03, Yuan Fu wrote:
> Mohammed Sadiq <sadiq@sadiqpk.org> writes:
>
>> In c-ts-mode, comments are indented wrong. Say for example, if a C
>> source file contains the following content:
>>
>> /**
>> * @some_func:
>> * @arg1:
>> */
>>
>>
>> and if I select all and indent with C-x h TAB, I get the following:
>>
>> /**
>> * @some_func:
>> * @arg1:
>> */
>>
>> But I expect to get the following:
>>
>> /**
>> * @some_func:
>> * @arg1:
>> */
>
> Should be fixed now, please give it a try :-)
>
> Yuan
Yes, it does work now, thanks.
Can this be more in par with c-mode. Not strictly required, but would
be nice to have if someone used to use c-mode and migrated to c-ts-mode
and indented the code with select all and TAB (to avoid unnecessary
change).
The test cases are:
/*
some comment
*/
/*
* Some comment
*/
cheers,
Mohammed Sadiq
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#60270: 29.0.60; c-ts-mode: Comments are not indented right on auto indentation
2022-12-23 9:30 bug#60270: 29.0.60; c-ts-mode: Comments are not indented right on auto indentation Mohammed Sadiq
2022-12-24 8:33 ` Yuan Fu
@ 2022-12-24 22:32 ` Yuan Fu
2022-12-25 4:34 ` Mohammed Sadiq
2022-12-25 8:36 ` Yuan Fu
` (4 subsequent siblings)
6 siblings, 1 reply; 20+ messages in thread
From: Yuan Fu @ 2022-12-24 22:32 UTC (permalink / raw)
To: sadiq; +Cc: 60270
Mohammed Sadiq <sadiq@sadiqpk.org> writes:
> On 2022-12-24 14:03, Yuan Fu wrote:
>> Mohammed Sadiq <sadiq@sadiqpk.org> writes:
>>
>>> In c-ts-mode, comments are indented wrong. Say for example, if a C
>>> source file contains the following content:
>>> /**
>>> * @some_func:
>>> * @arg1:
>>> */
>>> and if I select all and indent with C-x h TAB, I get the following:
>>> /**
>>> * @some_func:
>>> * @arg1:
>>> */
>>> But I expect to get the following:
>>> /**
>>> * @some_func:
>>> * @arg1:
>>> */
>> Should be fixed now, please give it a try :-)
>> Yuan
>
>
> Yes, it does work now, thanks.
>
> Can this be more in par with c-mode. Not strictly required, but would
> be nice to have if someone used to use c-mode and migrated to c-ts-mode
> and indented the code with select all and TAB (to avoid unnecessary
> change).
>
> The test cases are:
>
> /*
> some comment
> */
>
> /*
> * Some comment
> */
I didn’t quite get it, what’s the expected behavior you are looking for?
The two example indents like the following right now:
/*
some comment
*/
/*
* Some comment
*/
Yuan
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#60270: 29.0.60; c-ts-mode: Comments are not indented right on auto indentation
2022-12-24 22:32 ` Yuan Fu
@ 2022-12-25 4:34 ` Mohammed Sadiq
0 siblings, 0 replies; 20+ messages in thread
From: Mohammed Sadiq @ 2022-12-25 4:34 UTC (permalink / raw)
To: Yuan Fu; +Cc: 60270
On 2022-12-25 04:02, Yuan Fu wrote:
> Mohammed Sadiq <sadiq@sadiqpk.org> writes:
>
>> On 2022-12-24 14:03, Yuan Fu wrote:
>>> Mohammed Sadiq <sadiq@sadiqpk.org> writes:
>>>
>>>> In c-ts-mode, comments are indented wrong. Say for example, if a C
>>>> source file contains the following content:
>>>> /**
>>>> * @some_func:
>>>> * @arg1:
>>>> */
>>>> and if I select all and indent with C-x h TAB, I get the following:
>>>> /**
>>>> * @some_func:
>>>> * @arg1:
>>>> */
>>>> But I expect to get the following:
>>>> /**
>>>> * @some_func:
>>>> * @arg1:
>>>> */
>>> Should be fixed now, please give it a try :-)
>>> Yuan
>>
>>
>> Yes, it does work now, thanks.
>>
>> Can this be more in par with c-mode. Not strictly required, but would
>> be nice to have if someone used to use c-mode and migrated to
>> c-ts-mode
>> and indented the code with select all and TAB (to avoid unnecessary
>> change).
>>
>> The test cases are:
>>
>> /*
>> some comment
>> */
>>
>> /*
>> * Some comment
>> */
>
> I didn’t quite get it, what’s the expected behavior you are looking
> for?
> The two example indents like the following right now:
>
> /*
> some comment
> */
>
>
> /*
> * Some comment
> */
>
>
> Yuan
On buffer select-all TAB, for the following comment:
/*
hello
*/
I get the following in c-mode (no space before */):
/*
hello
*/
and the following in c-ts-mode (a space before */):
/*
hello
*/
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#60270: 29.0.60; c-ts-mode: Comments are not indented right on auto indentation
2022-12-23 9:30 bug#60270: 29.0.60; c-ts-mode: Comments are not indented right on auto indentation Mohammed Sadiq
2022-12-24 8:33 ` Yuan Fu
2022-12-24 22:32 ` Yuan Fu
@ 2022-12-25 8:36 ` Yuan Fu
2022-12-25 9:25 ` Eli Zaretskii
2022-12-25 9:46 ` Mohammed Sadiq
2023-01-07 23:28 ` Yuan Fu
` (3 subsequent siblings)
6 siblings, 2 replies; 20+ messages in thread
From: Yuan Fu @ 2022-12-25 8:36 UTC (permalink / raw)
To: sadiq; +Cc: Alan Mackenzie, 60270
> On buffer select-all TAB, for the following comment:
>
> /*
> hello
> */
>
> I get the following in c-mode (no space before */):
>
> /*
> hello
> */
>
> and the following in c-ts-mode (a space before */):
>
> /*
> hello
> */
I have to say I’m not a C veteran, but I feel like the c-ts-mode result
makes more sense. Why do we want
/*
* hello
*/
but not
/*
hello
*/
?
Is it like a convention?
CC’ed Alan because he must know this.
Yuan
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#60270: 29.0.60; c-ts-mode: Comments are not indented right on auto indentation
2022-12-25 8:36 ` Yuan Fu
@ 2022-12-25 9:25 ` Eli Zaretskii
2023-01-03 14:30 ` Mohammed Sadiq
2022-12-25 9:46 ` Mohammed Sadiq
1 sibling, 1 reply; 20+ messages in thread
From: Eli Zaretskii @ 2022-12-25 9:25 UTC (permalink / raw)
To: Yuan Fu; +Cc: acm, sadiq, 60270
> Cc: Alan Mackenzie <acm@muc.de>, 60270@debbugs.gnu.org
> From: Yuan Fu <casouri@gmail.com>
> Date: Sun, 25 Dec 2022 00:36:46 -0800
>
>
> I have to say I’m not a C veteran, but I feel like the c-ts-mode result
> makes more sense. Why do we want
>
> /*
> * hello
> */
>
> but not
>
> /*
> hello
> */
>
> ?
We actually want this:
/*
* hello
*/
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#60270: 29.0.60; c-ts-mode: Comments are not indented right on auto indentation
2022-12-25 9:25 ` Eli Zaretskii
@ 2023-01-03 14:30 ` Mohammed Sadiq
0 siblings, 0 replies; 20+ messages in thread
From: Mohammed Sadiq @ 2023-01-03 14:30 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: acm, Yuan Fu, 60270
Now it indents properly when selecting the comment and TAB,
but if point is inside the comment, the line indents further
breaking the indentation.
example, for the following code:
/*
* Some comment
*/
and I place the point to be between '*' and '/' in the comment
and or somewhere in the "Some comment" string, and then press
TAB, the line indents further, breaking the indentation.
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#60270: 29.0.60; c-ts-mode: Comments are not indented right on auto indentation
2022-12-25 8:36 ` Yuan Fu
2022-12-25 9:25 ` Eli Zaretskii
@ 2022-12-25 9:46 ` Mohammed Sadiq
1 sibling, 0 replies; 20+ messages in thread
From: Mohammed Sadiq @ 2022-12-25 9:46 UTC (permalink / raw)
To: Yuan Fu; +Cc: Alan Mackenzie, 60270
On 2022-12-25 14:06, Yuan Fu wrote:
>> On buffer select-all TAB, for the following comment:
>>
>> /*
>> hello
>> */
>>
>> I get the following in c-mode (no space before */):
>>
>> /*
>> hello
>> */
>>
>> and the following in c-ts-mode (a space before */):
>>
>> /*
>> hello
>> */
>
> I have to say I’m not a C veteran, but I feel like the c-ts-mode result
> makes more sense. Why do we want
>
> /*
> * hello
> */
>
> but not
>
> /*
> hello
> */
>
> ?
>
> Is it like a convention?
I don't know, I was suggesting to have c-ts-mode behave like c-mode.
So, as to avoid unnecessary changes (as it adds unnecessary noise in
version control history, for those who are using one) on buffer
select-all TAB indent and for the people who migrated to c-ts-mode.
>
> CC’ed Alan because he must know this.
>
> Yuan
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#60270: 29.0.60; c-ts-mode: Comments are not indented right on auto indentation
2022-12-23 9:30 bug#60270: 29.0.60; c-ts-mode: Comments are not indented right on auto indentation Mohammed Sadiq
` (2 preceding siblings ...)
2022-12-25 8:36 ` Yuan Fu
@ 2023-01-07 23:28 ` Yuan Fu
2023-01-08 10:02 ` Mohammed Sadiq
2023-01-10 5:28 ` Yuan Fu
` (2 subsequent siblings)
6 siblings, 1 reply; 20+ messages in thread
From: Yuan Fu @ 2023-01-07 23:28 UTC (permalink / raw)
To: Mohammed Sadiq; +Cc: Alan Mackenzie, Eli Zaretskii, 60270
Mohammed Sadiq <sadiq@sadiqpk.org> writes:
> Now it indents properly when selecting the comment and TAB,
> but if point is inside the comment, the line indents further
> breaking the indentation.
>
> example, for the following code:
>
> /*
> * Some comment
> */
>
> and I place the point to be between '*' and '/' in the comment
> and or somewhere in the "Some comment" string, and then press
> TAB, the line indents further, breaking the indentation.
Ah, yes. I fixed that. Thanks for the report.
Yuan
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#60270: 29.0.60; c-ts-mode: Comments are not indented right on auto indentation
2023-01-07 23:28 ` Yuan Fu
@ 2023-01-08 10:02 ` Mohammed Sadiq
0 siblings, 0 replies; 20+ messages in thread
From: Mohammed Sadiq @ 2023-01-08 10:02 UTC (permalink / raw)
To: Yuan Fu; +Cc: Alan Mackenzie, Eli Zaretskii, 60270
On 2023-01-08 04:58, Yuan Fu wrote:
> Mohammed Sadiq <sadiq@sadiqpk.org> writes:
>
>> Now it indents properly when selecting the comment and TAB,
>> but if point is inside the comment, the line indents further
>> breaking the indentation.
>>
>> example, for the following code:
>>
>> /*
>> * Some comment
>> */
>>
>> and I place the point to be between '*' and '/' in the comment
>> and or somewhere in the "Some comment" string, and then press
>> TAB, the line indents further, breaking the indentation.
>
> Ah, yes. I fixed that. Thanks for the report.
>
> Yuan
There is one more case that's broken:
int
main (void)
{
/*
Some comment
*/
}
Where I expect it to be:
int
main (void)
{
/*
Some comment
*/
}
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#60270: 29.0.60; c-ts-mode: Comments are not indented right on auto indentation
2022-12-23 9:30 bug#60270: 29.0.60; c-ts-mode: Comments are not indented right on auto indentation Mohammed Sadiq
` (3 preceding siblings ...)
2023-01-07 23:28 ` Yuan Fu
@ 2023-01-10 5:28 ` Yuan Fu
2023-01-10 10:13 ` Mohammed Sadiq
2023-01-14 7:53 ` Yuan Fu
2023-01-16 8:24 ` Yuan Fu
6 siblings, 1 reply; 20+ messages in thread
From: Yuan Fu @ 2023-01-10 5:28 UTC (permalink / raw)
To: Mohammed Sadiq; +Cc: 60270
Mohammed Sadiq <sadiq@sadiqpk.org> writes:
> On 2023-01-08 04:58, Yuan Fu wrote:
>> Mohammed Sadiq <sadiq@sadiqpk.org> writes:
>>
>>> Now it indents properly when selecting the comment and TAB,
>>> but if point is inside the comment, the line indents further
>>> breaking the indentation.
>>> example, for the following code:
>>> /*
>>> * Some comment
>>> */
>>> and I place the point to be between '*' and '/' in the comment
>>> and or somewhere in the "Some comment" string, and then press
>>> TAB, the line indents further, breaking the indentation.
>> Ah, yes. I fixed that. Thanks for the report.
>> Yuan
>
> There is one more case that's broken:
>
> int
> main (void)
> {
> /*
> Some comment
> */
> }
>
>
> Where I expect it to be:
>
> int
> main (void)
> {
> /*
> Some comment
> */
> }
Ah, right. Now it’s fixed. Thanks!
Yuan
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#60270: 29.0.60; c-ts-mode: Comments are not indented right on auto indentation
2023-01-10 5:28 ` Yuan Fu
@ 2023-01-10 10:13 ` Mohammed Sadiq
2023-01-10 12:17 ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-11 9:30 ` Yuan Fu
0 siblings, 2 replies; 20+ messages in thread
From: Mohammed Sadiq @ 2023-01-10 10:13 UTC (permalink / raw)
To: Yuan Fu; +Cc: 60270
On 2023-01-10 10:58, Yuan Fu wrote:
>
> Ah, right. Now it’s fixed. Thanks!
>
> Yuan
This broke the following comment styles:
/* some comment
*/
indentation of above code gives:
/* some comment
*/
Also:
/*
* some comment
*/
where I expect:
/*
* some comment
*/
If there are ways to add automated tests, it would be nice so that
these won't be broken when fixing something else.
cheers,
Mohammed Sadiq
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#60270: 29.0.60; c-ts-mode: Comments are not indented right on auto indentation
2023-01-10 10:13 ` Mohammed Sadiq
@ 2023-01-10 12:17 ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-11 9:27 ` Yuan Fu
2023-01-11 9:30 ` Yuan Fu
1 sibling, 1 reply; 20+ messages in thread
From: Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-01-10 12:17 UTC (permalink / raw)
To: Mohammed Sadiq; +Cc: Yuan Fu, 60270
Mohammed Sadiq <sadiq@sadiqpk.org> writes:
>
> If there are ways to add automated tests, it would be nice so that
> these won't be broken when fixing something else.
>
I sent a patch to emacs-devel a few days ago with some basic regression
testing infrastructure for Tree-sitter modes:
https://lists.gnu.org/archive/html/emacs-devel/2023-01/msg00111.html
Yuan, WDYT?
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#60270: 29.0.60; c-ts-mode: Comments are not indented right on auto indentation
2023-01-10 10:13 ` Mohammed Sadiq
2023-01-10 12:17 ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-01-11 9:30 ` Yuan Fu
2023-01-13 8:58 ` Yuan Fu
1 sibling, 1 reply; 20+ messages in thread
From: Yuan Fu @ 2023-01-11 9:30 UTC (permalink / raw)
To: Mohammed Sadiq; +Cc: 60270
> On Jan 10, 2023, at 2:13 AM, Mohammed Sadiq <sadiq@sadiqpk.org> wrote:
>
> On 2023-01-10 10:58, Yuan Fu wrote:
>> Ah, right. Now it’s fixed. Thanks!
>> Yuan
>
> This broke the following comment styles:
>
> /* some comment
> */
>
> indentation of above code gives:
>
> /* some comment
> */
>
>
> Also:
>
> /*
> * some comment
> */
>
> where I expect:
>
> /*
> * some comment
> */
This is easy to fix, I’ll push a fix soon.
>
> If there are ways to add automated tests, it would be nice so that
> these won't be broken when fixing something else.
I agree. I have been busy fixing all sorts of bugs and haven’t go around to it :-(
Yuan
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#60270: 29.0.60; c-ts-mode: Comments are not indented right on auto indentation
2023-01-11 9:30 ` Yuan Fu
@ 2023-01-13 8:58 ` Yuan Fu
0 siblings, 0 replies; 20+ messages in thread
From: Yuan Fu @ 2023-01-13 8:58 UTC (permalink / raw)
To: Mohammed Sadiq; +Cc: 60270
> On Jan 11, 2023, at 1:30 AM, Yuan Fu <casouri@gmail.com> wrote:
>
>
>
>> On Jan 10, 2023, at 2:13 AM, Mohammed Sadiq <sadiq@sadiqpk.org> wrote:
>>
>> On 2023-01-10 10:58, Yuan Fu wrote:
>>> Ah, right. Now it’s fixed. Thanks!
>>> Yuan
>>
>> This broke the following comment styles:
>>
>> /* some comment
>> */
>>
>> indentation of above code gives:
>>
>> /* some comment
>> */
>>
>>
>> Also:
>>
>> /*
>> * some comment
>> */
>>
>> where I expect:
>>
>> /*
>> * some comment
>> */
>
> This is easy to fix, I’ll push a fix soon.
I pushed the fix.
>
>>
>> If there are ways to add automated tests, it would be nice so that
>> these won't be broken when fixing something else.
>
> I agree. I have been busy fixing all sorts of bugs and haven’t go around to it :-(
I added the c-ts-mode tests you had in the patch.
Yuan
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#60270: 29.0.60; c-ts-mode: Comments are not indented right on auto indentation
2022-12-23 9:30 bug#60270: 29.0.60; c-ts-mode: Comments are not indented right on auto indentation Mohammed Sadiq
` (4 preceding siblings ...)
2023-01-10 5:28 ` Yuan Fu
@ 2023-01-14 7:53 ` Yuan Fu
2023-01-15 5:28 ` Mohammed Sadiq
2023-01-16 8:24 ` Yuan Fu
6 siblings, 1 reply; 20+ messages in thread
From: Yuan Fu @ 2023-01-14 7:53 UTC (permalink / raw)
To: Mohammed Sadiq; +Cc: 60270-done
Yuan Fu <casouri@gmail.com> writes:
>> On Jan 11, 2023, at 1:30 AM, Yuan Fu <casouri@gmail.com> wrote:
>>
>>
>>
>>> On Jan 10, 2023, at 2:13 AM, Mohammed Sadiq <sadiq@sadiqpk.org> wrote:
>>>
>>> On 2023-01-10 10:58, Yuan Fu wrote:
>>>> Ah, right. Now it’s fixed. Thanks!
>>>> Yuan
>>>
>>> This broke the following comment styles:
>>>
>>> /* some comment
>>> */
>>>
>>> indentation of above code gives:
>>>
>>> /* some comment
>>> */
>>>
>>>
>>> Also:
>>>
>>> /*
>>> * some comment
>>> */
>>>
>>> where I expect:
>>>
>>> /*
>>> * some comment
>>> */
>>
>> This is easy to fix, I’ll push a fix soon.
>
> I pushed the fix.
>
>>
>>>
>>> If there are ways to add automated tests, it would be nice so that
>>> these won't be broken when fixing something else.
>>
>> I agree. I have been busy fixing all sorts of bugs and haven’t go around to it :-(
>
> I added the c-ts-mode tests you had in the patch.
I added some more indent and filling tests. Now I think this can be
closed, yay!
Yuan
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#60270: 29.0.60; c-ts-mode: Comments are not indented right on auto indentation
2023-01-14 7:53 ` Yuan Fu
@ 2023-01-15 5:28 ` Mohammed Sadiq
0 siblings, 0 replies; 20+ messages in thread
From: Mohammed Sadiq @ 2023-01-15 5:28 UTC (permalink / raw)
To: Yuan Fu; +Cc: 60270-done
On 2023-01-14 13:23, Yuan Fu wrote:
> I added some more indent and filling tests. Now I think this can be
> closed, yay!
Thanks, Looks like almost all issues has been fixed. I found one more
case that this fails:
int
main (void)
{
/*
line one
line 2
*/
}
In the above code, if I select the whole buffer and indent, line 2
doesn't
indent
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#60270: 29.0.60; c-ts-mode: Comments are not indented right on auto indentation
2022-12-23 9:30 bug#60270: 29.0.60; c-ts-mode: Comments are not indented right on auto indentation Mohammed Sadiq
` (5 preceding siblings ...)
2023-01-14 7:53 ` Yuan Fu
@ 2023-01-16 8:24 ` Yuan Fu
6 siblings, 0 replies; 20+ messages in thread
From: Yuan Fu @ 2023-01-16 8:24 UTC (permalink / raw)
To: Mohammed Sadiq; +Cc: 60270-done, 60270
Mohammed Sadiq <sadiq@sadiqpk.org> writes:
> On 2023-01-14 13:23, Yuan Fu wrote:
>> I added some more indent and filling tests. Now I think this can be
>> closed, yay!
>
>
> Thanks, Looks like almost all issues has been fixed. I found one more
> case that this fails:
>
> int
> main (void)
> {
> /*
> line one
> line 2
> */
> }
>
> In the above code, if I select the whole buffer and indent, line 2
> doesn't
> indent
Ok, that’s not due to incorrect due to incorrect indentation rule, but
rather the indentation function. Anyway, I fixed it and added a test.
Thanks!
Yuan
^ permalink raw reply [flat|nested] 20+ messages in thread