GNU Info

Info Node: (ccmode)Styles

(ccmode)Styles


Next: Advanced Customizations Prev: Hooks Up: Customizing Indentation
Enter node , (file) or (file)node

Styles
======

   Most people only need to edit code formatted in just a few
well-defined and consistent styles.  For example, their organization
might impose a "blessed" style that all its programmers must conform
to.  Similarly, people who work on GNU software will have to use the
GNU coding style.  Some shops are more lenient, allowing a variety of
coding styles, and as programmers come and go, there could be a number
of styles in use.  For this reason, CC Mode makes it convenient for you
to set up logical groupings of customizations called "styles",
associate a single name for any particular style, and pretty easily
start editing new or existing code using these styles.

   The variables that the style system affect are called "style
variables".  They are handled specially in several ways:

   * Style variables are by default global variables, i.e. they have
     the same value in all Emacs buffers.  However, they can instead be
     made always buffer local by setting
     `c-style-variables-are-local-p' to non-`nil' before CC Mode is
     initialized.

   * The default value of any style variable (with two exceptions -- see
     below) is the special symbol `set-from-style'.  Variables that are
     still set to that symbol when a CC Mode buffer is initialized will
     be set according to the current style, otherwise they will keep
     their current value(1).

     Note that when we talk about the "default value" for a style
     variable, we don't mean the `set-from-style' symbol that all style
     variables are set to initially, but instead the value it will get
     at mode initialization when neither a style nor a global setting
     has set its value.

     The style variable `c-offsets-alist' is handled a little
     differently from the other style variables.  It's an association
     list, and is thus by default set to the empty list, `nil'.  When
     the style system is initialized, any syntactic symbols already on
     it are kept -- only the missing ones are filled in from the chosen
     style.

     The style variable `c-special-indent-hook' is also handled in a
     special way.  Styles may only add more functions on this hook, so
     the global settings on it are always preserved(2).

   * The global settings of style variables get captured in the special
     `user' style, which is used as the base for all the other styles.
     Note: Built-in Styles, for details.


   The style variables are: `c-basic-offset',
`c-comment-only-line-offset', `c-block-comment-prefix',
`c-comment-prefix-regexp', `c-cleanup-list', `c-hanging-braces-alist',
`c-hanging-colons-alist', `c-hanging-semi&comma-criteria',
`c-backslash-column', `c-special-indent-hook',
`c-label-minimum-indentation', and `c-offsets-alist'.

Built-in Styles
Adding Styles
File Styles
   ---------- Footnotes ----------

   (1) 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-`nil'.

   (2) This did not change in version 5.26.


automatically generated by info2www version 1.2.2.9