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
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
Note that file style settings (i.e.,
c-file-style) are applied
before file offset settings
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 CC Hooks). Any individual setting of a variable
will override one made through
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
nil. Since this
variable is virtually always non-
nil anyhow, you’re unlikely to
notice this effect.