CC MODE Version 5 Documentation. Node: Built-in Styles

prev UP Styles NEXT Adding Styles

6.3.1: Built-in Styles

If you're lucky, one of CC Mode's built-in styles might be just what you're looking for. These include:

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 Commands.

Once you find a built-in style you like, you can make the change permanent by adding some lisp to your `.emacs' file. Let's say for example that you want to use the `ellemtel' style in all your files. You would add this:


(defun my-c-mode-common-hook ()
  ;; use Ellemtel style for all C like languages
  (c-set-style "ellemtel")
  ;; other customizations can go here
  )
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)

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 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.


[1] This document is ftp'able from euagate.eua.ericsson.se

[2] Python is a high level scripting language with a C/C++ foreign function interface. For more information, see <http://www.python.org/>.

prev UP Styles NEXT Adding Styles