Go to the first, previous, next, last section, table of contents.
A C style is a collection of indentation style customizations.
Emacs comes with several predefined indentation styles for C and related
modes, including gnu
, k&r
, bsd
, stroustrup
,
linux
, python
, java
, whitesmith
,
ellemtel
, and cc-mode
. The default style is gnu
.
To choose the style you want, use the command M-x c-set-style.
Specify a style name as an argument (case is not significant in C style
names). The chosen style only affects newly visited buffers, not those
you are already editing. You can also set the variable
c-default-style
to specify the style for various major modes.
Its value should be an alist, in which each element specifies one major
mode and which indentation style to use for it. For example,
(setq c-default-style '((java-mode . "java") (other . "gnu")))
specifies an explicit choice for Java mode, and the default `gnu' style for the other C-like modes.
To define a new C indentation style, call the function
c-add-style
:
(c-add-style name values use-now)
Here name is the name of the new style (a string), and
values is an alist whose elements have the form
(variable . value)
. The variables you specify should
be among those documented in section Variables for C Indentation.
If use-now is non-nil
, c-add-style
switches to the
new style after defining it.
Go to the first, previous, next, last section, table of contents.