bug-indent
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-indent] brace-line-up feature mod for indent


From: Kim Saunders
Subject: Re: [Bug-indent] brace-line-up feature mod for indent
Date: 25 Jul 2002 09:34:03 +1200

> You cannot do this with indent as it is.  If you use -bl -bli2 -i0 you
> will get this:
> if (x > 0)
>   {
>   x--;
>   }
> else
> x++;

That's because x-- is getting indented 2 spaces because of the brace,
and 0 spaces because of i0. Whereas x++ isn't getting indented the two
spaces, because it's not inside a pair of braces.

In a way, this makes sense. But, I can also see entirely why you
expected it to be formatted the way you wanted. And I'd expect the same.

So, I'd like to suggest that, maybe (given my incomplete indent
understanding) that it would be reasonable to expect indent to treat
(and intent):

if (a)
        foo();

as if it were
if (a)
        {
        foo();
        }

The way I see it, one omits braces on one-line conditional blocks, but
it seems reasonable for indent to treat that line as if it were wrapped
in braces.

What Daniel is getting at, is that in

if (a)
        {
        foo();
        }
else
        bar();

The two function calls are at the same depth in terms of conditionals,
and so one would expect them to be indented the same (at least it seems
Daniel and myself would).

What *I'm* getting at, is that I see this more as a bug in the existing
indent code, and that one-line conditionals should perhaps *always* be
indented as if they had braces around them. To me, modifying indent to
display this behaviour makes more sence than adding (yet another)
option, and I can't really see why anyone would want the current
(somewhat inconsistant) behavior.

KimS




reply via email to

[Prev in Thread] Current Thread [Next in Thread]