GNU bug report logs - #64133
CC Mode 5.35.2 (C/*l); incorrect indentation for an arrays of structs.

Previous Next

Package: emacs;

Reported by: Jeff Norden <norden.jeff <at> gmail.com>

Date: Sat, 17 Jun 2023 15:05:01 UTC

Severity: normal

Done: Alan Mackenzie <acm <at> muc.de>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 64133 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Jeff Norden <norden.jeff <at> gmail.com>
Cc: 64133 <at> debbugs.gnu.org
Subject: Re: bug#64133: CC Mode 5.35.2 (C/*l);
 incorrect indentation for an arrays of structs.
Date: Sat, 17 Jun 2023 18:14:34 +0300
> From: Jeff Norden <norden.jeff <at> gmail.com>
> Date: Sat, 17 Jun 2023 10:03:24 -0500
> 
> I've verified the following behavior with c-version 5.35.2 (emacs-29,
> and emacs-30 from git) and with 5.35.1 (emacs 28.2).
> 
> Place the following text into a file with a ".c" extension, and load
> it with "emacs -Q".
> ==========================================
> #include <stdio.h>
> struct three_ints {
>   int a, b, c;
> };
> int main () {
>   struct three_ints numbers[]= {
>     {0,1,2},
> {3,4,5},
>     {6,7,8}
>   };
>   for (int i=0; i<numbers[2].a; i++) {
>     printf("ack ");
>   }
>   printf("\n");
> }
> ==========================================
> Move the cursor to the beginning of the line with {3,4,5} and press
> <tab> to indent the line.  It will be incorrectly indented 2 spaces
> more than the previous line.  Move to the next line, press <tab>,
> and you'll see:
> 
>   struct three_ints numbers[]= {
>     {0,1,2},
>       {3,4,5},
>         {6,7,8}
>   };

This source code uses the 'linux' indentation style, so you should do

  M-x c-set-style RET linux RET

after which the problem goes away, AFAICT.




This bug report was last modified 1 year and 326 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.