Copyright (C) 2000-2012 |
GNU Info (ccmode)Built-in StylesBuilt-in Styles --------------- If you're lucky, one of CC Mode's built-in styles might be just what you're looking for. These include: * `gnu' -- Coding style blessed by the Free Software Foundation for C code in GNU programs. * `k&r' -- The classic Kernighan and Ritchie style for C code. * `bsd' -- Also known as "Allman style" after Eric Allman. * `whitesmith' -- Popularized by the examples that came with Whitesmiths C, an early commercial C compiler. * `stroustrup' -- The classic Stroustrup style for C++ code. * `ellemtel' -- Popular C++ coding standards as defined by "Programming in C++, Rules and Recommendations," Erik Nyquist and Mats Henricson, Ellemtel(1). * `linux' -- C coding standard for Linux (the kernel). * `python' -- C coding standard for Python extension modules(2). * `java' -- The style for editing Java code. Note that the default value for `c-default-style' installs this style when you enter `java-mode'. * `user' -- This is a special style for several reasons. First, the CC Mode customizations you do by using either the Customization interface, or by writing `setq''s at the top level of your `.emacs' file, will be captured in the `user' style. Also, all other styles implicitly inherit their settings from `user' style. This means that for any styles you add via `c-add-style' (Note: Adding Styles) you need only define the differences between your new style and `user' style. The default style in all newly created buffers is `gnu', but you can change this by setting variable `c-default-style'. Although the `user' style is not the default style, any style variable settings you do with the Customization interface or on the top level in your `.emacs' file will by default override the style system, so you don't need to set `c-default-style' to `user' to see the effect of these settings. `c-default-style' takes either a style name string, or an association list of major mode symbols to style names. Thus you can control exactly which default style is used for which CC Mode language mode. Here are the rules: 1. When `c-default-style' is a string, it must be an existing style name as found in `c-style-alist'. This style is then used for all modes. 2. When `c-default-style' is an association list, the current major mode is looked up to find a style name string. In this case, this style is always used exactly as specified and an error will occur if the named style does not exist. 3. If `c-default-style' is an association list, but the current major mode isn't found, then the special symbol `other' is looked up. If this value is found, the associated style is used. 4. If `other' is not found, then the `gnu' style is used. 5. In all cases, the style described in `c-default-style' is installed _before_ the language hooks are run, so you can always override this setting by including an explicit call to `c-set-style' in your language mode hook, or in `c-mode-common-hook'. If you'd like to experiment with these built-in styles you can simply type the following in a CC Mode buffer: C-c . STYLE-NAME RET `C-c .' runs the command `c-set-style'. Note that all style names are case insensitive, even the ones you define. Setting a style in this way does _not_ automatically re-indent your file. For commands that you can use to view the effect of your changes, see Note: Commands. Note that for BOCM compatibility, `gnu' is the default style, and any non-style based customizations you make (i.e. in `c-mode-common-hook' in your `.emacs' file) will be based on `gnu' style unless you set `c-default-style' or do a `c-set-style' as the first thing in your hook. The variable `c-indentation-style' always contains the buffer's current style name, as a string. ---------- Footnotes ---------- (1) This document is available at `http://www.doc.ic.ac.uk/lab/cplus/c++.rules/' among other places. (2) Python is a high level scripting language with a C/C++ foreign function interface. For more information, see `http://www.python.org/'. automatically generated by info2www version 1.2.2.9 |