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.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Your message dated Sun, 10 Dec 2023 01:09:15 -0800
with message-id <8c7e244d-5dad-4111-89b8-ca7722657ce0 <at> gmail.com>
and subject line Re: bug#67357: [PATCH] Fix c-ts-mode block indent when first-siblings are comments
has caused the debbugs.gnu.org bug report #67357,
regarding [PATCH] Fix c-ts-mode block indent when first-siblings are comments
to be marked as done.
(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)
--
67357: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=67357
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
[Message part 3 (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 4 (text/html, inline)]
[c-ts-mode-first-sib-comments.patch (text/x-patch, attachment)]
[Message part 6 (message/rfc822, inline)]
> 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
This bug report was last modified 1 year and 196 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.