The Emacs manual describes how you can customize certain variables on a per-file basis by including a file local variable block at the end of the file (see Local Variables in Files in GNU Emacs Manual).
So far, you’ve only seen a functional interface for setting styles in CC Mode, and this can’t be used here. CC Mode fills the gap by providing two variables for use in a file’s local variable list. Don’t use them anywhere else! These allow you to customize the style on a per-file basis:
Set this variable to a style name string in the Local Variables list.
From now on, when you visit the file, CC Mode will automatically set
the file’s style to this one using c-set-style
.
Set this variable (in the Local Variables list) to an association list
of the same format as c-offsets-alist
. From now on, when you
visit the file, CC Mode will automatically institute these offsets
using c-set-offset
.
Note that file style settings (i.e. c-file-style
) are applied
before file offset settings
(i.e. c-file-offsets
)23.
If you set any variable by the file local variables mechanism, that
setting takes priority over all other settings, even those in your
mode hooks (see Hooks). Any individual setting of a variable
will override one made through c-file-style
or
c-file-offsets
.
Also, if either of these are set
in a file’s local variable section, all the style variable values are
made local to that buffer, even if
c-style-variables-are-local-p
is nil
. Since this
variable is virtually always non-nil
anyhow, you’re unlikely to
notice this effect.