The variables that CC Mode’s style system control are called style variables. Note that style variables are ordinary Lisp variables, which the style system initializes; you can change their values at any time (e.g., in a hook function). The style system can also set other variables, to some extent. See Styles.
Style variables are handled specially in several ways:
nilbefore CC Mode is initialized.
set-from-style. When the style system initializes a buffer-local copy of a style variable for a CC Mode buffer, if its global binding is still that symbol then it will be set from the current style. Otherwise it will retain its global default17. This “otherwise” happens, for example, when you’ve set the variable with
setqat the top level of your .emacs (see Config Basics).
c-offsets-alist(see c-offsets-alist) is an association list with an element for each syntactic symbol. It’s handled a little differently from the other style variables. Its default global binding is the empty list
nil, rather than
set-from-style. Before the style system is initialized, you can add individual elements to
c-set-offset(see c-offsets-alist) just like you would set other style variables with
setq. Those elements will then prevail when the style system later initializes a buffer-local copy of
c-special-indent-hookis also handled in a special way. Styles can only add functions to this hook, not remove them, so any global settings you put on it are always preserved18. The value you give this variable in a style definition can be either a function or a list of functions.
userstyle when the style system is first initialized. See Built-in Styles, for details.
The style variables are:
c-indent-comments-syntactically-p (see Indentation Commands);
c-doc-comment-style (see Doc Comments);
(see Custom Filling and Breaking);
c-hanging-braces-alist (see Hanging Braces);
c-hanging-colons-alist (see Hanging Colons);
c-hanging-semi&comma-criteria (see Hanging Semicolons and Commas);
c-cleanup-list (see Clean-ups);
c-basic-offset (see Customizing Indentation);
c-offsets-alist (see c-offsets-alist);
c-comment-only-line-offset (see Comment Line-Up);
(see Other Indentation);
(see Custom Macros).
This is a big change from versions of
CC Mode earlier than 5.26, where such settings would get overridden
by the style system unless special precautions were taken. That was
changed since it was counterintuitive and confusing, especially to
novice users. If your configuration depends on the old overriding
behavior, you can set the variable
c-old-style-variable-behavior to non-
This did not change in version 5.26.