| www.delorie.com/gnu/docs/emacs/cc-mode_21.html | search |
![]() Buy the book! | |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
To make your changes permanent, you need to add some lisp code to your `.emacs' file. CC Mode supports many different ways to be configured, from the straightforward way by setting variables globally in `.emacs' or in the Customization interface, to the complex and precisely controlled way by using styles and hook functions.
The simplest way of customizing CC Mode permanently is to set the
variables in your `.emacs' with setq and similar commands.
So to make the setting of substatement-open permanent, add this
to the `.emacs' file:
(require 'cc-mode) (c-set-offset 'substatement-open 0) |
The require line is only needed once in the beginning to make
sure CC Mode is loaded so that the c-set-offset function is
defined.
You can also use the more user friendly Customization interface, but this manual does not cover how that works.
Variables set like this at the top level in `.emacs' take effect in
all CC Mode buffers, regardless of language. The indentation style
related variables, e.g. c-basic-offset, that you don't set this
way get their value from the style system (see section 7.4 Styles), and they
therefore depend on the setting of c-default-style. Note that if
you use Customize, this means that the greyed-out default values
presented there might not be the ones you actually get, since the actual
values depend on the style, which may very well be different for
different languages.
If you want to make more advanced configurations, e.g. language-specific customization, global variable settings isn't enough. For that you can use the language hooks, see 7.3 Hooks, and/or the style system, see 7.4 Styles.
By default, all style variables are global, so that every buffer will
share the same style settings. This is fine if you primarily edit one
style of code, but if you edit several languages and want to use
different styles for them, you need finer control by making the style
variables buffer local. The recommended way to do this is to set the
variable c-style-variables-are-local-p to t. The
variables will be made buffer local when CC Mode is activated in a
buffer for the first time in the Emacs session. Note that once the
style variables are made buffer local, they cannot be made global again,
without restarting Emacs.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
| webmaster donations bookstore | delorie software privacy |
| Copyright © 2003 by The Free Software Foundation | Updated Jun 2003 |