www.delorie.com/gnu/docs/emacs/cc-mode_22.html   search  
 
Buy the book!


CC Mode Manual

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.3 Hooks

CC Mode provides several hooks that you can use to customize the mode according to your coding style. Each language mode has its own hook, adhering to standard Emacs major mode conventions. There is also one general hook and one package initialization hook:

The language hooks get run as the last thing when you enter that language mode. The c-mode-common-hook is run by all supported modes before the language specific hook, and thus can contain customizations that are common across all languages. Most of the examples in this section will assume you are using the common hook.

Note that all the language-specific mode setup that CC Mode does is done prior to both c-mode-common-hook and the language specific hook. That includes installing the indentation style, which can be mode specific (and also is by default for Java mode). Thus, any style settings done in c-mode-common-hook will override whatever language-specific style is chosen by c-default-style.

Here's a simplified example of what you can add to your `.emacs' file to do things whenever any CC Mode language is edited. See the Emacs manuals for more information on customizing Emacs via hooks. See section D. Sample .emacs file, for a more complete sample `.emacs' file.
 
(defun my-c-mode-common-hook ()
  ;; my customizations for all of c-mode and related modes
  (no-case-fold-search)
  )
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003