indent
Chris Shoemaker
c.shoemaker at cox.net
Fri Mar 9 01:17:06 EST 2007
On Thu, Mar 08, 2007 at 11:46:53PM -0500, David Hampton wrote:
> There's been some discussion on IRC about using the indent program to
> reformat the sources into something consistent from file to file. I'd
> like to propose the following options as a starting point for
> discussion. I think some of these options will be agreed upon by all,
> and I'm sure others will be contentious. :-)
>
> Indentation
>
> -nut No tabs. Indentation is done with spaces.
> -i4 Add four spaces for each indent level
> -ci4 Continuation lines are indented by four spaces
> -cli4 Case labels are indented by four spaces
> -ppi4 Nested pre-processor defines are indented by four spaces
> -nbc Do not force newlines after commas in declarations (default)
> -nbfda Don´t put each argument in a function declaration
> on a separate line (default)
> -lp Line up continued lines at parentheses (default)
> -psl Put the type of a procedure on the line before its name.
> -bbo Prefer to break long lines before boolean operators.
>
> Blank Lines
>
> -nsob Do not swallow optional blank lines (default)
> -bad Force a blank line after a declaration.
> -bbb Force a blank line before a block comment.
> -bap Force blank lines after procedure bodies.
>
> Comments
>
> -fca Reformat all comments except those starting in column 1
> -fc1 Reformat comments starting in column 1
> -sc Continuation lines in a comments start with a '*'
>
> Statements
>
> -npcs Do not put space after the function in function calls.
> -nprs Do not put a space after every ´(´ and before every ´)´.
>
> -ncs Do not put a space after cast operators.
> -saf Put a space after each for.
> -sai Put a space after each if.
> -saw Put a space after each while.
>
> -brs Put braces on struct declaration line.
> -br Put braces on line with if, etc.
> -ce Cuddle else and preceeding `}´.
> -cdw Cuddle while of do {} while; and preceeding `}´.
>
> Other
>
> -l80 Line width of 80.
>
> Attached is a small source file formatted with the above options.
>
> Let the discussion begin. :-)
>
> Of the above list of options, the ones I feel strongly about are lining
> up continued lines at parentheses (-lp), the space-after-keyword group
> (saf, -sai, -saw), and the cuddling-of-braces group (-br, -ce, -cdw). I
> feel most strongly about this last group. The parts of an if/then/else
> statement are clearly delineated by the indentation of the keywords vs.
> the indentation of the code blocks. I believe it a complete waste to
> additionally add vertical separation my making the "else" take up three
> lines. One for a closing parenthesis, one for the word "else", and one
> for an opening parenthesis. Maybe that's just me.
>
> What do the rest of the developers think?
I like it. It's basically K&R, but with -bad -psl and some
comment-formatting.
I would recommend adding -ss, and I would have defaulted to -cli0,
which is also K&R, but I don't feel strongly about it.
-chris
>
> David
>
>
> _______________________________________________
> gnucash-devel mailing list
> gnucash-devel at gnucash.org
> https://lists.gnucash.org/mailman/listinfo/gnucash-devel
More information about the gnucash-devel
mailing list