Styles
Customizing Indentation
For most users, CC Mode will support their coding styles with
very little need for more advanced customizations. Usually, one of the
standard styles defined in c-style-alist
will do the trick. At
most, perhaps one of the syntactic symbol offsets will need to be
tweaked slightly, or maybe c-basic-offset
will need to be
changed. However, some styles require a more flexible framework for
customization, and one of the real strengths of CC Mode is that
the syntactic analysis model provides just such a framework. This allows
you to implement custom indentation calculations for situations not
handled by the mode directly.
Note that the style controlling variables can either have global values,
or can be buffer local (e.g. different in every buffer). If all the C
files you edit tend to have the same style, you might want to keep the
variables global. If you tend to edit files with many different styles,
you will have to make the variables buffer local. The variable
c-style-variables-are-local-p
controls this.
When c-style-variables-are-local-p
is non-nil, then the style
variables will have a different settable value for each buffer,
otherwise all buffers will share the same values. By default, its value
is nil
(i.e. global values). You must set this variable
before CC Mode is loaded into your Emacs session, and once the
variables are made buffer local, they cannot be made global again
(unless you restart Emacs of course!)