GNU bug report logs - #67357
[PATCH] Fix c-ts-mode block indent when first-siblings are comments

Previous Next

Package: emacs;

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

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Noah Peart <noah.v.peart <at> gmail.com>
Subject: bug#67357: closed (Re: bug#67357: [PATCH] Fix c-ts-mode block
 indent when first-siblings are comments)
Date: Sun, 10 Dec 2023 09:10:03 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#67357: [PATCH] Fix c-ts-mode block indent when first-siblings are comments

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 67357 <at> debbugs.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)]
From: Yuan Fu <casouri <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>, 67357-done <at> debbugs.gnu.org
Cc: noah.v.peart <at> gmail.com, 67357 <at> debbugs.gnu.org, dmitry <at> gutov.dev
Subject: Re: bug#67357: [PATCH] Fix c-ts-mode block indent when first-siblings
 are comments
Date: Sun, 10 Dec 2023 01:09:15 -0800
> 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

[Message part 3 (message/rfc822, inline)]
From: Noah Peart <noah.v.peart <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] Fix c-ts-mode block indent when first-siblings are comments
Date: Tue, 21 Nov 2023 17:50:52 -0800
[Message part 4 (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 5 (text/html, inline)]
[c-ts-mode-first-sib-comments.patch (text/x-patch, attachment)]

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.