This section explains the structure and semantics of the style
c-offsets-alist, the principal variable for configuring
indentation. Details of how to set it up, and its relationship to
CC Mode's style system are given in Style Variables.
This is an alist which associates an offset with each syntactic symbol. This offset is a rule specifying how to indent a line whose syntactic context matches the symbol. See Syntactic Analysis.
Note that the buffer-local binding of this alist in a CC Mode buffer contains an entry for every syntactic symbol. Its global binding and its settings within style specifications usually contain only a few entries. See Style Variables.
The offset specification associated with any particular syntactic symbol can be an integer, a variable name, a vector, a function or lambda expression, a list, or one of the following special symbols:
/. The meanings of these values are described in detail below.
Here is an example fragment of a
c-offsets-alist, showing some of these kinds of offsets:((statement . 0) (substatement . +) (cpp-macro . ) (topmost-intro-cont . c-lineup-topmost-intro-cont) (statement-block-intro . (add c-lineup-whitesmith-in-block c-indent-multi-line-block)) ...
You can use
c-set-offsetsinteractively within a CC Mode buffer to make experimental changes to your indentation settings. C-c C-o prompts you for the syntactic symbol to change (defaulting to that of the current line) and the new offset (defaulting to the current offset).
c-set-offsetstakes two arguments when used programmatically: symbol, the syntactic element symbol to change and offset, the new offset for that syntactic element. You can call the command in your .emacs to change the global binding of
c-offsets-alist(see Style Variables); you can use it in a hook function to make changes from the current style. CC Mode itself uses this function when initializing styles.
The “offset specifications” in
c-offsets-alist can be any of
+than an integer (apart from zero).
By defining a style's indentation in terms of
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:
nil values are always ignored when the offsets are combined.
The first element of the list specifies the method of combining the
nil offsets from the remaining elements:
nil. Subsequent elements of the list don't get evaluated.
As a compatibility measure, if the first element is none of the above
then it too will be taken as an offset specification and the whole list
will be combined according to the method
If an offset specification evaluates to
nil, then a relative
offset of 0 (zero) is used2.
 The syntactic context
((defun-block-intro 2724) (comment-intro)) would likely have two relative offsets.
 There is however a variable
c-strict-syntax-p that when set to non-
nil will cause an
error to be signaled in that case. It's now considered obsolete since
it doesn't work well with some of the alignment functions that return
nil instead of zero. You should therefore leave
c-strict-syntax-p set to