GNU bug report logs -
#67357
[PATCH] Fix c-ts-mode block indent when first-siblings are comments
Previous Next
Reported by: Noah Peart <noah.v.peart <at> gmail.com>
Date: Wed, 22 Nov 2023 01:52:02 UTC
Severity: normal
Tags: patch
Done: Yuan Fu <casouri <at> gmail.com>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 67357 in the body.
You can then email your comments to 67357 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#67357
; Package
emacs
.
(Wed, 22 Nov 2023 01:52:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Noah Peart <noah.v.peart <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Wed, 22 Nov 2023 01:52:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Tags: patch
I wasn't sure if these should be two separate bugs, so I separated them
just
in case.
* lisp/progmodes/c-ts-mode.el(c-ts-mode--indent-styles): Fix indentation
in block statements for cases when the first-sibling(s) are comments or
nested keywords (else_clause/do while).
Bug: The first statement in a compound statement that is preceded by a
comment (or multiple comments) isn't indented.
For example, the `if` statement isnt indented in the following code in
`c-ts-mode` using `linux` style.
int main() {
while (true) { /* foo */
if (true) { // this line isnt indented
puts ("Hello"); // and this isnt either
}
}
}
* lisp/progmodes/c-ts-mode.el(c-ts-mode--indent-styles): Fix indentation
for else_clause and do-while in bracket-less block statements using
`linux` style.
Bug: There is no matching indent rule for bracket-less else_clause
statements and the "while" in a bracket-less do-while statement is
indented to the same level as the do body.
To reproduce, using `linux` style in `c-ts-mode`.
int main() {
if (true)
puts("Hello");
else
puts("No matched rule!");
do
puts("Hello");
while (indented_as_part_of_block);
}
In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.33, cairo version 1.16.0) of 2023-11-18 built on noah-X580VD
Repository revision: 47b497b4dac91e5ea56102018223bdeb5e21a93b
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101004
System Description: Ubuntu 22.04.3 LTS
Configured using:
'configure --prefix=/usr/local --with-modules --with-tree-sitter
--with-threads --with-x-toolkit=gtk3 --with-xwidgets --with-gnutls
--with-json --with-mailutils --with-jpeg --with-png --with-rsvg
--with-tiff --with-xml2 --with-xpm --with-imagemagick CC=gcc-12
CXX=gcc-12'
[Message part 2 (text/html, inline)]
[c-ts-mode-first-sib-comments.patch (text/x-patch, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#67357
; Package
emacs
.
(Thu, 23 Nov 2023 07:36:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 67357 <at> debbugs.gnu.org (full text, mbox):
> From: Noah Peart <noah.v.peart <at> gmail.com>
> Date: Tue, 21 Nov 2023 17:50:52 -0800
>
> I wasn't sure if these should be two separate bugs, so I separated them just
> in case.
>
> * lisp/progmodes/c-ts-mode.el(c-ts-mode--indent-styles): Fix indentation
> in block statements for cases when the first-sibling(s) are comments or
> nested keywords (else_clause/do while).
>
> Bug: The first statement in a compound statement that is preceded by a
> comment (or multiple comments) isn't indented.
>
> For example, the `if` statement isnt indented in the following code in
> `c-ts-mode` using `linux` style.
>
> int main() {
> while (true) { /* foo */
> if (true) { // this line isnt indented
> puts ("Hello"); // and this isnt either
> }
> }
> }
>
> * lisp/progmodes/c-ts-mode.el(c-ts-mode--indent-styles): Fix indentation
> for else_clause and do-while in bracket-less block statements using
> `linux` style.
>
> Bug: There is no matching indent rule for bracket-less else_clause
> statements and the "while" in a bracket-less do-while statement is
> indented to the same level as the do body.
>
> To reproduce, using `linux` style in `c-ts-mode`.
>
> int main() {
> if (true)
> puts("Hello");
> else
> puts("No matched rule!");
> do
> puts("Hello");
> while (indented_as_part_of_block);
> }
I'm not sure I can reproduce these, it seems to me that the
indentation is correct in these case when I try the examples. So
please show a detailed recipe, starting from "emacs -Q", for each of
the two problems, so that we could be sure that we are seeing the same
problems.
Also, please tell if the same problems exist on the emacs-29 branch.
Adding Yuan to the discussion.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#67357
; Package
emacs
.
(Thu, 23 Nov 2023 13:18:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 67357 <at> debbugs.gnu.org (full text, mbox):
On 23/11/2023 09:35, Eli Zaretskii wrote:
>> From: Noah Peart<noah.v.peart <at> gmail.com>
>> Date: Tue, 21 Nov 2023 17:50:52 -0800
>>
>> I wasn't sure if these should be two separate bugs, so I separated them just
>> in case.
>>
>> * lisp/progmodes/c-ts-mode.el(c-ts-mode--indent-styles): Fix indentation
>> in block statements for cases when the first-sibling(s) are comments or
>> nested keywords (else_clause/do while).
>>
>> Bug: The first statement in a compound statement that is preceded by a
>> comment (or multiple comments) isn't indented.
>>
>> For example, the `if` statement isnt indented in the following code in
>> `c-ts-mode` using `linux` style.
>>
>> int main() {
>> while (true) { /* foo */
>> if (true) { // this line isnt indented
>> puts ("Hello"); // and this isnt either
>> }
>> }
>> }
>>
>> * lisp/progmodes/c-ts-mode.el(c-ts-mode--indent-styles): Fix indentation
>> for else_clause and do-while in bracket-less block statements using
>> `linux` style.
>>
>> Bug: There is no matching indent rule for bracket-less else_clause
>> statements and the "while" in a bracket-less do-while statement is
>> indented to the same level as the do body.
>>
>> To reproduce, using `linux` style in `c-ts-mode`.
>>
>> int main() {
>> if (true)
>> puts("Hello");
>> else
>> puts("No matched rule!");
>> do
>> puts("Hello");
>> while (indented_as_part_of_block);
>> }
> I'm not sure I can reproduce these, it seems to me that the
> indentation is correct in these case when I try the examples. So
> please show a detailed recipe, starting from "emacs -Q", for each of
> the two problems, so that we could be sure that we are seeing the same
> problems.
I can easily reproduce the first one (comment-related): the two
indicated lines just don't reindent at all. That's with the default
'gnu' indentation style, but also with 'linux' and perhaps others (I
haven't tried).
To reproduce the second one, you first need to enable the 'linux' style:
(setq c-ts-mode-indent-style 'linux)
M-x c-ts-mode
Then 'while' indents the same level as 'puts'. Unless this is actually
indended for the 'linux' style (I have no idea), it's a bug too.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#67357
; Package
emacs
.
(Thu, 23 Nov 2023 14:35:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 67357 <at> debbugs.gnu.org (full text, mbox):
> Date: Thu, 23 Nov 2023 15:17:40 +0200
> Cc: 67357 <at> debbugs.gnu.org
> From: Dmitry Gutov <dmitry <at> gutov.dev>
>
> On 23/11/2023 09:35, Eli Zaretskii wrote:
> > I'm not sure I can reproduce these, it seems to me that the
> > indentation is correct in these case when I try the examples. So
> > please show a detailed recipe, starting from "emacs -Q", for each of
> > the two problems, so that we could be sure that we are seeing the same
> > problems.
>
> I can easily reproduce the first one (comment-related): the two
> indicated lines just don't reindent at all. That's with the default
> 'gnu' indentation style, but also with 'linux' and perhaps others (I
> haven't tried).
I don't understand what you mean by "reindent". That wasn't what the
original report was about, AFAIU.
I still think a complete recipe is needed.
> To reproduce the second one, you first need to enable the 'linux' style:
I tried to reproduce _only_ with the 'linux' style, as the bug report
said.
> (setq c-ts-mode-indent-style 'linux)
> M-x c-ts-mode
The style is a per-buffer setting, so AFAIU one needs to set the style
after turning on the mode in a buffer, whether manually or
automatically.
A full recipe is supposed to remove all those confusing details and
potential mistakes.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#67357
; Package
emacs
.
(Thu, 23 Nov 2023 14:42:01 GMT)
Full text and
rfc822 format available.
Message #17 received at 67357 <at> debbugs.gnu.org (full text, mbox):
On 23/11/2023 16:33, Eli Zaretskii wrote:
>> Date: Thu, 23 Nov 2023 15:17:40 +0200
>> Cc: 67357 <at> debbugs.gnu.org
>> From: Dmitry Gutov <dmitry <at> gutov.dev>
>>
>> On 23/11/2023 09:35, Eli Zaretskii wrote:
>>> I'm not sure I can reproduce these, it seems to me that the
>>> indentation is correct in these case when I try the examples. So
>>> please show a detailed recipe, starting from "emacs -Q", for each of
>>> the two problems, so that we could be sure that we are seeing the same
>>> problems.
>>
>> I can easily reproduce the first one (comment-related): the two
>> indicated lines just don't reindent at all. That's with the default
>> 'gnu' indentation style, but also with 'linux' and perhaps others (I
>> haven't tried).
>
> I don't understand what you mean by "reindent". That wasn't what the
> original report was about, AFAIU.
Reindent is when you press tab, and the indentation on a given line
changes. In that example, no matter which indentation you set on those
line, pressing TAB doesn't change it.
> I still think a complete recipe is needed.
>
>> To reproduce the second one, you first need to enable the 'linux' style:
>
> I tried to reproduce _only_ with the 'linux' style, as the bug report
> said.
>
>> (setq c-ts-mode-indent-style 'linux)
>> M-x c-ts-mode
>
> The style is a per-buffer setting, so AFAIU one needs to set the style
> after turning on the mode in a buffer, whether manually or
> automatically.
Did you use 'M-x c-ts-mode-set-style', then? That also repros for me.
The style can be set locally - as the above command does - but initially
the global value is used. And it's applied during the major mode's
execution, so a simple 'setq' doesn't work.
> A full recipe is supposed to remove all those confusing details and
> potential mistakes.
I don't mind.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#67357
; Package
emacs
.
(Fri, 24 Nov 2023 13:49:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 67357 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Sorry for the confusion: to setup the `c-ts-mode` buffers to reproduce bugs,
run the following to configure `c-ts-mode` with `linux` style:
(defun example-setup ()
(interactive)
(c-ts-mode)
(setq-local indent-tabs-mode nil)
(setq-local c-ts-mode-indent-offset 2)
(c-ts-mode-set-style 'linux))
The patch should also fix the missing indent for the `else_clause`
mentioned
in https://lists.gnu.org/archive/html/bug-gnu-emacs/2023-11/msg01266.html.
On Thu, Nov 23, 2023 at 6:41 AM Dmitry Gutov <dmitry <at> gutov.dev> wrote:
> On 23/11/2023 16:33, Eli Zaretskii wrote:
> >> Date: Thu, 23 Nov 2023 15:17:40 +0200
> >> Cc: 67357 <at> debbugs.gnu.org
> >> From: Dmitry Gutov <dmitry <at> gutov.dev>
> >>
> >> On 23/11/2023 09:35, Eli Zaretskii wrote:
> >>> I'm not sure I can reproduce these, it seems to me that the
> >>> indentation is correct in these case when I try the examples. So
> >>> please show a detailed recipe, starting from "emacs -Q", for each of
> >>> the two problems, so that we could be sure that we are seeing the same
> >>> problems.
> >>
> >> I can easily reproduce the first one (comment-related): the two
> >> indicated lines just don't reindent at all. That's with the default
> >> 'gnu' indentation style, but also with 'linux' and perhaps others (I
> >> haven't tried).
> >
> > I don't understand what you mean by "reindent". That wasn't what the
> > original report was about, AFAIU.
>
> Reindent is when you press tab, and the indentation on a given line
> changes. In that example, no matter which indentation you set on those
> line, pressing TAB doesn't change it.
>
> > I still think a complete recipe is needed.
> >
> >> To reproduce the second one, you first need to enable the 'linux' style:
> >
> > I tried to reproduce _only_ with the 'linux' style, as the bug report
> > said.
> >
> >> (setq c-ts-mode-indent-style 'linux)
> >> M-x c-ts-mode
> >
> > The style is a per-buffer setting, so AFAIU one needs to set the style
> > after turning on the mode in a buffer, whether manually or
> > automatically.
>
> Did you use 'M-x c-ts-mode-set-style', then? That also repros for me.
>
> The style can be set locally - as the above command does - but initially
> the global value is used. And it's applied during the major mode's
> execution, so a simple 'setq' doesn't work.
>
> > A full recipe is supposed to remove all those confusing details and
> > potential mistakes.
>
> I don't mind.
>
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#67357
; Package
emacs
.
(Fri, 24 Nov 2023 14:08:02 GMT)
Full text and
rfc822 format available.
Message #23 received at 67357 <at> debbugs.gnu.org (full text, mbox):
> From: Noah Peart <noah.v.peart <at> gmail.com>
> Date: Fri, 24 Nov 2023 05:47:34 -0800
> Cc: Eli Zaretskii <eliz <at> gnu.org>, casouri <at> gmail.com, 67357 <at> debbugs.gnu.org
>
> Sorry for the confusion: to setup the `c-ts-mode` buffers to reproduce bugs,
> run the following to configure `c-ts-mode` with `linux` style:
>
> (defun example-setup ()
> (interactive)
> (c-ts-mode)
> (setq-local indent-tabs-mode nil)
> (setq-local c-ts-mode-indent-offset 2)
> (c-ts-mode-set-style 'linux))
Thanks, but what to do after (or before?) the above, to actually
reproduce the problem?
I'm sorry I insist on a complete recipe with all the details, but IME
without having such a recipe, it is all too easy to create
misunderstandings about the problem, and harder to test solutions.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#67357
; Package
emacs
.
(Fri, 24 Nov 2023 14:36:01 GMT)
Full text and
rfc822 format available.
Message #26 received at 67357 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
> I'm sorry I insist on a complete recipe with all the details
Ok, lemme try again :)
To reproduce the indentation bugs for unbracketed `else_clause`, and
do-while:
1. open a buffer and insert the following:
int main() {
if (true)
puts("Hello");
else
puts("No matched rule!"); // 1
do
puts("Hello");
while (indented_as_part_of_block); // 2
}
2. call `M-x example-setup` to configure `c-ts-mode`
3. `M-x indent-region` to indent the whole buffer
You should see that the line with comment `1` has not been
indented, and the line with comment `2` has been indented to the
same level as the previous line.
To reproduce the indentation bugs when comments are the first
siblings:
1. open a buffer and insert:
int main() {
while (true) { /* foo */
if (true) { // 1
puts ("Hello"); // 2
}
}
}
2. call `M-x example-setup` to configure `c-ts-mode`
3. `M-x indent-region` to indent the whole buffer
You should see that the lines with comments `1` and `2` have
not been indented at all.
On Fri, Nov 24, 2023 at 6:07 AM Eli Zaretskii <eliz <at> gnu.org> wrote:
> > From: Noah Peart <noah.v.peart <at> gmail.com>
> > Date: Fri, 24 Nov 2023 05:47:34 -0800
> > Cc: Eli Zaretskii <eliz <at> gnu.org>, casouri <at> gmail.com,
> 67357 <at> debbugs.gnu.org
> >
> > Sorry for the confusion: to setup the `c-ts-mode` buffers to reproduce
> bugs,
> > run the following to configure `c-ts-mode` with `linux` style:
> >
> > (defun example-setup ()
> > (interactive)
> > (c-ts-mode)
> > (setq-local indent-tabs-mode nil)
> > (setq-local c-ts-mode-indent-offset 2)
> > (c-ts-mode-set-style 'linux))
>
> Thanks, but what to do after (or before?) the above, to actually
> reproduce the problem?
>
> I'm sorry I insist on a complete recipe with all the details, but IME
> without having such a recipe, it is all too easy to create
> misunderstandings about the problem, and harder to test solutions.
>
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#67357
; Package
emacs
.
(Fri, 24 Nov 2023 14:46:01 GMT)
Full text and
rfc822 format available.
Message #29 received at 67357 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
I did notice an issue with testing solutions in
`c-ts-mode-resources/indent.erts`.
In cases where no indentation is applied (eg. comment is first-sibling) or
there
is no matching rule (eg. else_clause), the test case can still pass since
the test cases are written with the proper indentation already. So, despite
no indentation being applied, the result still matches the expected result.
On Fri, Nov 24, 2023 at 6:35 AM Noah Peart <noah.v.peart <at> gmail.com> wrote:
> > I'm sorry I insist on a complete recipe with all the details
>
> Ok, lemme try again :)
>
> To reproduce the indentation bugs for unbracketed `else_clause`, and
> do-while:
> 1. open a buffer and insert the following:
>
> int main() {
> if (true)
> puts("Hello");
> else
> puts("No matched rule!"); // 1
> do
> puts("Hello");
> while (indented_as_part_of_block); // 2
> }
>
> 2. call `M-x example-setup` to configure `c-ts-mode`
> 3. `M-x indent-region` to indent the whole buffer
> You should see that the line with comment `1` has not been
> indented, and the line with comment `2` has been indented to the
> same level as the previous line.
>
> To reproduce the indentation bugs when comments are the first
> siblings:
> 1. open a buffer and insert:
>
> int main() {
> while (true) { /* foo */
> if (true) { // 1
> puts ("Hello"); // 2
> }
> }
> }
>
> 2. call `M-x example-setup` to configure `c-ts-mode`
> 3. `M-x indent-region` to indent the whole buffer
>
> You should see that the lines with comments `1` and `2` have
> not been indented at all.
>
> On Fri, Nov 24, 2023 at 6:07 AM Eli Zaretskii <eliz <at> gnu.org> wrote:
>
>> > From: Noah Peart <noah.v.peart <at> gmail.com>
>> > Date: Fri, 24 Nov 2023 05:47:34 -0800
>> > Cc: Eli Zaretskii <eliz <at> gnu.org>, casouri <at> gmail.com,
>> 67357 <at> debbugs.gnu.org
>> >
>> > Sorry for the confusion: to setup the `c-ts-mode` buffers to reproduce
>> bugs,
>> > run the following to configure `c-ts-mode` with `linux` style:
>> >
>> > (defun example-setup ()
>> > (interactive)
>> > (c-ts-mode)
>> > (setq-local indent-tabs-mode nil)
>> > (setq-local c-ts-mode-indent-offset 2)
>> > (c-ts-mode-set-style 'linux))
>>
>> Thanks, but what to do after (or before?) the above, to actually
>> reproduce the problem?
>>
>> I'm sorry I insist on a complete recipe with all the details, but IME
>> without having such a recipe, it is all too easy to create
>> misunderstandings about the problem, and harder to test solutions.
>>
>
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#67357
; Package
emacs
.
(Fri, 24 Nov 2023 14:47:02 GMT)
Full text and
rfc822 format available.
Message #32 received at 67357 <at> debbugs.gnu.org (full text, mbox):
> From: Noah Peart <noah.v.peart <at> gmail.com>
> Date: Fri, 24 Nov 2023 06:35:06 -0800
> Cc: dmitry <at> gutov.dev, casouri <at> gmail.com, 67357 <at> debbugs.gnu.org
>
> To reproduce the indentation bugs for unbracketed `else_clause`, and
> do-while:
> 1. open a buffer and insert the following:
>
> int main() {
> if (true)
> puts("Hello");
> else
> puts("No matched rule!"); // 1
> do
> puts("Hello");
> while (indented_as_part_of_block); // 2
> }
>
> 2. call `M-x example-setup` to configure `c-ts-mode`
> 3. `M-x indent-region` to indent the whole buffer
> You should see that the line with comment `1` has not been
> indented, and the line with comment `2` has been indented to the
> same level as the previous line.
>
> To reproduce the indentation bugs when comments are the first
> siblings:
> 1. open a buffer and insert:
>
> int main() {
> while (true) { /* foo */
> if (true) { // 1
> puts ("Hello"); // 2
> }
> }
> }
>
> 2. call `M-x example-setup` to configure `c-ts-mode`
> 3. `M-x indent-region` to indent the whole buffer
>
> You should see that the lines with comments `1` and `2` have
> not been indented at all.
Thanks, I see the problems now.
Let's wait for Yuan to chime in.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#67357
; Package
emacs
.
(Wed, 29 Nov 2023 13:48:01 GMT)
Full text and
rfc822 format available.
Message #35 received at 67357 <at> debbugs.gnu.org (full text, mbox):
> Date: Fri, 24 Nov 2023 16:46:32 +0200
> From: Eli Zaretskii <eliz <at> gnu.org>
> Cc: dmitry <at> gutov.dev, casouri <at> gmail.com, 67357 <at> debbugs.gnu.org
>
> > From: Noah Peart <noah.v.peart <at> gmail.com>
> > Date: Fri, 24 Nov 2023 06:35:06 -0800
> > Cc: dmitry <at> gutov.dev, casouri <at> gmail.com, 67357 <at> debbugs.gnu.org
> >
> > To reproduce the indentation bugs for unbracketed `else_clause`, and
> > do-while:
> > 1. open a buffer and insert the following:
> >
> > int main() {
> > if (true)
> > puts("Hello");
> > else
> > puts("No matched rule!"); // 1
> > do
> > puts("Hello");
> > while (indented_as_part_of_block); // 2
> > }
> >
> > 2. call `M-x example-setup` to configure `c-ts-mode`
> > 3. `M-x indent-region` to indent the whole buffer
> > You should see that the line with comment `1` has not been
> > indented, and the line with comment `2` has been indented to the
> > same level as the previous line.
> >
> > To reproduce the indentation bugs when comments are the first
> > siblings:
> > 1. open a buffer and insert:
> >
> > int main() {
> > while (true) { /* foo */
> > if (true) { // 1
> > puts ("Hello"); // 2
> > }
> > }
> > }
> >
> > 2. call `M-x example-setup` to configure `c-ts-mode`
> > 3. `M-x indent-region` to indent the whole buffer
> >
> > You should see that the lines with comments `1` and `2` have
> > not been indented at all.
>
> Thanks, I see the problems now.
>
> Let's wait for Yuan to chime in.
Yuan, could you please comment on the proposed solution? TIA.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#67357
; Package
emacs
.
(Sat, 09 Dec 2023 08:25:02 GMT)
Full text and
rfc822 format available.
Message #38 received at 67357 <at> debbugs.gnu.org (full text, mbox):
Ping! Ping! Yuan, please chime is, as I'm waiting for your comments
before we install on the release branch.
This and other patches for TS-based modes are currently delaying the
release of Emacs 29.2, so please try to be more responsive, okay?
> Cc: noah.v.peart <at> gmail.com, 67357 <at> debbugs.gnu.org, dmitry <at> gutov.dev
> Date: Wed, 29 Nov 2023 15:47:25 +0200
> From: Eli Zaretskii <eliz <at> gnu.org>
>
> > Date: Fri, 24 Nov 2023 16:46:32 +0200
> > From: Eli Zaretskii <eliz <at> gnu.org>
> > Cc: dmitry <at> gutov.dev, casouri <at> gmail.com, 67357 <at> debbugs.gnu.org
> >
> > > From: Noah Peart <noah.v.peart <at> gmail.com>
> > > Date: Fri, 24 Nov 2023 06:35:06 -0800
> > > Cc: dmitry <at> gutov.dev, casouri <at> gmail.com, 67357 <at> debbugs.gnu.org
> > >
> > > To reproduce the indentation bugs for unbracketed `else_clause`, and
> > > do-while:
> > > 1. open a buffer and insert the following:
> > >
> > > int main() {
> > > if (true)
> > > puts("Hello");
> > > else
> > > puts("No matched rule!"); // 1
> > > do
> > > puts("Hello");
> > > while (indented_as_part_of_block); // 2
> > > }
> > >
> > > 2. call `M-x example-setup` to configure `c-ts-mode`
> > > 3. `M-x indent-region` to indent the whole buffer
> > > You should see that the line with comment `1` has not been
> > > indented, and the line with comment `2` has been indented to the
> > > same level as the previous line.
> > >
> > > To reproduce the indentation bugs when comments are the first
> > > siblings:
> > > 1. open a buffer and insert:
> > >
> > > int main() {
> > > while (true) { /* foo */
> > > if (true) { // 1
> > > puts ("Hello"); // 2
> > > }
> > > }
> > > }
> > >
> > > 2. call `M-x example-setup` to configure `c-ts-mode`
> > > 3. `M-x indent-region` to indent the whole buffer
> > >
> > > You should see that the lines with comments `1` and `2` have
> > > not been indented at all.
> >
> > Thanks, I see the problems now.
> >
> > Let's wait for Yuan to chime in.
>
> Yuan, could you please comment on the proposed solution? TIA.
>
>
>
>
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#67357
; Package
emacs
.
(Sun, 10 Dec 2023 09:10:02 GMT)
Full text and
rfc822 format available.
Message #41 received at 67357 <at> debbugs.gnu.org (full text, mbox):
> Ping! Ping! Yuan, please chime is, as I'm waiting for your comments
> before we install on the release branch.
>
> This and other patches for TS-based modes are currently delaying the
> release of Emacs 29.2, so please try to be more responsive, okay?
>
Whoa! Sorry, I just switched to a new email client, and direct CC isn't
highlight as they were before :-( (And admittedly I haven't been
browsing the bug tracker lately.)
As for the patch, first of all, thank you, Noah, it's very good. I try
to avoid query matchers since they could be slow, plus the fundamental
problem isn't with comments, IMO. The problem is when the first sibling
isn't on it's own line. (Though in normal C source code, when the first
sibling isn't on its own line, that sibling is usually a comment.)
Anyway, please see my reasoning in the commit message for 08fc6bace20.
I also removed the else_clause rule since it's already added by the
patch for bug#67417, and added another test.
Yuan
Reply sent
to
Yuan Fu <casouri <at> gmail.com>
:
You have taken responsibility.
(Sun, 10 Dec 2023 09:10:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Noah Peart <noah.v.peart <at> gmail.com>
:
bug acknowledged by developer.
(Sun, 10 Dec 2023 09:10:03 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#67357
; Package
emacs
.
(Sun, 10 Dec 2023 09:41:01 GMT)
Full text and
rfc822 format available.
Message #49 received at 67357 <at> debbugs.gnu.org (full text, mbox):
> Date: Sun, 10 Dec 2023 01:09:15 -0800
> Cc: noah.v.peart <at> gmail.com, 67357 <at> debbugs.gnu.org, dmitry <at> gutov.dev
> From: Yuan Fu <casouri <at> gmail.com>
>
>
> > Ping! Ping! Yuan, please chime is, as I'm waiting for your comments
> > before we install on the release branch.
> >
> > This and other patches for TS-based modes are currently delaying the
> > release of Emacs 29.2, so please try to be more responsive, okay?
> >
> Whoa! Sorry, I just switched to a new email client, and direct CC isn't
> highlight as they were before :-( (And admittedly I haven't been
> browsing the bug tracker lately.)
OK, but please look also at other bugs and issues where I asked for
your opinions.
> As for the patch, first of all, thank you, Noah, it's very good. I try
> to avoid query matchers since they could be slow, plus the fundamental
> problem isn't with comments, IMO. The problem is when the first sibling
> isn't on it's own line. (Though in normal C source code, when the first
> sibling isn't on its own line, that sibling is usually a comment.)
> Anyway, please see my reasoning in the commit message for 08fc6bace20.
>
> I also removed the else_clause rule since it's already added by the
> patch for bug#67417, and added another test.
Thanks, but please in the future mention _all_ relevant bug numbers
in the log message, or merge them if appropriate.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#67357
; Package
emacs
.
(Mon, 11 Dec 2023 01:13:02 GMT)
Full text and
rfc822 format available.
Message #52 received at 67357 <at> debbugs.gnu.org (full text, mbox):
On 12/10/23 1:39 AM, Eli Zaretskii wrote:
>> Date: Sun, 10 Dec 2023 01:09:15 -0800
>> Cc: noah.v.peart <at> gmail.com, 67357 <at> debbugs.gnu.org, dmitry <at> gutov.dev
>> From: Yuan Fu <casouri <at> gmail.com>
>>
>>
>>> Ping! Ping! Yuan, please chime is, as I'm waiting for your comments
>>> before we install on the release branch.
>>>
>>> This and other patches for TS-based modes are currently delaying the
>>> release of Emacs 29.2, so please try to be more responsive, okay?
>>>
>> Whoa! Sorry, I just switched to a new email client, and direct CC isn't
>> highlight as they were before :-( (And admittedly I haven't been
>> browsing the bug tracker lately.)
> OK, but please look also at other bugs and issues where I asked for
> your opinions.
Yes, I'm trying to setup something that can prevent this in the future,
and there are so many CC's that I missed, apologies!
>> As for the patch, first of all, thank you, Noah, it's very good. I try
>> to avoid query matchers since they could be slow, plus the fundamental
>> problem isn't with comments, IMO. The problem is when the first sibling
>> isn't on it's own line. (Though in normal C source code, when the first
>> sibling isn't on its own line, that sibling is usually a comment.)
>> Anyway, please see my reasoning in the commit message for 08fc6bace20.
>>
>> I also removed the else_clause rule since it's already added by the
>> patch for bug#67417, and added another test.
> Thanks, but please in the future mention _all_ relevant bug numbers
> in the log message, or merge them if appropriate.
I'll keep that in mind.
Yuan
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Mon, 08 Jan 2024 12:24:08 GMT)
Full text and
rfc822 format available.
This bug report was last modified 1 year and 162 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.