Compiz Fusion encourages use of the same coding style seen in Compiz:
Basic style
- Indentations are 4 spaces wide, tabs are eight. So odd-leveled indentation ends with 4 spaces. In other words: For one level of indentation you use 4 spaces. For two levels you use 1 tab, for three levels you use one tab and 4 spaces, for four levels you use two tabs, and so on.
Function calls have a space between name and parameters:
foo ()
not
foo()
Braces/brackets fall on next line to assist readability and closure detection:
if (foo) { bar (); } else { baz (); }
not
if (foo) { bar (); } else { baz (); }
It's ok, though, to omit the braces for a single line call:
if (foo) bar (); bla();
Function specs/prototypes have return and name/parms on seperate lines. Params should be aligned:
static int foo (int a, unsigned int b) { bar (a, b); }
not
static int foo (int a, unsigned int b) { bar (); }
We use C comments, not C++ ones:
/* this calls foo if bar */ if (bar) foo ();
not
// this calls foo if bar if (bar) foo ();
- Variables are defined at the beginning of the scope.
Rule of thumb: CompDisplay variables are called d, CompScreen ones s and CompWindow ones w. As usual, there may be exceptions (e.g. if one needs multiple CompWindow variables).
Editor settings
vim
set formatoptions=croqlt set ts=8 set softtabstop=4 set shiftwidth=4 set cindent set tw=80 set cino=(0,t0