| www.delorie.com/gnu/docs/emacs/cc-mode_6.html | search |
![]() Buy the book! | |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
CC Mode contains two minor-mode-like features that you should find useful while you enter new C code. The first is called auto-newline mode, and the second is called hungry-delete mode. These minor modes can be toggled on and off independently, and CC Mode can be configured so that it starts up with any combination of these minor modes. By default, both of these minor modes are turned off.
The state of the minor modes is always reflected in the minor mode list on the modeline of the CC Mode buffer. When auto-newline mode is enabled, you will see `C/a' on the mode line (7). When hungry delete mode is enabled you would see `C/h' and when both modes are enabled, you'd see `C/ah'.
CC Mode provides key bindings which allow you to toggle the minor
modes on the fly while editing code. To toggle just the auto-newline
state, hit C-c C-a (c-toggle-auto-state). When you do
this, you should see the `a' indicator either appear or disappear
on the modeline. Similarly, to toggle just the hungry-delete state, use
C-c C-d (c-toggle-hungry-state), and to toggle both states,
use C-c C-t (c-toggle-auto-hungry-state).
To set up the auto-newline and hungry-delete states to your preferred
values, you would need to add some lisp to your `.emacs' file that
called one of the c-toggle-*-state functions directly. When
called programmatically, each function takes a numeric value, where
a positive number enables the minor mode, a negative number disables the
mode, and zero toggles the current state of the mode.
So for example, if you wanted to enable both auto-newline and hungry-delete for all your C file editing, you could add the following to your `.emacs' file:
(add-hook 'c-mode-common-hook (lambda () (c-toggle-auto-hungry-state 1))) |
4.1 Auto-newline Insertion 4.2 Hungry-deletion of Whitespace
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
| webmaster donations bookstore | delorie software privacy |
| Copyright © 2003 by The Free Software Foundation | Updated Jun 2003 |