Copyright (C) 2000-2012 |
GNU Info (ccmode)HooksHooks ===== 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: * `c-mode-hook' -- For C buffers only. * `c++-mode-hook' -- For C++ buffers only. * `objc-mode-hook' -- For Objective-C buffers only. * `java-mode-hook' -- For Java buffers only. * `idl-mode-hook' -- For CORBA IDL buffers only. * `pike-mode-hook' -- For Pike buffers only. * `c-mode-common-hook' -- Common across all languages. * `c-initialization-hook' -- Hook run only once per Emacs session, when CC Mode is initialized. 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. *Note 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) automatically generated by info2www version 1.2.2.9 |