GNU bug report logs - #61026
29.0.60; c-ts-mode: Broken indentation for loops and conditions without brace

Previous Next

Package: emacs;

Reported by: Mohammed Sadiq <sadiq <at> sadiqpk.org>

Date: Mon, 23 Jan 2023 11:18:02 UTC

Severity: normal

Found in version 29.0.60

Full log


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

From: Knut Anders Hatlen <kahatlen <at> gmail.com>
To: Yuan Fu <casouri <at> gmail.com>
Cc: 61026 <at> debbugs.gnu.org
Subject: Re: bug#61026: 29.0.60; c-ts-mode: Broken indentation for loops and
 conditions without brace
Date: Tue, 7 Feb 2023 11:41:17 +0100
[Message part 1 (text/plain, inline)]
tir. 7. feb. 2023 kl. 03:30 skrev Yuan Fu <casouri <at> gmail.com>:

>
> Knut Anders Hatlen <kahatlen <at> gmail.com> writes:
>
> > Hi,
> >
> > I'm still seeing odd indentation for conditions without braces. For
> > example, invoking c-ts-mode-indent-defun (C-c C-q) with the point inside
> > this function ...
> >
> > int f(int x) {
> > if (x > 1)
> > return x;
> > else
> > return x + 1;
> > }
> >
> > ... results in the following indentation with the default GNU style:
> >
> > int f(int x) {
> >   if (x > 1)
> > return x;
> >   else
> > return x + 1;
> > }
> >
> > I would have expected this:
> >
> > int f(int x) {
> >   if (x > 1)
> >     return x;
> >   else
> >     return x + 1;
> > }
> >
> > Is something more needed for this bug, or is the problem I'm seeing a
> > different bug?
>
> My bad, I made some changes and didn’t push them, and I’m sitting here
> wondering why everyone is seeing problems... Everything should indent
> fine now.
>
> Yuan
>

Thanks, Yuan!

It now seems to work fine with the GNU style, K&R style and Linux style.
With BSD style, however, it ends up like this:

int f(int x) {
  if (x > 1)
  return x;
  else
  return x + 1;
}

I assume the return statements should have been indented one more level
here too?

Best regards,

-- 
Knut Anders
[Message part 2 (text/html, inline)]

This bug report was last modified 2 years and 127 days ago.

Previous Next


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