Customizing Indentation
***********************

   The variable `c-offsets-alist' contains the mappings between
syntactic symbols and the offsets to apply for those symbols.  You
should never modify this variable directly though.  The first step in
customizing your indentations is to decide what additional offset you
want to add for every syntactic symbol.

   You can use the command `C-c C-o' (`c-set-offset') as the way to set
offsets, both interactively and from your mode hook(1).  You can set up
*styles* of indentation, which are groupings of syntactic symbol
offsets and other variable values.  Most likely, you'll find that one
of the pre-defined styles will suit your needs.  See Styles for an
explanation of how to set up named styles.

   The offset associated with any particular syntactic symbol can be
any of an integer, a function or lambda expression, a variable name, or
one of the following symbols: `+', `-', `++', `--', `*', or `/'.  These
latter describe offset in multiples of the value of the variable
`c-basic-offset'.  By defining a style's indentation in terms of this
fundamental variable, you can change the amount of whitespace given to
an indentation level while maintaining the same basic shape of your
code.  Here are the values that the special symbols correspond to:

`+'
     `c-basic-offset' times 1

`-'
     `c-basic-offset' times -1

`++'
     `c-basic-offset' times 2

`--'
     `c-basic-offset' times -2

`*'
     `c-basic-offset' times 0.5

`/'
     `c-basic-offset' times -0.5

   The offset can also be a list, in which case it is evaluated
recursively using the semantics described above.  The first element of
the list that returns a non-`nil' value succeeds and the evaluation
stops.  If none of the list elements return a non-`nil' value, then what
happens depends on the value of `c-strict-syntax-p'.  When
`c-strict-syntax-p' is `nil', then an offset of 0 (zero) is used,
otherwise CC Mode issues an error.

So, for example, because most of the default offsets are defined in
terms of `+', `-', and `0', if you like the general indentation style,
but you use 4 spaces instead of 2 spaces per level, you can probably
achieve your style just by changing `c-basic-offset' like so(2):

     *M-x set-variable RET*
     Set variable: *c-basic-offset RET*
     Set c-basic-offset to value: *4 RET*

This would change

     int add( int val, int incr, int doit )
     {
       if( doit )
         {
           return( val + incr );
         }
       return( val );
     }

to

     int add( int val, int incr, int doit )
     {
         if( doit )
             {
                 return( val + incr );
             }
         return( val );
     }

   To change indentation styles more radically, you will want to change
the offsets associated with other syntactic symbols.  First, I'll show
you how to do that interactively, then I'll describe how to make
changes to your `.emacs' file so that your changes are more permanent.

Menu

Interactive Customization
Permanent Customization
Styles
Advanced Customizations
---------- Footnotes ---------- (1) Obviously, you use the keybinding interactively, and the

function call programmatically! (2) You can try this interactively in a C buffer by typing the text

that appears in italics.