This manual is for CC Mode in Emacs.
Copyright @copyright{} 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
- 2003, 2004, 2005 Free Software Foundation, Inc.
+2003, 2004, 2005, 2006 Free Software Foundation, Inc.
@quotation
Permission is granted to copy, distribute and/or modify this document
@vskip 0pt plus 1filll
@insertcopying
-This manual was generated from $Revision: 1.33 $ of $RCSfile: cc-mode.texi,v $, which can be
+This manual was generated from $Revision$ of $RCSfile$, which can be
downloaded from
-@url{http://cvs.sf.net/viewcvs.py/cc-mode/cc-mode/cc-mode.texi}.
+@url{http://cvs.savannah.gnu.org/viewcvs/emacs/emacs/man/cc-mode.texi}.
@end titlepage
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
lists the standard styles that @ccmode{} supplies.
@item
-The next few chapters, describe in detail how to customize the various
+The next few chapters describe in detail how to customize the various
features of @ccmode{}.
@item
@item The (indentation) style
The basic ``shape'' of indentation created by @ccmode{}---by default,
this is @code{gnu} style (except for Java and AWK buffers). A list of
-the availables styles and their descriptions can be found in
+the available styles and their descriptions can be found in
@ref{Built-in Styles}. A complete specification of the @ccmode{}
style system, including how to create your own style, can be found in
the chapter @ref{Styles}. To set your style to @code{linux}, either
be disconcerting until you get used to it. To disable @dfn{electric
indentation} in the current buffer, type @kbd{C-c C-l}. Type the same
thing to enable it again. To have electric indentation disabled by
-default, put the following into your @file{.emacs} mode@footnote{There
+default, put the following into your @file{.emacs} file@footnote{There
is no ``easy customization'' facility for making this change.}:
@example
about it for normal use.
@code{c-indent-command} does different things, depending on the
-settting of @code{c-syntactic-indentation} (@pxref{Indentation Engine
+setting of @code{c-syntactic-indentation} (@pxref{Indentation Engine
Basics}):
@itemize @bullet
(@pxref{Comments,,, xemacs, XEmacs User's Manual})
@end ifset
and the variables below. Finally, position the point after the
-comment starter. This is a standard Emacs command, but @ccmode{}
-enhances it a bit with two variables:
+comment starter. @kbd{C-u M-;} kills any comment on the current line,
+together with any whitespace before it. This is a standard Emacs
+command, but @ccmode{} enhances it a bit with two variables:
@defopt c-indent-comment-alist
@vindex indent-comment-alist (c-)
@findex end-of-defun (c-)
@findex beginning-of-defun
@findex end-of-defun
-Move to the start or end of the current top-level definition, this
-being the outermost brace pair which encloses point. These functions
-are analogous to the Emacs built-in commands @code{beginning-of-defun}
-and @code{end-of-defun}, except they eliminate the constraint that the
-top-level opening brace of the defun must be in column zero. See
-@ref{Defuns,,,@emacsman{}, @emacsmantitle{}}, for more information.
+Move to the start or end of the current top-level definition. This is
+the outermost brace pair which encloses point, together with the
+function header or similar preamble which precedes the opening brace.
+These functions are analogous to the Emacs built-in commands
+@code{beginning-of-defun} and @code{end-of-defun}, except they
+eliminate the constraint that the top-level opening brace of the defun
+must be in column zero. See @ref{Defuns,,,@emacsman{},
+@emacsmantitle{}}, for more information.
Depending on the coding style you're using, you might prefer these two
commands to the standard Emacs ones. If so, consider binding them to
Most punctuation keys provide @dfn{electric} behavior - as well as
inserting themselves they perform some other action, such as
-reindenting the line. A few keywords, such as @code{else}, also
-trigger electric action.
+reindenting the line. This reindentation saves you from having to
+reindent a line manually after typing, say, a @samp{@}}. A few
+keywords, such as @code{else}, also trigger electric action.
You can inhibit the electric behaviour described here by disabling
-electric minor mode (@pxref{Minor Modes}.)
+electric minor mode (@pxref{Minor Modes}).
-Common to all of them is that they only behave electrically when used
-in normal code (as contrasted with getting typed in a string literal
-or comment). Those which cause re-indentation do so only when
+Common to all these keys is that they only behave electrically when
+used in normal code (as contrasted with getting typed in a string
+literal or comment). Those which cause re-indentation do so only when
@code{c-syntactic-indentation} has a non-@code{nil} value (which it
does by default).
@cindex hungry-deletion
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-@kindex C-d
-
If you want to delete an entire block of whitespace at point, you can
use @dfn{hungry deletion}. This deletes all the contiguous whitespace
either before point or after point in a single operation.
useful. In fact, you might find yourself wanting it in @strong{all}
your editing modes!
+Loosely speaking, in what follows, @dfn{@key{DEL}} means ``the
+backspace key'' and @dfn{@key{DELETE}} means ``the forward delete
+key''. This is discussed in more detail below.
+
There are two different ways you can use hungry deletion:
@table @asis
c-toggle-hungry-state}@footnote{Prior to @ccmode{} 5.31, this command
was bound to @kbd{C-c C-d}. @kbd{C-c C-d} is now the default binding
for @code{c-hungry-delete-forward}.} (@pxref{Minor Modes}.) This
-makes @kbd{@key{DEL}} and @kbd{C-d} do forward and backwards hungry
+makes @kbd{@key{DEL}} and @kbd{C-d} do backwards and forward hungry
deletion.
@table @asis
@item Using Distinct Bindings
The other (newer and recommended) way to use hungry deletion is to
-perform @code{c-hungry-backspace} and @code{c-hungry-delete-forward}
-directly through their key sequences rather than using the minor mode
-toggling.
+perform @code{c-hungry-delete-backwards} and
+@code{c-hungry-delete-forward} directly through their key sequences
+rather than using the minor mode toggling.
@table @asis
-@item @kbd{C-c C-@key{Backspace}}, @kbd{C-c DEL}, or @kbd{C-c @key{Backspace}} (@code{c-hungry-backspace})
+@item @kbd{C-c C-@key{DEL}}, or @kbd{C-c @key{DEL}} (@code{c-hungry-delete-backwards})@footnote{This command was formerly known as @code{c-hungry-backspace}.}
@kindex C-c C-<backspace>
-@kindex C-c DEL
@kindex C-c <backspace>
-@findex c-hungry-backspace
-@findex hungry-backspace (c-)
+@kindex C-c C-DEL
+@kindex C-c DEL
+@findex c-hungry-delete-backwards
+@findex hungry-delete-backwards (c-)
Delete any amount of whitespace in the backwards direction (regardless
whether hungry-delete mode is enabled or not). This command is bound
-to both @kbd{C-c C-@key{Backspace}} and @kbd{C-c @key{Backspace}},
-since the more natural one, @kbd{C-c C-@key{Backspace}}, is sometimes
-difficult to type at a character terminal.
+to both @kbd{C-c C-@key{DEL}} and @kbd{C-c @key{DEL}}, since the more
+natural one, @kbd{C-c C-@key{DEL}}, is sometimes difficult to type at
+a character terminal.
-@item @kbd{C-c C-@key{Delete}}, @kbd{C-c C-d}, or @kbd{C-c @key{Delete}} (@code{c-hungry-delete-forward})
-@kindex C-c C-<delete>
+@item @kbd{C-c C-d}, @kbd{C-c C-@key{DELETE}}, or @kbd{C-c @key{DELETE}} (@code{c-hungry-delete-forward})
@kindex C-c C-d
-@kindex C-c <delete>
+@kindex C-c C-<DELETE>
+@kindex C-c <DELETE>
@findex c-hungry-delete-forward
@findex hungry-delete-forward (c-)
Delete any amount of whitespace in the forward direction (regardless
whether hungry-delete mode is enabled or not). This command is bound
-to both @kbd{C-c C-@key{Delete}} and @kbd{C-c @key{Delete}} for the
-same reason as for @key{Backspace} above.
+to both @kbd{C-c C-@key{DELETE}} and @kbd{C-c @key{DELETE}} for the
+same reason as for @key{DEL} above.
@end table
@end table
@kindex <delete>
@kindex <backspace>
-When we talk about @kbd{DEL}, @kbd{C-d}, @key{Backspace} and
-@key{Delete} above, we actually do so without connecting them to the
-physical keys commonly known as @key{Backspace} and @key{Delete}. The
-default bindings to those two keys depends on the flavor of (X)Emacs
-you are using.
+When we talk about @kbd{@key{DEL}}, and @kbd{@key{DELETE}} above, we
+actually do so without connecting them to the physical keys commonly
+known as @key{Backspace} and @key{Delete}. The default bindings to
+those two keys depends on the flavor of (X)Emacs you are using.
@findex c-electric-delete
@findex electric-delete (c-)
@findex c-hungry-delete
@findex hungry-delete (c-)
@vindex delete-key-deletes-forward
-
In XEmacs 20.3 and beyond, the @key{Backspace} key is bound to
@code{c-electric-backspace} and the @key{Delete} key is bound to
@code{c-electric-delete}. You control the direction it deletes in by
setting the variable @code{delete-key-deletes-forward}, a standard
-XEmacs variable. When this variable is non-@code{nil},
-@code{c-electric-delete} will do forward deletion with
-@code{c-electric-delete-forward}, otherwise it does backward deletion
-with @code{c-electric-backspace}. Similarly, @kbd{C-c @key{Delete}}
-and @kbd{C-c C-@key{Delete}} are bound to @code{c-hungry-delete} which
-is controlled in the same way by @code{delete-key-deletes-forward}.
+XEmacs variable.
+@c This variable is encapsulated by XEmacs's (defsubst delete-forward-p ...).
+When this variable is non-@code{nil}, @code{c-electric-delete} will do
+forward deletion with @code{c-electric-delete-forward}, otherwise it
+does backward deletion with @code{c-electric-backspace}. Similarly,
+@kbd{C-c @key{Delete}} and @kbd{C-c C-@key{Delete}} are bound to
+@code{c-hungry-delete} which is controlled in the same way by
+@code{delete-key-deletes-forward}.
@findex normal-erase-is-backspace-mode
@dfn{subword}. Here are some examples:
@multitable {@samp{NSGraphicsContext}} {@samp{NS}, @samp{Graphics}, and @samp{Context}}
-@headitem Nomenclature
+@c This could be converted to @headitem when we require Texinfo 4.7
+@iftex
+@item @b{Nomenclature}
+ @tab @b{Subwords}
+@end iftex
+@ifnottex
+@item Nomenclature
@tab Subwords
+@item ---------------------------------------------------------
+@end ifnottex
@item @samp{GtkWindow}
@tab @samp{Gtk} and @samp{Window}
@item @samp{EmacsFrameClass}
@findex c-downcase-subword
@findex downcase-subword (c-)
@multitable @columnfractions .20 .40 .40
-@headitem Key @tab Word oriented command @tab Subword oriented command
+@c This could be converted to @headitem when we require Texinfo 4.7
+@iftex
+@item @b{Key} @tab @b{Word oriented command} @tab @b{Subword oriented command}
+@end iftex
+@ifnottex
+@item Key @tab Word oriented command @tab Subword oriented command
+@item ----------------------------------------------------------------------------
+@end ifnottex
@item @kbd{M-f} @tab @code{forward-word} @tab @code{c-forward-subword}
@item @kbd{M-b} @tab @code{backward-word} @tab @code{c-backward-subword}
@item @kbd{M-@@} @tab @code{mark-word} @tab @code{c-mark-subword}
@chapter Configuration Basics
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-@cindex Emacs Initiliazation File
+@cindex Emacs Initialization File
@cindex Configuration
You configure @ccmode{} by setting Lisp variables and calling (and
perhaps writing) Lisp functions@footnote{DON'T PANIC!!! This isn't
@ccmode{} still uses the value on that variable if it's set.} is used
then as the comment prefix. It defaults to @samp{*
}@footnote{Actually, this default setting of
-@code{c-block-comment-prefix} typically gets overriden by the default
+@code{c-block-comment-prefix} typically gets overridden by the default
style @code{gnu}, which sets it to blank. You can see the line
splitting effect described here by setting a different style,
e.g. @code{k&r} @xref{Choosing a Style}.}, which makes a comment
that @var{action}s are usually a list containing some combination of
the symbols @code{before} and @code{after} (@pxref{Hanging Braces}).
For more flexibility, you can instead specify brace ``hanginess'' by
-giving a synctactic symbol an @dfn{action function} in
+giving a syntactic symbol an @dfn{action function} in
@code{c-hanging-braces-alist}; this function determines the
``hanginess'' of a brace, usually by looking at the code near it.
the proper functioning of @ccmode{}.
This variable is also bound in three other circumstances:
-(i)@tie{}when calling a c-hanging-semi&comma-criteria function
-(@pxref{Hanging Semicolons and Commas}; (ii)@tie{}when calling a
-line-up function (@pxref{Custom Line-Up}; (iii)@tie{}when calling a
+(i)@w{ }when calling a c-hanging-semi&comma-criteria function
+(@pxref{Hanging Semicolons and Commas}; (ii)@w{ }when calling a
+line-up function (@pxref{Custom Line-Up}; (iii)@w{ }when calling a
c-special-indent-hook function (@pxref{Other Indentation}).
@end defvar
@item space-before-funcall
Insert a space between the function name and the opening parenthesis
of a function call. This produces function calls in the style
-mandated by the GNU coding standards, e.g. @samp{signal@tie{}(SIGINT,
-SIG_IGN)} and @samp{abort@tie{}()}. Clean up occurs when the opening
+mandated by the GNU coding standards, e.g. @samp{signal@w{ }(SIGINT,
+SIG_IGN)} and @samp{abort@w{ }()}. Clean up occurs when the opening
parenthesis is typed. This clean-up should never be active in AWK
Mode, since such a space is syntactically invalid for user defined
functions.
@item cpp-macro
The start of a preprocessor macro definition. @ref{Literal Symbols}.
@item cpp-define-intro
-The first line inside a multiline preproprocessor macro if
+The first line inside a multiline preprocessor macro if
@code{c-syntactic-indentation-in-macros} is set. @ref{Multiline Macro
Symbols}.
@item cpp-macro-cont
different one''. @xref{c-offsets-alist}.
The subsections below describe all the standard line-up functions,
-categorized by the sort of token the lining-up centres around. For
+categorized by the sort of token the lining-up centers around. For
each of these functions there is a ``works with'' list that indicates
which syntactic symbols the function is intended to be used with.
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Normally, the lines in a multi-line macro are indented relative to
-eachother as though they were code. You can suppress this behaviour
+each other as though they were code. You can suppress this behaviour
by setting the following user option:
@defopt c-syntactic-indentation-in-macros
(defun my-c-initialization-hook ()
(define-key c-mode-base-map "\C-m" 'c-context-line-break)
(define-key c-mode-base-map [?\C-\M-a] 'c-beginning-of-defun)
- (define-key c-mode-base-map [?\C-\M-e] 'c-end-of-defun)
+ (define-key c-mode-base-map [?\C-\M-e] 'c-end-of-defun))
(add-hook 'c-initialization-hook 'my-c-initialization-hook)
;; offset customizations not in my-c-style