Common code indentation (follow-up to 2007 discussion)
Christian Stimming
stimming at tuhh.de
Mon Jul 13 14:53:24 EDT 2009
After a short discussion on this topic in June, it seems to me everyone is
more or less satisfied with the style proposed below. If this is the case, I
would volunteer to actually transform the code according to this style.
Regards,
Christian
http://lists.gnucash.org/pipermail/gnucash-devel/2007-March/020099.html
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 '*'
-lc80 Comment line width of 80
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.
-ss On one-line for and while statments, force a blank before the semicolon.
-brs Put braces on struct declaration line.
-bl Put braces on line after if, etc. [changed after discussion]
-bli0 Indent braces 0 spaces
Other
-l90 Line width of 90. [changed according to discussion last year]
In one single line:
indent -nut -i4 -ci4 -cli4 -ppi4 -nbc -nbfda -lp -psl -bbo -nsob -bad -bbb -bap -fca -fc1 -sc -lc80 -npcs -nprs -ncs -saf -sai -saw -ss -brs -bl -bli0 -l90
*.h *.c
> On Mon, Jun 8, 2009 at 8:14 AM, Christian Stimming <stimming at tuhh.de> wrote:
> > Zitat von Derek Atkins <warlord at MIT.EDU>:
> >> Charles Day <cedayiv at gmail.com> writes:
> >>> I strongly prefer -bl to -br.
> >>
> >> Me too. I prefer:
> >>
> >> if (....)
> >> {
> >> ....
> >> }
> >> else
> >> {
> >> ...
> >> }
> >
> > Agreed by me. I already wrote the same thing in 2007 [1]: I prefer -bl
> > -bli0 over the proposed options. If this is a somewhat majority opinion
> > here, we should surely use those options instead.
>
> Cool! And if we use -bl, then definitely -bli0 or I will be hopelessly
> confused!
>
> > However I do like:
> >> do
> >> {
> >> ...
> >> } while (...);
> >
> > This is already included by -ce -cdw.
>
> This is my preference as well.
>
> -Charles
More information about the gnucash-devel
mailing list