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: Daniel Gryniewicz
Subject: Re: [Bug-indent] brace-line-up feature mod for indent
Date: 24 Jul 2002 17:50:54 -0400

On Wed, 2002-07-24 at 17:34, Kim Saunders wrote:
> > 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

Actually, what I'm objecting to is the extra indentation within the
braces.  If there was a separate "indent within braces" option, that
would be more flexible than my solution, but as it is, the only way to
get your code inside your braces to line up with the braces is to have
your general indent level be zero (-i0), which of course messes up all
other indentation.

Daniel

-- 
Recursion n.:
        See Recursion.
                        -- Random Shack Data Processing Dictionary





reply via email to

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