\input texinfo@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@comment %**start of header (This is for running Texinfo on a region)@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@comment No overfull hbox marks in the dvi file.@finalout@setfilename ../info/ccmode@settitle CC Mode Manual@footnotestyle end@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@comment @setchapternewpage odd !! we don't want blank pages !!@comment %**end of header (This is for running Texinfo on a region)@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@comment@comment Texinfo manual for CC Mode@comment Generated from the original README file by Krishna Padmasola@comment <krishna@earth-gw.njit.edu>@comment@comment Authors:@comment Barry A. Warsaw@comment Martin Stjernholm@comment@comment Maintained by Martin Stjernholm <bug-cc-mode@gnu.org>@comment@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@copyingThis manual is for CC Mode in Emacs.Copyright @copyright{} 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 FreeSoftware Foundation, Inc.@quotationPermission is granted to copy, distribute and/or modify this documentunder the terms of the GNU Free Documentation License, Version 1.1 orany later version published by the Free Software Foundation; with theInvariant Sections being ``The GNU Manifesto'', ``Distribution'' and``GNU GENERAL PUBLIC LICENSE'', with the Front-Cover texts being ``A GNUManual'', and with the Back-Cover Texts as in (a) below. A copy of thelicense is included in the section entitled ``GNU Free DocumentationLicense'' in the Emacs manual.(a) The FSF's Back-Cover Text is: ``You have freedom to copy and modifythis GNU Manual, like GNU software. Copies published by the FreeSoftware Foundation raise funds for GNU development.''This document is part of a collection distributed under the GNU FreeDocumentation License. If you want to distribute this documentseparately from the collection, you can do so by adding a copy of thelicense to the document, as described in section 6 of the license.@end quotation@end copying@comment Info directory entry for use by install-info. The indentation@comment here is by request from the FSF folks.@dircategory Emacs@direntry* CC Mode: (ccmode). Emacs mode for editing C, C++, Objective-C, Java, Pike, and IDL code.@end direntry@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@comment TeX title page@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@titlepage@sp 10@center @titlefont{CC Mode 5.28}@sp 2@center @subtitlefont{A GNU Emacs mode for editing C and C-like languages}@sp 2@center Barry A. Warsaw, Martin Stjernholm@page@vskip 0pt plus 1filll@insertcopying@end titlepage@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@comment The Top node contains the master menu for the Info file.@comment This appears only in the Info file, not the printed manual.@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@node Top, Introduction, (dir), (dir)@comment node-name, next, previous, up@macro ccmodeCC Mode@end macro@ifinfo@top @ccmode{}@ccmode{} is a GNU Emacs mode for editing files containing C, C++,Objective-C, Java, CORBA IDL, and Pike code. It provides syntax-basedindentation and has several handy commands and some minor modes to makethe editing easier. Note that @ccmode{} does @emph{not} providefont-locking; there are other Emacs packages for that.@end ifinfo@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@menu* Introduction::* Getting Connected::* New Indentation Engine::* Minor Modes::* Text Filling and Line Breaking::* Commands::* Customizing Indentation::* Syntactic Symbols::* Indentation Functions::* Performance Issues::* Limitations and Known Bugs::* Frequently Asked Questions::* Getting the Latest CC Mode Release::* Mailing Lists and Submitting Bug Reports::* Sample .emacs File:: --- Indices ---* Concept Index::* Command Index::* Key Index::* Variable Index:: --- The Detailed Node Listing ---New Indentation Engine* Syntactic Analysis::* Indentation Calculation::Minor Modes* Auto-newline Insertion::* Hungry-deletion of Whitespace::Auto-newline Insertion* Hanging Braces::* Hanging Colons::* Hanging Semi-colons and Commas::* Other Electric Commands::* Clean-ups::Commands* Indentation Commands::* Movement Commands::* Other Commands::Customizing Indentation* Interactive Customization::* Permanent Customization::* Hooks::* Styles::* Advanced Customizations::Styles* Built-in Styles::* Adding Styles::* File Styles::Advanced Customizations* Custom Indentation Functions::* Custom Brace and Colon Hanging::* Customizing Semi-colons and Commas::* Other Special Indentations::@end menu@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@node Introduction, Getting Connected, Top, Top@comment node-name, next, previous, up@chapter Introduction@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@cindex BOCMWelcome to @ccmode{}, a GNU Emacs mode for editing files containing C,C++, Objective-C, Java, CORBA IDL, and Pike code. This incarnation ofthe mode is descendant from @file{c-mode.el} (also called "Boring Old CMode" or BOCM @t{:-)}, and @file{c++-mode.el} version 2, which Barry hasbeen maintaining since 1992. @ccmode{} represents a significantmilestone in the mode's life. It has been fully merged back with Emacs19's @file{c-mode.el}. Also a new, more intuitive and flexible mechanismfor controlling indentation has been developed. Late in 1997, Martinjoined the @ccmode{} Maintainers Team, and implemented the Pike support.As of 2000 Martin has taken over as the sole maintainer.This manual describes @ccmode{}@comment The following line must appear on its own, so that the automatedversion 5.28.@comment Release.py script can update the version number automatically@ccmode{} supports the editing of K&R and ANSI C, @dfn{ARM}@footnote{@cite{The Annotated C++ Reference Manual}, by Ellis andStroustrup.} C++, Objective-C, Java, CORBA's Interface DefinitionLanguage, and Pike@footnote{A C-like scripting language with its rootsin the LPC language used in some MUD engines. See@uref{http://pike.idonex.se/}.} files. In this way, you can easily setup consistent coding styles for use in editing all of these languages.@ccmode{} does @emph{not} handle font-locking (a.k.a. syntax coloring,keyword highlighting) or anything of that nature, for any of thesemodes. Font-locking is handled by other Emacs packages.This manual will describe the following:@itemize @bullet@itemHow to get started using @ccmode{}.@itemHow the new indentation engine works.@itemHow to customize the new indentation engine.@end itemize@findex c-mode@findex c++-mode@findex objc-mode@findex java-mode@findex idl-mode@findex pike-modeNote that the name of this package is ``@ccmode{},'' but there is no toplevel @code{cc-mode} entry point. All of the variables, commands, andfunctions in @ccmode{} are prefixed with @code{c-@var{<thing>}}, and@code{c-mode}, @code{c++-mode}, @code{objc-mode}, @code{java-mode},@code{idl-mode}, and @code{pike-mode} entry points are provided. Thispackage is intended to be a replacement for @file{c-mode.el} and@file{c++-mode.el}.@cindex @file{cc-compat.el} fileThis distribution also contains a filecalled @file{cc-compat.el} which should ease your transition from BOCMto @ccmode{}. If you have a BOCM configuration you are really happywith, and want to postpone learning how to configure @ccmode{}, take alook at that file. It maps BOCM configuration variables to @ccmode{}'snew indentation model. It is not actively supported so for the longrun, you should learn how to customize @ccmode{} to support your codingstyle.A special word of thanks goes to Krishna Padmasola for his work inconverting the original @file{README} file to Texinfo format. I'd alsolike to thank all the @ccmode{} victims who help enormously during theearly beta stages of @ccmode{}'s development.@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@node Getting Connected, New Indentation Engine, Introduction, Top@comment node-name, next, previous, up@chapter Getting Connected@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!If you got this version of @ccmode{} with Emacs or XEmacs, it shouldwork just fine right out of the box. Note however that you may not havethe latest @ccmode{} release and may want to upgrade your copy.If you are upgrading an existing @ccmode{} installation, please see the@file{README} file for installation details. @ccmode{} may not workwith older versions of Emacs or XEmacs. See the @ccmode{} release notesWeb pages for the latest information on Emacs version and packagecompatibility (@pxref{Getting the Latest CC Mode Release}).@cindex @file{cc-mode-18.el} file@emph{Note that @ccmode{} no longerworks with Emacs 18!}, so if you haven't upgraded from Emacs 18 by now,you are out of luck.@findex c-version@findex version (c-)You can find out what version of @ccmode{} you are using by visiting a Cfile and entering @kbd{M-x c-version RET}. You should see this message inthe echo area:@exampleUsing CC Mode version 5.XX@end example@noindentwhere @samp{XX} is the minor release number.@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@node New Indentation Engine, Minor Modes, Getting Connected, Top@comment node-name, next, previous, up@chapter New Indentation Engine@cindex indentation engine@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@ccmode{} has a new indentation engine, providing a simplified, yetflexible and general mechanism for customizing indentation. It separatesindentation calculation into two steps: first, @ccmode{} analyzes theline of code being indented to determine the kind of language constructit's looking at, then it applies user defined offsets to the currentline based on this analysis.This section will briefly cover how indentation is calculated in@ccmode{}. It is important to understand the indentation modelbeing used so that you will know how to customize @ccmode{} foryour personal coding style.@menu* Syntactic Analysis::* Indentation Calculation::@end menu@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@node Syntactic Analysis, Indentation Calculation, , New Indentation Engine@comment node-name, next, previous, up@section Syntactic Analysis@cindex syntactic analysis@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@cindex relative buffer position@cindex syntactic symbol@cindex syntactic component@cindex syntactic component listThe first thing @ccmode{} does when indenting a line of code, is toanalyze the line, determining the @dfn{syntactic component list} of theconstruct on that line. A syntactic component consists of a pair ofinformation (in lisp parlance, a @emph{cons cell}), where the first partis a @dfn{syntactic symbol}, and the second part is a @dfn{relativebuffer position}. Syntactic symbols describe elements of C code@footnote{Unless otherwise noted, the term ``C code'' to refers to allthe C-like languages.}, e.g. @code{statement}, @code{substatement},@code{class-open}, @code{class-close}, etc. @xref{Syntactic Symbols},for a complete list of currently recognized syntactic symbols and theirsemantics. The style variable @code{c-offsets-alist} also contains thelist of currently supported syntactic symbols.Conceptually, a line of C code is always indented relative to theindentation of some line higher up in the buffer. This is representedby the relative buffer position in the syntactic component.Here is an example. Suppose we had the following code as the only thingin a C++ buffer @footnote{The line numbers in this and future examplesdon't actually appear in the buffer, of course!}:@example@group 1: void swap( int& a, int& b ) 2: @{ 3: int tmp = a; 4: a = b; 5: b = tmp; 6: @}@end group@end example@kindex C-c C-s@findex c-show-syntactic-information@findex show-syntactic-information (c-)We can use the command @kbd{C-c C-s}(@code{c-show-syntactic-information}) to simply report what thesyntactic analysis is for the current line. Running this command online 4 of this example, we'd see in the echo area@footnote{With a universalargument (i.e. @kbd{C-u C-c C-s}) the analysis is inserted into thebuffer as a commenton the current line.}:@example((statement . 35))@end exampleThis tells us that the line is a statement and it is indented relativeto buffer position 35, which happens to be the @samp{i} in @code{int} online 3. If you were to move point to line 3 and hit @kbd{C-c C-s}, youwould see:@example((defun-block-intro . 29))@end exampleThis indicates that the @samp{int} line is the first statement in a toplevel function block, and is indented relative to buffer position 29,which is the brace just after the function header.Here's another example:@example@group 1: int add( int val, int incr, int doit ) 2: @{ 3: if( doit ) 4: @{ 5: return( val + incr ); 6: @} 7: return( val ); 8: @}@end group@end example@noindentHitting @kbd{C-c C-s} on line 4 gives us:@example((substatement-open . 46))@end example@cindex substatement@cindex substatement block@noindentwhich tells us that this is a brace that @emph{opens} a substatementblock. @footnote{A @dfn{substatement} is the line after aconditional statement, such as @code{if}, @code{else}, @code{while},@code{do}, @code{switch}, etc. A @dfn{substatementblock} is a brace block following one of these conditional statements.}@cindex comment-only lineSyntactic component lists can contain more than one component, andindividual syntactic components need not have relative buffer positions.The most common example of this is a line that contains a @dfn{commentonly line}.@example@group 1: void draw_list( List<Drawables>& drawables ) 2: @{ 3: // call the virtual draw() method on each element in list 4: for( int i=0; i < drawables.count(), ++i ) 5: @{ 6: drawables[i].draw(); 7: @} 8: @}@end group@end example@noindentHitting @kbd{C-c C-s} on line 3 of this example gives:@example((comment-intro) (defun-block-intro . 46))@end example@noindentand you can see that the syntactic component list contains two syntacticcomponents. Also notice that the first component,@samp{(comment-intro)} has no relative buffer position.@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@node Indentation Calculation, , Syntactic Analysis, New Indentation Engine@comment node-name, next, previous, up@section Indentation Calculation@cindex indentation calculation@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!Indentation for a line is calculated using the syntacticcomponent list derived in step 1 above (@pxref{Syntactic Analysis}).Each component contributes to the final total indentation of the line intwo ways.First, the syntactic symbols are looked up in the @code{c-offsets-alist}style variable, which is an association list of syntactic symbols andthe offsets to apply for those symbols. These offsets are added to arunning total.Second, if the component has a relative buffer position, @ccmode{}adds the column number of that position to the running total. By addingup the offsets and columns for every syntactic component on the list,the final total indentation for the current line is computed.Let's use our two code examples above to see how this works. Here isour first example again:@example@group 1: void swap( int& a, int& b ) 2: @{ 3: int tmp = a; 4: a = b; 5: b = tmp; 6: @}@end group@end exampleLet's say point is on line 3 and we hit the @kbd{TAB} key to re-indentthe line. Remember that the syntactic component list for thatline is:@example((defun-block-intro . 29))@end example@noindent@ccmode{} looks up @code{defun-block-intro} in the@code{c-offsets-alist} style variable. Let's say it finds the value@samp{4}; it adds this to the running total (initialized to zero),yielding a running total indentation of 4 spaces.Next @ccmode{} goes to buffer position 29 and asks for the currentcolumn. This brace is in column zero, so @ccmode{}adds @samp{0} to the running total. Since there is only one syntacticcomponent on the list for this line, indentation calculation iscomplete, and the total indentation for the lineis 4 spaces.Here's another example:@example@group 1: int add( int val, int incr, int doit ) 2: @{ 3: if( doit ) 4: @{ 5: return( val + incr ); 6: @} 7: return( val ); 8: @}@end group@end exampleIf we were to hit @kbd{TAB} on line 4 in the above example, the samebasic process is performed, despite the differences in the syntacticcomponent list. Remember that the list for this line is:@example((substatement-open . 46))@end exampleHere, @ccmode{} first looks up the @code{substatement-open} symbolin @code{c-offsets-alist}. Let's say it finds the value @samp{4}. Thisyields a running total of 4. @ccmode{} then goes tobuffer position 46, which is the @samp{i} in @code{if} on line 3. Thischaracter is in the fourth column on that line so adding this to therunning total yields an indentation for the line of 8 spaces.Simple, huh?Actually, the mode usually just does The Right Thing without you havingto think about it in this much detail. But when customizingindentation, it's helpful to understand the general indentation modelbeing used.@vindex c-echo-syntactic-information-p@vindex echo-syntactic-information-p (c-)As you configure @ccmode{}, you might want to set the variable@code{c-echo-syntactic-information-p} to non-@code{nil} so that thesyntactic component list and calculated offset will always be echoed inthe minibuffer when you hit @kbd{TAB}.@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@node Minor Modes, Text Filling and Line Breaking, New Indentation Engine, Top@comment node-name, next, previous, up@chapter Minor Modes@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@ccmode{} contains two minor-mode-like features that you shouldfind useful while you enter new C code. The first is called@dfn{auto-newline} mode, and the second is called @dfn{hungry-delete}mode. These minor modes can be toggled on and off independently, and@ccmode{} can be configured so that it starts up with anycombination of these minor modes. By default, both of these minor modesare turned off.The state of the minor modes is always reflected in the minor mode liston the modeline of the @ccmode{} buffer. When auto-newline mode isenabled, you will see @samp{C/a} on the mode line @footnote{The @samp{C}would be replaced with @samp{C++}, @samp{ObjC}, @samp{Java}, @samp{IDL},or @samp{Pike} for the respective languages.}. When hungry delete modeis enabled you would see @samp{C/h} and when both modes are enabled,you'd see @samp{C/ah}.@kindex C-c C-a@kindex C-c C-d@kindex C-c C-t@findex c-toggle-hungry-state@findex c-toggle-auto-state@findex c-toggle-auto-hungry-state@findex toggle-hungry-state (c-)@findex toggle-auto-state (c-)@findex toggle-auto-hungry-state (c-)@ccmode{} provides key bindings which allow you to toggle the minormodes on the fly while editing code. To toggle just the auto-newlinestate, hit @kbd{C-c C-a} (@code{c-toggle-auto-state}). When you dothis, you should see the @samp{a} indicator either appear or disappearon the modeline. Similarly, to toggle just the hungry-delete state, use@kbd{C-c C-d} (@code{c-toggle-hungry-state}), and to toggle both states,use @kbd{C-c C-t} (@code{c-toggle-auto-hungry-state}).To set up the auto-newline and hungry-delete states to your preferredvalues, you would need to add some lisp to your @file{.emacs} file thatcalled one of the @code{c-toggle-*-state} functions directly. Whencalled programmatically, each function takes a numeric value, wherea positive number enables the minor mode, a negative number disables themode, and zero toggles the current state of the mode.So for example, if you wanted to enable both auto-newline andhungry-delete for all your C file editing, you could add the followingto your @file{.emacs} file:@example(add-hook 'c-mode-common-hook (lambda () (c-toggle-auto-hungry-state 1)))@end example@cindex electric characters@menu* Auto-newline Insertion::* Hungry-deletion of Whitespace::@end menu@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@node Auto-newline Insertion, Hungry-deletion of Whitespace, , Minor Modes@comment node-name, next, previous, up@section Auto-newline Insertion@cindex auto-newline insertion@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@cindex electric commandsAuto-newline minor mode works by enabling certain @dfn{electriccommands}. Electric commands are typically bound to special characterssuch as the left and right braces, colons, semi-colons, etc., which whentyped, perform some magic formatting in addition to inserting the typedcharacter. As a general rule, electric commands are only electric whenthe following conditions apply:@itemize @bullet@itemAuto-newline minor mode is enabled, as evidenced by a @samp{C/a} or@samp{C/ah} indicator on the modeline.@cindex literal@cindex syntactic whitespace@itemThe character was not typed inside of a literal @footnote{A@dfn{literal} is defined as any comment, string, or C preprocessor macrodefinition. These constructs are also known as @dfn{syntacticwhitespace} since they are usually ignored when scanning C code.}.@item@kindex C-uNo numeric argument was supplied to the command (i.e. it was typed asnormal, with no @kbd{C-u} prefix).@end itemize@menu* Hanging Braces::* Hanging Colons::* Hanging Semi-colons and Commas::* Other Electric Commands::* Clean-ups::@end menu@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@node Hanging Braces, Hanging Colons, , Auto-newline Insertion@comment node-name, next, previous, up@subsection Hanging Braces@cindex hanging braces@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@findex c-electric-brace@findex electric-brace (c-)@vindex c-hanging-braces-alist@vindex hanging-braces-alist (c-)When you type either an open or close brace (i.e. @kbd{@{} or @kbd{@}}),the electric command @code{c-electric-brace} gets run. This command hastwo electric formatting behaviors. First, it will perform somere-indentation of the line the brace was typed on, and second, it willadd various newlines before and/or after the typed brace.Re-indentation occurs automatically whenever the electric behavior isenabled. If the brace ends up on a line other than the one it was typedon, then that line is also re-indented.@cindex class-open syntactic symbol@cindex class-close syntactic symbol@cindex defun-open syntactic symbol@cindex defun-close syntactic symbol@cindex inline-open syntactic symbol@cindex inline-close syntactic symbol@cindex brace-list-open syntactic symbol@cindex brace-list-close syntactic symbol@cindex brace-list-intro syntactic symbol@cindex brace-entry-open syntactic symbol@cindex block-open syntactic symbol@cindex block-close syntactic symbol@cindex substatement-open syntactic symbol@cindex statement-case-open syntactic symbol@cindex extern-lang-open syntactic symbol@cindex extern-lang-close syntactic symbol@cindex namespace-open syntactic symbol@cindex namespace-close syntactic symbol@cindex inexpr-class-open symbol@cindex inexpr-class-close symbolThe default in auto-newline mode is to insert newlines both before andafter a brace, but that can be controlled by the@code{c-hanging-braces-alist} style variable. This variable contains amapping between syntactic symbols related to braces, and a list ofplaces to insert a newline. The syntactic symbols that are useful forthis list are: @code{class-open}, @code{class-close}, @code{defun-open},@code{defun-close}, @code{inline-open}, @code{inline-close},@code{brace-list-open}, @code{brace-list-close},@code{brace-list-intro}, @code{brace-entry-open}, @code{block-open},@code{block-close}, @code{substatement-open},@code{statement-case-open}, @code{extern-lang-open},@code{extern-lang-close}, @code{namespace-open}, @code{namespace-close},@code{inexpr-class-open}, and @code{inexpr-class-close}@footnote{Notethat the aggregate constructs in Pike mode, @samp{(@{}, @samp{@})},@samp{([}, @samp{])}, and @samp{(<}, @samp{>)}, do not count as bracelists in this regard, even though they do for normal indentationpurposes. It's currently not possible to set automatic newlines onthese constructs.}. @xref{Syntactic Symbols}, for a more detaileddescription of these syntactic symbols, except for@code{inexpr-class-open} and @code{inexpr-class-close}, which aren'tactual syntactic symbols.The braces of anonymous inner classes in Java are given the specialsymbols @code{inexpr-class-open} and @code{inexpr-class-close}, so thatthey can be distinguished from the braces of normal classes@footnote{Thebraces of anonymous classes produces a combination of@code{inexpr-class}, and @code{class-open} or @code{class-close} innormal indentation analysis.}.The value associated with each syntactic symbol in this association listis called an @var{ACTION} which can be either a function or a list.@xref{Custom Brace and Colon Hanging}, for a more detailed discussion ofusing a function as a brace hanging @var{ACTION}.When the @var{ACTION} is a list, it can contain any combination of thesymbols @code{before} and @code{after}, directing @ccmode{} where toput newlines in relationship to the brace being inserted. Thus, if thelist contains only the symbol @code{after}, then the brace is said to@dfn{hang} on the right side of the line, as in:@example@group// here, open braces always `hang'void spam( int i ) @{ if( i == 7 ) @{ dosomething(i); @}@}@end group@end exampleWhen the list contains both @code{after} and @code{before}, the braceswill appear on a line by themselves, as shown by the close braces in theabove example. The list can also be empty, in which case no newlinesare added either before or after the brace.If a syntactic symbol is missing entirely from@code{c-hanging-braces-alist}, it's treated in the same way as an@var{ACTION} with a list containing @code{before} and @code{after}, sothat braces by default end up on their own line.For example, the default value of @code{c-hanging-braces-alist} is:@example@group ((brace-list-open) (brace-entry-open) (substatement-open after) (block-close . c-snug-do-while) (extern-lang-open after) (inexpr-class-open after) (inexpr-class-close before))@end group@end example@noindent which says that @code{brace-list-open} and@code{brace-entry-open} braces should both hang on the right side, andallow subsequent text to follow on the same line as the brace. Also,@code{substatement-open}, @code{extern-lang-open}, and@code{inexpr-class-open} braces should hang on the right side, butsubsequent text should follow on the next line. The opposite holds for@code{inexpr-class-close} braces; they won't hang, but the followingtext continues on the same line. Here, in the @code{block-close} entry,you also see an example of using a function as an @var{ACTION}. In allother cases, braces are put on a line by themselves.A word of caution: it is not a good idea to hang top-level constructintroducing braces, such as @code{class-open} or @code{defun-open}.Emacs makes an assumption that such braces will always appear in columnzero, hanging them can introduce performance problems.@xref{Performance Issues}, for more information.@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@node Hanging Colons, Hanging Semi-colons and Commas, Hanging Braces, Auto-newline Insertion@comment node-name, next, previous, up@subsection Hanging Colons@cindex hanging colons@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@vindex hanging-colons-alist (c-)@vindex c-hanging-colons-alistUsing a mechanism similar to brace hanging (@pxref{Hanging Braces}),colons can also be made to hang using the style variable@code{c-hanging-colons-alist}. The syntactic symbols appropriate forthis association list are: @code{case-label}, @code{label},@code{access-label}, @code{member-init-intro}, and @code{inher-intro}.Note however that for @code{c-hanging-colons-alist}, @var{ACTION}s asfunctions are not supported. See also @ref{Custom Brace and ColonHanging} for details.In C++, double-colons are used as a scope operator but because thesecolons always appear right next to each other, newlines before and afterthem are controlled by a different mechanism, called @dfn{clean-ups} in@ccmode{}. @xref{Clean-ups}, for details.@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@node Hanging Semi-colons and Commas, Other Electric Commands, Hanging Colons, Auto-newline Insertion@comment node-name, next, previous, up@subsection Hanging Semi-colons and Commas@cindex hanging semi-colons@cindex hanging commas@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!Semicolons and commas are also electric in @ccmode{}, but sincethese characters do not correspond directly to syntactic symbols, adifferent mechanism is used to determine whether newlines should beautomatically inserted after these characters. @xref{CustomizingSemi-colons and Commas}, for details.@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@node Other Electric Commands, Clean-ups, Hanging Semi-colons and Commas, Auto-newline Insertion@comment node-name, next, previous, up@subsection Other Electric Commands@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@kindex #@findex c-electric-pound@vindex c-electric-pound-behavior@findex electric-pound (c-)@vindex electric-pound-behavior (c-)A few other keys also provide electric behavior. For example@kbd{#} (@code{c-electric-pound}) is electric when typed asthe first non-whitespace character on a line. In this case, thevariable @code{c-electric-pound-behavior} is consulted for the electricbehavior. This variable takes a list value, although the only elementcurrently defined is @code{alignleft}, which tells this command to forcethe @samp{#} character into column zero. This is useful for enteringC preprocessor macro definitions.@findex c-electric-star@findex c-electric-slash@findex electric-star (c-)@findex electric-slash (c-)Stars and slashes (i.e. @kbd{*} and @kbd{/}, @code{c-electric-star} and@code{c-electric-slash} respectively) are also electric undercertain circumstances. If a star is inserted as the second character ofa C style block comment on a comment-only line, then the commentdelimiter is indented as defined by @code{c-offsets-alist}. Acomment-only line is defined as a line which contains only a comment, asin:@example@groupvoid spam( int i )@{ // this is a comment-only line... if( i == 7 ) // but this is not @{ dosomething(i); @}@}@end group@end exampleLikewise, if a slash is inserted as the second slash in a C++ style linecomment (also only on a comment-only line), then the line is indented asdefined by @code{c-offsets-alist}.@findex c-electric-lt-gt@findex electric-lt-gt (c-)@kindex <@kindex >Less-than and greater-than signs (@code{c-electric-lt-gt}) are alsoelectric, but only in C++ mode. Hitting the second of two @kbd{<} or@kbd{>} keys re-indents the line if it is a C++ style stream operator.@findex c-electric-paren@findex electric-paren (c-)@kindex (@kindex )The normal parenthesis characters @samp{(} and @samp{)} also reindentthe current line if they are used in normal code. This is useful forgetting the closing parenthesis of an argument list alignedautomatically.@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@node Clean-ups, , Other Electric Commands, Auto-newline Insertion@comment node-name, next, previous, up@subsection Clean-ups@cindex clean-ups@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@dfn{Clean-ups} are mechanisms complementary to colon and brace hanging.On the surface, it would seem that clean-ups overlap the functionalityprovided by the @code{c-hanging-*-alist} variables. Clean-ups arehowever used to adjust code ``after-the-fact,'' i.e. to adjust thewhitespace in constructs after they are typed.Most of the clean-ups are only applicable to counteract automaticallyinserted newlines, and will therefore only have any effect if theauto-newline minor mode is turned on. Others will work all the time.@vindex c-cleanup-list@vindex cleanup-list (c-)@cindex literalYou can configure @ccmode{}'s clean-ups by setting the style variable@code{c-cleanup-list}, which is a list of clean-up symbols. By default,@ccmode{} cleans up only the @code{scope-operator} construct, which isnecessary for proper C++ support. Note that clean-ups are onlyperformed when the construct does not occur within a literal(@pxref{Auto-newline Insertion}), and when there is nothing butwhitespace appearing between the individual components of the construct.These are the clean-ups that only are active in the auto-newline minormode:@itemize @bullet@item@code{brace-else-brace} --- Clean up @samp{@} else @{} constructs byplacing the entire construct on a single line. Clean-up occurs when theopen brace after the @samp{else} is typed. So for example, this:@example@groupvoid spam(int i)@{ if( i==7 ) @{ dosomething(); @} else @{@end group@end example@noindentappears like this after the open brace is typed:@example@groupvoid spam(int i)@{ if( i==7 ) @{ dosomething(); @} else @{@end group@end example@item@code{brace-elseif-brace} --- Similar to the @code{brace-else-brace}clean-up, but this cleans up @samp{@} else if (...) @{} constructs. Forexample:@example@groupvoid spam(int i)@{ if( i==7 ) @{ dosomething(); @} else if( i==3 ) @{@end group@end example@noindentappears like this after the open parenthesis is typed:@example@groupvoid spam(int i)@{ if( i==7 ) @{ dosomething(); @} else if( i==3 ) @{@end group@end example@noindentand like this after the open brace is typed:@example@groupvoid spam(int i)@{ if( i==7 ) @{ dosomething(); @} else if( i==3 ) @{@end group@end example@item@code{brace-catch-brace} --- Analogous to @code{brace-elseif-brace}, butcleans up @samp{@} catch (...) @{} in C++ and Java mode.@item@code{empty-defun-braces} --- Clean up braces following a top-levelfunction or class definition that contains no body. Clean up occurswhen the closing brace is typed. Thus the following:@example@groupclass Spam@{@}@end group@end example@noindentis transformed into this when the close brace is typed:@example@groupclass Spam@{@}@end group@end example@item@code{defun-close-semi} --- Clean up the terminating semi-colon ontop-level function or class definitions when they follow a closebrace. Clean up occurs when the semi-colon is typed.So for example, the following:@example@groupclass Spam@{@};@end group@end example@noindentis transformed into this when the semi-colon is typed:@example@groupclass Spam@{@};@end group@end example@item@code{list-close-comma} --- Clean up commas following braces in arrayand aggregate initializers. Clean up occurs when the comma is typed.@item@code{scope-operator} --- Clean up double colons which may designate aC++ scope operator split across multiple lines@footnote{Certain C++constructs introduce ambiguous situations, so @code{scope-operator}clean-ups may not always be correct. This usually only occurs whenscoped identifiers appear in switch label tags.}. Clean up occurs whenthe second colon is typed. You will always want @code{scope-operator}in the @code{c-cleanup-list} when you are editing C++ code.@end itemizeThe following clean-ups are always active when they occur on@code{c-cleanup-list}, and are thus not affected by the auto-newlineminor mode:@itemize @bullet@item@code{space-before-funcall} --- Insert a space between the function nameand the opening parenthesis of a function call. This produces functioncalls in the style mandated by the GNU coding standards,e.g. @samp{signal (SIGINT, SIG_IGN)} and @samp{abort ()}. Clean upoccurs when the opening parenthesis is typed.@item@code{compact-empty-funcall} --- Clean up any space between the functionname and the opening parenthesis of a function call that have noarguments. This is typically used together with@code{space-before-funcall} if you prefer the GNU function call stylefor functions with arguments but think it looks ugly when it's only anempty parenthesis pair. I.e. you will get @samp{signal (SIGINT,SIG_IGN)}, but @samp{abort()}. Clean up occurs when the closingparenthesis is typed.@end itemize@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@node Hungry-deletion of Whitespace, , Auto-newline Insertion, Minor Modes@comment node-name, next, previous, up@section Hungry-deletion of Whitespace@cindex hungry-deletion of whitespace@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!Hungry deletion of whitespace, or as it more commonly called,@dfn{hungry-delete mode}, is a simple feature that some people findextremely useful. In fact, you might find yourself wantinghungry-delete in @strong{all} your editing modes!@kindex DEL@kindex BackspaceIn a nutshell, when hungry-delete mode is enabled, hitting the@key{Backspace} key@footnote{I say ``hit the @key{Backspace} key'' butwhat I really mean is ``when Emacs receives the @code{BackSpace} keyevent.'' The difference usually isn't significant to most users, butadvanced users will realize that under window systems such as X, anyphysical key (keycap) on the keyboard can be configured to generate anykeysym, and thus any Emacs key event. Also, the use of Emacs on TTYswill affect which keycap generates which key event. From a pedanticpoint of view, here we are only concerned with the key event thatEmacs receives.} will consume all preceding whitespace, includingnewlines and tabs. This can really cut down on the number of@key{Backspace}'s you have to type if, for example you made a mistake onthe preceding line.@findex c-electric-backspace@findex electric-backspace (c-)@vindex c-backspace-function@vindex backspace-function (c-)@findex c-electric-delete@findex electric-delete (c-)@vindex c-delete-function@vindex delete-function (c-)@cindex literal@findex backward-delete-char-untabifyBy default, when you hit the @key{Backspace} key @ccmode{} runs thecommand @code{c-electric-backspace}, which deletes text in the backwardsdirection. When deleting a single character, or when @key{Backspace} ishit in a literal (@pxref{Auto-newline Insertion}), or when hungry-deletemode is disabled, the function contained in the@code{c-backspace-function} variable is called with one argument (thenumber of characters to delete). This variable is set to@code{backward-delete-char-untabify} by default.@vindex delete-key-deletes-forward@findex delete-charThe default behavior of the @key{Delete} key depends on the flavor ofEmacs you are using. By default in XEmacs 20.3 and beyond, the@key{Delete} key is bound to @code{c-electric-delete}. You control thedirection that the @key{Delete} key deletes by setting the variable@code{delete-key-deletes-forward}, a standard XEmacs variable. Whenthis variable is non-@code{nil} and hungry-delete mode is enabled,@code{c-electric-delete} will consume all whitespace @emph{following}point. When @code{delete-key-deletes-forward} is @code{nil}, it deletesall whitespace @emph{preceding} point@footnote{i.e. it literally calls@code{c-electric-backspace}.} When deleting a single character, or if@key{Delete} is hit in a literal, or hungry-delete mode is disabled, thefunction contained in @code{c-delete-function} is called with oneargument: the number of characters to delete. This variable is set to@code{delete-char} by default.In Emacs 19 or Emacs 20, both the @key{Delete} and @key{Backspace} keysare bound to @code{c-electric-backspace}, however you can change this byexplicitly binding @code{[delete]}@footnote{E.g. to@code{c-electric-delete} in your @file{.emacs} file. Note however, thatEmacs 20 does not have a standard variable such as@code{delete-key-deletes-forward}.}.XEmacsen older than 20.3 behave similar to Emacs 19 and Emacs 20.@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@node Text Filling and Line Breaking, Commands, Minor Modes, Top@comment node-name, next, previous, up@chapter Text Filling and Line Breaking@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!Since there's a lot of normal text in comments and string literals,@ccmode{} provides features to edit these like in text mode. The goalis to do it as seamlessly as possible, i.e. you can use auto fill mode,sentence and paragraph movement, paragraph filling, adaptive filling etcwherever there's a piece of normal text without having to think muchabout it. @ccmode{} should keep the indentation, fix the comment linedecorations, and so on, for you. It does that by hooking in on thedifferent line breaking functions and tuning relevant variables asnecessary.@vindex c-comment-prefix-regexp@vindex comment-prefix-regexp (c-)@cindex comment line prefix@vindex comment-start@vindex comment-end@vindex comment-start-skip@vindex paragraph-start@vindex paragraph-separate@vindex paragraph-ignore-fill-prefix@vindex adaptive-fill-mode@vindex adaptive-fill-regexp@vindex adaptive-fill-first-line-regexpTo make Emacs recognize comments and treat text in them as normalparagraphs, @ccmode{} makes several standardvariables@footnote{@code{comment-start}, @code{comment-end},@code{comment-start-skip}, @code{paragraph-start},@code{paragraph-separate}, @code{paragraph-ignore-fill-prefix},@code{adaptive-fill-mode}, @code{adaptive-fill-regexp}, and@code{adaptive-fill-first-line-regexp}.} buffer local and modifies themaccording to the language syntax and the style of line decoration thatstarts every line in a comment. The style variable@code{c-comment-prefix-regexp} contains the regexp used to recognizethis @dfn{comment line prefix}. The default is @samp{//+\\|\\**}, whichmatches C++ style line comments like@example// blah blah@end example@noindentwith two or more slashes in front of them, and C style block commentslike@example@group/* * blah blah */@end group@end example@noindentwith zero or more stars at the beginning of every line. If you changethat variable, please make sure it still matches the comment starter(i.e. @code{//}) of line comments @emph{and} the line prefix insideblock comments. Also note that since @ccmode{} uses the value of@code{c-comment-prefix-regexp} to set up several other variables at modeinitialization, you need to reinitialize the program mode if you changeit inside a @ccmode{} buffer.@findex auto-fill-mode@cindex auto fill mode@cindex paragraph fillLine breaks are by default handled (almost) the same regardless whetherthey are made by auto fill mode (@pxref{Auto Fill,,, emacs, The EmacsEditor}), paragraph filling (e.g. with @kbd{M-q}), or explicitly with@kbd{M-j} or similar methods. In string literals, the new line gets thesame indentation as the previous nonempty line (may be changed with the@code{string} syntactic symbol). In comments, @ccmode{} uses@code{c-comment-prefix-regexp} to adapt the line prefix from the otherlines in the comment.@vindex adaptive-fill-mode@cindex adaptive fill mode@ccmode{} uses adaptive fill mode (@pxref{Adaptive Fill,,, emacs, TheEmacs Editor}) to make Emacs correctly keep the line prefix when fillingparagraphs. That also makes Emacs preserve the text indentation@emph{inside} the comment line prefix. E.g. in the following comment,both paragraphs will be filled with the left margins kept intact:@example@group/* Make a balanced b-tree of the nodes in the incoming * stream. But, to quote the famous words of Donald E. * Knuth, * * Beware of bugs in the above code; I have only * proved it correct, not tried it. */@end group@end example@findex c-setup-filladapt@findex setup-filladapt (c-)@findex filladapt-mode@vindex filladapt-mode@cindex Filladapt modeIt's also possible to use other adaptive filling packages, notably KyleE. Jones' Filladapt package@footnote{It's available from@uref{http://www.wonderworks.com/}. As of version 2.12, it does howeverlack a feature that makes it work suboptimally when@code{c-comment-prefix-regexp} matches the empty string (which it doesby default). A patch for that is available from@uref{http://cc-mode.sourceforge.net/,, the CC Mode site}.},which handles things like bulleted lists nicely. There's a conveniencefunction @code{c-setup-filladapt} that tunes the relevant variables inFilladapt for use in @ccmode{}. Call it from a mode hook, e.g. withsomething like this in your @file{.emacs}:@example@group(defun my-c-mode-common-hook () (c-setup-filladapt) (filladapt-mode 1))(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)@end group@end example@vindex c-block-comment-prefix@vindex block-comment-prefix (c-)@vindex c-comment-continuation-stars@vindex comment-continuation-stars (c-)Normally the comment line prefix inserted for a new line inside acomment is deduced from other lines in it. However there's onesituation when there's no clue about how the prefix should look, namelywhen a block comment is broken for the first time. The string in thestyle variable @code{c-block-comment-prefix}@footnote{In versions before5.26, this variable was called @code{c-comment-continuation-stars}. Asa compatibility measure, @ccmode{} still uses the value on that variableif it's set.} is used in that case. It defaults to @samp{* }, whichmakes a comment@example/* Got O(n^2) here, which is a Bad Thing. */@end example@noindentbreak into@example@group/* Got O(n^2) here, * which is a Bad Thing. */@end group@end exampleNote that it won't work to justify the indentation by putting leadingspaces in the @code{c-block-comment-prefix} string, since @ccmode{}still uses the normal indentation engine to indent the line. Thus, theright way to fix the indentation is by setting the @code{c} syntacticsymbol. It defaults to @code{c-lineup-C-comments}, which handles theindentation of most common comment styles, see @ref{IndentationFunctions}.@vindex c-ignore-auto-fill@vindex ignore-auto-fill (c-)When auto fill mode is enabled, @ccmode{} can selectively ignore itdepending on the context the line break would occur in, e.g. to neverbreak a line automatically inside a string literal. This behavior canbe controlled with the @code{c-ignore-auto-fill} variable. It takes alist of symbols for the different contexts where auto-filling nevershould occur:@itemize @bullet@item @code{string} --- Inside a string or character literal.@item @code{c} --- Inside a C style block comment.@item @code{c++} --- Inside a C++ style line comment.@item @code{cpp} --- Inside a preprocessor directive.@item @code{code} --- Anywhere else, i.e. in normal code.@end itemizeBy default, @code{c-ignore-auto-fill} is set to @code{'(string cppcode)}, which means that auto-filling only occurs in comments whenauto-fill mode is activated. In literals, it's often desirable to haveexplicit control over newlines. In preprocessor directives, thenecessary @samp{\} escape character before the newline is notautomatically inserted, so an automatic line break would produce invalidcode. In normal code, line breaks are normally dictated by some logicalstructure in the code rather than the last whitespace character, soautomatic line breaks there will produce poor results in the currentimplementation.The commands that does the actual work follows.@table @asis@kindex M-q@findex c-fill-paragraph@findex fill-paragraph (c-)@cindex Javadoc markup@cindex Pike autodoc markup@item @kbd{M-q} (@code{c-fill-paragraph})This is the replacement for @code{fill-paragraph} in @ccmode{}buffers. It's used to fill multiline string literals and both block andline style comments. In Java buffers, the Javadoc markup words arerecognized as paragraph starters. The line oriented Pike autodoc markupwords are recognized in the same way in Pike mode.The function keeps the comment starters and enders of block comments asthey were before the filling. This means that a comment ender on thesame line as the paragraph being filled will be filled with theparagraph, and one on a line by itself will stay as it is. The commentstarter is handled similarly@footnote{This means that the variables@code{c-hanging-comment-starter-p} and @code{c-hanging-comment-ender-p},which controlled this behavior in earlier versions of @ccmode{}, are nowobsolete.}.@kindex M-j@findex c-indent-new-comment-line@findex indent-new-comment-line (c-)@item @kbd{M-j} (@code{c-indent-new-comment-line})This is the replacement for @code{indent-new-comment-line}. It breaksthe line at point and indents the new line like the current one.@vindex comment-multi-lineIf inside a comment and @code{comment-multi-line} is non-@code{nil}, theindentation and line prefix are preserved. If inside a comment and@code{comment-multi-line} is @code{nil}, a new comment of the same typeis started on the next line and indented as appropriate for comments.@findex c-context-line-break@findex context-line-break (c-)@item @kbd{M-x c-context-line-break}This is a function that works like @code{indent-new-comment-line} incomments and @code{newline-and-indent} elsewhere, thus combining thosetwo in a way that uses each one in the context it's best suited for.I.e. in comments the comment line prefix and indentation is kept for thenew line, and in normal code it's indented according to context by theindentation engine.It's not bound to a key by default, but it's intended to be used on the@kbd{RET} key. If you like the behavior of @code{newline-and-indent} on@kbd{RET}, you might consider switching to this function.@end table@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@node Commands, Customizing Indentation, Text Filling and Line Breaking, Top@comment node-name, next, previous, up@chapter Commands@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@menu* Indentation Commands::* Movement Commands::* Other Commands::@end menuSee also @ref{Text Filling and Line Breaking}, for commands concerningthat bit.@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@node Indentation Commands, Movement Commands, , Commands@comment node-name, next, previous,up@section Indentation Commands@cindex indentation commands@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!The following list of commands re-indent C constructs. Note that whenyou change your coding style, either interactively or through some othermeans, your file does @emph{not} automatically get re-indented. Youwill need to execute one of the following commands to see the effects ofyour changes.@cindex GNU indent programAlso, variables like @code{c-hanging-*} and @code{c-cleanup-list}only affect how on-the-fly code is formatted. Changing the``hanginess'' of a brace and then re-indenting, will not move the braceto a different line. For this, you're better off getting an externalprogram like GNU @code{indent}, which will re-arrange brace location,among other things.Re-indenting large sections of code can take a long time. When@ccmode{} reindents a region of code, it is essentially equivalent tohitting @kbd{TAB} on every line of the region. Especially vulnerable iscode generator output@footnote{In particular, I have had peoplecomplain about the speed with which @code{lex(1)} output is re-indented.Lex, yacc, and other code generators usually output some prettyperversely formatted code. Re-indenting such code will be slow.}.These commands are useful when indenting code:@table @asis@kindex TAB@findex c-indent-command@findex indent-command (c-)@item @kbd{TAB} (@code{c-indent-command})Indents the current line. The actual behavior is controlled by severalvariables, described below. See @code{c-tab-always-indent},@code{c-insert-tab-function}, and @code{indent-tabs-mode}. With anumeric argument, this command rigidly indents the region, preservingthe relative indentation among the lines.@kindex C-M-q@findex c-indent-exp@findex indent-exp (c-)@item @kbd{C-M-q} (@code{c-indent-exp})Indent an entire balanced brace or parenthesis expression. Note thatpoint must be on the opening brace or parenthesis of the expression youwant to indent.@kindex C-c C-q@findex c-indent-defun@findex indent-defun (c-)@item @kbd{C-c C-q} (@code{c-indent-defun})Indents the entire top-level function or class definition encompassingpoint. It leaves point unchanged. This function can't be used tore-indent a nested brace construct, such as a nested class or function,or a Java method. The top-level construct being re-indented must becomplete, i.e. it must have both a beginning brace and an ending brace.@kindex C-M-\@findex indent-region@item @kbd{C-M-\} (@code{indent-region})Indents an arbitrary region of code. This is a standard Emacs command,tailored for C code in a @ccmode{} buffer. Note that of course, pointand mark must delineate the region you want to indent.@kindex C-M-h@findex c-mark-function@findex mark-function (c-)@item @kbd{C-M-h} (@code{c-mark-function})While not strictly an indentation command, this is useful for markingthe current top-level function or class definition as the currentregion. As with @code{c-indent-defun}, this command operates ontop-level constructs, and can't be used to mark say, a Java method.@end tableThese variables are also useful when indenting code:@table @code@vindex c-tab-always-indent@vindex tab-always-indent (c-)@kindex TAB@cindex literal@item c-tab-always-indentThis variable controls how @kbd{TAB} @code{c-indent-command} operates.When this variable is @code{t}, @kbd{TAB} always just indents thecurrent line. When it is @code{nil}, the line is indented only if pointis at the left margin, or on or before the first non-whitespacecharacter on the line, otherwise some whitespace is inserted. If thisvariable is the symbol @code{other}, then some whitespace is insertedonly within strings and comments (literals), an inside preprocessordirectives, but the line is always reindented.@vindex c-insert-tab-function@vindex insert-tab-function (c-)@findex tab-to-tab-stop@item c-insert-tab-functionWhen ``some whitespace'' is inserted as described above, what actuallyhappens is that the function stored in @code{c-insert-tab-function} iscalled. Normally, this just inserts a real tab character, or theequivalent number of spaces, depending on @code{indent-tabs-mode}.Some people, however, set @code{c-insert-tab-function} to@code{tab-to-tab-stop} so as to get hard tab stops when indenting.@vindex indent-tabs-mode@item indent-tabs-modeThis is a standard Emacs variable that controls how line indentation iscomposed. When this variable is non-@code{nil}, then tabs can be usedin a line's indentation, otherwise only spaces can be used.@vindex c-progress-interval@vindex progress-interval (c-)@item c-progress-intervalWhen indenting large regions of code, this variable controls how often aprogress message is displayed. Set this variable to @code{nil} toinhibit the progress messages, or set it to an integer which is theinterval in seconds that progress messages are displayed.@end table@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@node Movement Commands, Other Commands, Indentation Commands, Commands@comment node-name, next, previous, up@section Movement Commands@cindex movement commands@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@ccmode{} contains some useful command for moving around in Ccode.@table @asis@findex c-beginning-of-defun@findex beginning-of-defun (c-)@findex beginning-of-defun@item @kbd{M-x c-beginning-of-defun}Moves point back to the least-enclosing brace. This function isanalogous to the Emacs built-in command @code{beginning-of-defun},except it eliminates the constraint that the top-level opening bracemust be in column zero. See @code{beginning-of-defun} for moreinformation.Depending on the coding style being used, you might prefer@code{c-beginning-of-defun} to @code{beginning-of-defun}. If so,consider binding @kbd{C-M-a} to the former instead. For backwardscompatibility reasons, the default binding remains in effect.@findex c-end-of-defun@findex end-of-defun (c-)@findex end-of-defun@item @kbd{M-x c-end-of-defun}Moves point to the end of the current top-level definition. Thisfunction is analogous to the Emacs built-in command @code{end-of-defun},except it eliminates the constraint that the top-level opening brace ofthe defun must be in column zero. See @code{beginning-of-defun} for moreinformation.Depending on the coding style being used, you might prefer@code{c-end-of-defun} to @code{end-of-defun}. If so,consider binding @kbd{C-M-e} to the former instead. For backwardscompatibility reasons, the default binding remains in effect.@kindex C-c C-u@findex c-up-conditional@findex up-conditional (c-)@item @kbd{C-c C-u} (@code{c-up-conditional})Move point back to the containing preprocessor conditional, leaving themark behind. A prefix argument acts as a repeat count. With a negativeargument, move point forward to the end of the containingpreprocessor conditional.@samp{#elif} is treated like @samp{#else} followed by @samp{#if}, so thefunction stops at them when going backward, but not when going forward.@findex c-up-conditional-with-else@findex up-conditional-with-else (c-)@item @kbd{M-x c-up-conditional-with-else}A variety of @code{c-up-conditional} that also stops at @samp{#else}lines. Normally those lines are ignored.@findex c-down-conditional@findex down-conditional (c-)@item @kbd{M-x c-down-conditional}Move point forward into the next nested preprocessor conditional,leaving the mark behind. A prefix argument acts as a repeat count.With a negative argument, move point backward into the previousnested preprocessor conditional.@samp{#elif} is treated like @samp{#else} followed by @samp{#if}, so thefunction stops at them when going forward, but not when going backward.@findex c-down-conditional-with-else@findex down-conditional-with-else (c-)@item @kbd{M-x c-down-conditional-with-else}A variety of @code{c-down-conditional} that also stops at @samp{#else}lines. Normally those lines are ignored.@kindex C-c C-p@findex c-backward-conditional@findex backward-conditional (c-)@item @kbd{C-c C-p} (@code{c-backward-conditional})Move point back over a preprocessor conditional, leaving the markbehind. A prefix argument acts as a repeat count. With a negativeargument, move forward.@kindex C-c C-n@findex c-forward-conditional@findex forward-conditional (c-)@item @kbd{C-c C-n} (@code{c-forward-conditional})Move point forward across a preprocessor conditional, leaving the markbehind. A prefix argument acts as a repeat count. With a negativeargument, move backward.@kindex M-a@findex c-beginning-of-statement@findex beginning-of-statement (c-)@item @kbd{M-a} (@code{c-beginning-of-statement})Move point to the beginning of the innermost C statement. If point isalready at the beginning of a statement, move to the beginning of theclosest preceding statement, even if that means moving into a block (youcan use @kbd{C-M-b} to move over a balanced block). With prefixargument @var{n}, move back @var{n} @minus{} 1 statements.If point is within or next to a comment or a string which spans morethan one line, this command moves by sentences instead of statements.When called from a program, this function takes three optionalarguments: the repetition count, a buffer position limit which is thefarthest back to search for the syntactic context, and a flag sayingwhether to do sentence motion in or near comments and multiline strings.@kindex M-e@findex c-end-of-statement@findex end-of-statement (c-)@item @kbd{M-e} (@code{c-end-of-statement})Move point to the end of the innermost C statement. If point is at theend of a statement, move to the end of the next statement, even if it'sinside a nested block (use @kbd{C-M-f} to move to the other side of theblock). With prefix argument @var{n}, move forward @var{n} @minus{} 1statements.If point is within or next to a comment or a string which spans morethan one line, this command moves by sentences instead of statements.When called from a program, this function takes three optionalarguments: the repetition count, a buffer position limit which is thefarthest back to search for the syntactic context, and a flag sayingwhether to do sentence motion in or near comments and multiline strings.@findex c-forward-into-nomenclature@findex forward-into-nomenclature (c-)@item @kbd{M-x c-forward-into-nomenclature}A popular programming style, especially for object-oriented languagessuch as C++ is to write symbols in a mixed case format, where the firstletter of each word is capitalized, and not separated by underscores.E.g. @samp{SymbolsWithMixedCaseAndNoUnderlines}.This command moves point forward to next capitalized word. With prefixargument @var{n}, move @var{n} times.@findex c-backward-into-nomenclature@findex backward-into-nomenclature (c-)@item @kbd{M-x c-backward-into-nomenclature}Move point backward to beginning of the next capitalizedword. With prefix argument @var{n}, move @var{n} times. If@var{n} is negative, move forward.@end table@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@node Other Commands, , Movement Commands, Commands@comment node-name, next, previous, up@section Other Commands@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@ccmode{} contains a few other useful commands:@table @asis@kindex C-c :@findex c-scope-operator@findex scope-operator (c-)@item @kbd{C-c :} (@code{c-scope-operator})In C++, it is also sometimes desirable to insert the double-colon scopeoperator without performing the electric behavior of colon insertion.@kbd{C-c :} does just this.@kindex C-c C-\@findex c-backslash-region@findex backslash-region (c-)@item @kbd{C-c C-\} (@code{c-backslash-region})This function is handy when editing macros split over several lines byending each line with a backslash. It inserts and aligns, or deletesthese end-of-line backslashes in the current region.@vindex c-backslash-column@vindex backslash-column (c-)With no prefix argument, it inserts any missing backslashes and alignsthem to the column specified by the @code{c-backslash-column} stylevariable. With a prefix argument, it deletes any backslashes.The function does not modify blank lines at the start of the region. Ifthe region ends at the start of a line, it always deletes the backslash(if any) at the end of the previous line.@end table@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@node Customizing Indentation, Syntactic Symbols, Commands, Top@comment node-name, next, previous, up@chapter Customizing Indentation@cindex customizing indentation@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@vindex c-offsets-alist@vindex offsets-alist (c-)The style variable @code{c-offsets-alist} contains the mappings betweensyntactic symbols and the offsets to apply for those symbols. It's setat mode initialization from a @emph{style} you may specify. Styles aregroupings of syntactic symbol offsets and other style variable values.Most likely, you'll find that one of the pre-defined styles will suityour needs. @xref{Styles}, for an explanation of how to set up namedstyles.Only syntactic symbols not already bound on @code{c-offsets-alist} willbe set from styles. This means that any association you set on it, beit before or after mode initialization, will not be changed. The@code{c-offsets-alist} variable may therefore be used from e.g. theCustomization interface@footnote{Available in Emacs 20 and later, andXEmacs 19.15 and later.} to easily change indentation offsets withouthaving to bother about styles. Initially @code{c-offsets-alist} isempty, so that all syntactic symbols are set by the style system.@kindex C-c C-o@findex c-set-offset@findex set-offset (c-)You can use the command @kbd{C-c C-o} (@code{c-set-offset}) as the wayto set offsets, both interactively and from your modehook@footnote{Obviously, you use the key binding interactively, and thefunction call programmatically!}.@vindex c-basic-offset@vindex basic-offset (c-)The offset associated with any particular syntactic symbol can be any ofan integer, a function or lambda expression, a variable name, a vector,a list, or one of the following symbols: @code{+}, @code{-}, @code{++},@code{--}, @code{*}, or @code{/}.Those last special symbols describe an offset in multiples of the valueof the style variable @code{c-basic-offset}. By defining a style'sindentation in terms of this fundamental variable, you can change theamount of whitespace given to an indentation level while maintaining thesame basic shape of your code. Here are the values that the specialsymbols correspond to:@table @code@item +@code{c-basic-offset} times 1@item -@code{c-basic-offset} times -1@item ++@code{c-basic-offset} times 2@item --@code{c-basic-offset} times -2@item *@code{c-basic-offset} times 0.5@item /@code{c-basic-offset} times -0.5@end table@cindex indentation functionsWhen a function is used as offset, it's called an @dfn{indentationfunction}. Such functions are useful when more context than just thesyntactic symbol is needed to get the desired indentation.@xref{Indentation Functions}, and @ref{Custom Indentation Functions},for details about them.If the offset is a vector, its first element sets the absoluteindentation column, which will override any relative indentation.@vindex c-strict-syntax-p@vindex strict-syntax-p (c-)The offset can also be a list, in which case it is evaluated recursivelyusing the semantics described above. The first element of the list thatreturns a non-@code{nil} value succeeds and the evaluation stops. Ifnone of the list elements return a non-@code{nil} value, then an offsetof 0 (zero) is used@footnote{There is however a variable@code{c-strict-syntax-p} that, when set to non-@code{nil}, will cause anerror to be signaled in that case. It's now considered obsolete sinceit doesn't work well with some of the alignment functions that nowreturns @code{nil} instead of zero to be more usable in lists. Youshould therefore leave @code{c-strict-syntax-p} set to @code{nil}.}.So, for example, because most of the default offsets are defined interms of @code{+}, @code{-}, and @code{0}, if you like the generalindentation style, but you use 4 spaces instead of 2 spaces per level,you can probably achieve your style just by changing@code{c-basic-offset} like so@footnote{You can try this interactively ina C buffer by typing the text that appears in italics.}:@example@emph{M-x set-variable RET}Set variable: @emph{c-basic-offset RET}Set c-basic-offset to value: @emph{4 RET}@end example@noindentThis would change@example@groupint add( int val, int incr, int doit )@{ if( doit ) @{ return( val + incr ); @} return( val );@}@end group@end example@noindentto@example@groupint add( int val, int incr, int doit )@{ if( doit ) @{ return( val + incr ); @} return( val );@}@end group@end exampleTo change indentation styles more radically, you will want to change theoffsets associated with other syntactic symbols. First, I'll show youhow to do that interactively, then I'll describe how to make changes toyour @file{.emacs} file so that your changes are more permanent.@menu* Interactive Customization::* Permanent Customization::* Hooks::* Styles::* Advanced Customizations::@end menu@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@node Interactive Customization, Permanent Customization, , Customizing Indentation@comment node-name, next, previous, up@section Interactive Customization@cindex interactive customization@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!As an example of how to customize indentation, let's change thestyle of this example@footnote{In this an subsequent examples, theoriginal code is formatted using the @samp{gnu} style unless otherwiseindicated. @xref{Styles}.}:@example@group1: int add( int val, int incr, int doit )2: @{3: if( doit )4: @{5: return( val + incr );6: @}7: return( val );8: @}@end group@end example@noindentto:@example@group1: int add( int val, int incr, int doit )2: @{3: if( doit )4: @{5: return( val + incr );6: @}7: return( val );8: @}@end group@end exampleIn other words, we want to change the indentation of braces that open ablock following a condition so that the braces line up under theconditional, instead of being indented. Notice that the construct wewant to change starts on line 4. To change the indentation of a line,we need to see which syntactic components affect the offset calculationsfor that line. Hitting @kbd{C-c C-s} on line 4 yields:@example((substatement-open . 44))@end example@noindentso we know that to change the offset of the open brace, we need tochange the indentation for the @code{substatement-open} syntacticsymbol. To do this interactively, just hit @kbd{C-c C-o}. This promptsyou for the syntactic symbol to change, providing a reasonable default.In this case, the default is @code{substatement-open}, which is just thesyntactic symbol we want to change!After you hit return, @ccmode{} will then prompt you for the newoffset value, with the old value as the default. The default in thiscase is @samp{+}, but we want no extra indentation so enter@samp{0} and @kbd{RET}. This will associate the offset 0 with thesyntactic symbol @code{substatement-open}.To check your changes quickly, just hit @kbd{C-c C-q}(@code{c-indent-defun}) to reindent the entire function. The exampleshould now look like:@example@group1: int add( int val, int incr, int doit )2: @{3: if( doit )4: @{5: return( val + incr );6: @}7: return( val );8: @}@end group@end exampleNotice how just changing the open brace offset on line 4 is all weneeded to do. Since the other affected lines are indented relative toline 4, they are automatically indented the way you'd expect. For morecomplicated examples, this may not always work. The general approach totake is to always start adjusting offsets for lines higher up in thefile, then re-indent and see if any following lines need furtheradjustments.@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@node Permanent Customization, Hooks, Interactive Customization, Customizing Indentation@comment node-name, next, previous, up@section Permanent Customization@cindex permanent customization@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!To make your changes permanent, you need to add some lisp code to your@file{.emacs} file. @ccmode{} supports many different ways to beconfigured, from the straightforward way by setting variables globallyin @file{.emacs} or in the Customization interface, to the complex andprecisely controlled way by using styles and hook functions.The simplest way of customizing @ccmode{} permanently is to set thevariables in your @file{.emacs} with @code{setq} and similar commands.So to make the setting of @code{substatement-open} permanent, add thisto the @file{.emacs} file:@example@group(require 'cc-mode)(c-set-offset 'substatement-open 0)@end group@end exampleThe @code{require} line is only needed once in the beginning to makesure @ccmode{} is loaded so that the @code{c-set-offset} function isdefined.You can also use the more user friendly Customization interface, butthis manual does not cover how that works.Variables set like this at the top level in @file{.emacs} take effect inall @ccmode{} buffers, regardless of language. The indentation stylerelated variables, e.g. @code{c-basic-offset}, that you don't set thisway get their value from the style system (@pxref{Styles}), and theytherefore depend on the setting of @code{c-default-style}. Note that ifyou use Customize, this means that the greyed-out default valuespresented there might not be the ones you actually get, since the actualvalues depend on the style, which may very well be different fordifferent languages.If you want to make more advanced configurations, e.g. language-specificcustomization, global variable settings isn't enough. For that you canuse the language hooks, see @ref{Hooks}, and/or the style system, see@ref{Styles}.@vindex c-style-variables-are-local-p@vindex style-variables-are-local-p (c-)By default, all style variables are global, so that every buffer willshare the same style settings. This is fine if you primarily edit onestyle of code, but if you edit several languages and want to usedifferent styles for them, you need finer control by making the stylevariables buffer local. The recommended way to do this is to set thevariable @code{c-style-variables-are-local-p} to @code{t}. Thevariables will be made buffer local when @ccmode{} is activated in abuffer for the first time in the Emacs session. Note that once thestyle variables are made buffer local, they cannot be made global again,without restarting Emacs.@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@node Hooks, Styles, Permanent Customization, Customizing Indentation@comment node-name, next, previous, up@section Hooks@cindex hooks@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@vindex c-mode-common-hook@vindex mode-common-hook (c-)@vindex c-mode-hook@vindex c++-mode-hook@vindex objc-mode-hook@vindex java-mode-hook@vindex idl-mode-hook@vindex pike-mode-hook@vindex c-initialization-hook@vindex initialization-hook (c-)@ccmode{} provides several hooks that you can use to customize the modeaccording to your coding style. Each language mode has its own hook,adhering to standard Emacs major mode conventions. There is also onegeneral hook and one package initialization hook:@itemize @bullet@item@code{c-mode-hook} --- For C buffers only.@item@code{c++-mode-hook} --- For C++ buffers only.@item@code{objc-mode-hook} --- For Objective-C buffers only.@item@code{java-mode-hook} --- For Java buffers only.@item@code{idl-mode-hook} --- For CORBA IDL buffers only.@item@code{pike-mode-hook} --- For Pike buffers only.@item@code{c-mode-common-hook} --- Common across all languages.@item@code{c-initialization-hook} --- Hook run only once per Emacs session,when @ccmode{} is initialized.@end itemizeThe language hooks get run as the last thing when you enter thatlanguage mode. The @code{c-mode-common-hook} is run by all supportedmodes @emph{before} the language specific hook, and thus can containcustomizations that are common across all languages. Most of theexamples in this section will assume you are using the common hook.Note that all the language-specific mode setup that CC Mode does is doneprior to both @code{c-mode-common-hook} and the language specific hook.That includes installing the indentation style, which can be modespecific (and also is by default for Java mode). Thus, any stylesettings done in @code{c-mode-common-hook} will override whateverlanguage-specific style is chosen by @code{c-default-style}.Here's a simplified example of what you can add to your @file{.emacs}file to do things whenever any @ccmode{} language is edited. See theEmacs manuals for more information on customizing Emacs via hooks.@xref{Sample .emacs File}, for a more complete sample @file{.emacs}file.@example@group(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)@end group@end example@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@node Styles, Advanced Customizations, Hooks, Customizing Indentation@comment node-name, next, previous, up@section Styles@cindex styles@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!Most people only need to edit code formatted in just a few well-definedand consistent styles. For example, their organization might impose a``blessed'' style that all its programmers must conform to. Similarly,people who work on GNU software will have to use the GNU coding style.Some shops are more lenient, allowing a variety of coding styles, and asprogrammers come and go, there could be a number of styles in use. Forthis reason, @ccmode{} makes it convenient for you to set up logicalgroupings of customizations called @dfn{styles}, associate a single namefor any particular style, and pretty easily start editing new orexisting code using these styles.@cindex style variablesThe variables that the style system affect are called @dfn{stylevariables}. They are handled specially in several ways:@itemize @bullet@itemStyle variables are by default global variables, i.e. they have the samevalue in all Emacs buffers. However, they can instead be made alwaysbuffer local by setting @code{c-style-variables-are-local-p} tonon-@code{nil} before @ccmode{} is initialized.@vindex c-old-style-variable-behavior@vindex old-style-variable-behavior (c-)@itemThe default value of any style variable (with two exceptions --- seebelow) is the special symbol @code{set-from-style}. Variables that arestill set to that symbol when a @ccmode{} buffer is initialized will beset according to the current style, otherwise they will keep theircurrent value@footnote{This is a big change from versions of @ccmode{}earlier than 5.26, where such settings would get overridden by the stylesystem unless special precautions were taken. That was changed since itwas counterintuitive and confusing, especially to novice users. If yourconfiguration depends on the old overriding behavior, you can set thevariable @code{c-old-style-variable-behavior} to non-@code{nil}.}.Note that when we talk about the ``default value'' for a style variable,we don't mean the @code{set-from-style} symbol that all style variablesare set to initially, but instead the value it will get at modeinitialization when neither a style nor a global setting has set itsvalue.The style variable @code{c-offsets-alist} is handled a littledifferently from the other style variables. It's an association list,and is thus by default set to the empty list, @code{nil}. When thestyle system is initialized, any syntactic symbols already on it arekept --- only the missing ones are filled in from the chosen style.The style variable @code{c-special-indent-hook} is also handled in aspecial way. Styles may only add more functions on this hook, so theglobal settings on it are always preserved@footnote{This did not changein version 5.26.}.@itemThe global settings of style variables get captured in the special@code{user} style, which is used as the base for all the other styles.@xref{Built-in Styles}, for details.@end itemizeThe style variables are:@code{c-basic-offset},@code{c-comment-only-line-offset},@code{c-block-comment-prefix},@code{c-comment-prefix-regexp},@code{c-cleanup-list},@code{c-hanging-braces-alist},@code{c-hanging-colons-alist},@code{c-hanging-semi&comma-criteria},@code{c-backslash-column},@code{c-special-indent-hook},@code{c-label-minimum-indentation}, and@code{c-offsets-alist}.@menu* Built-in Styles::* Adding Styles::* File Styles::@end menu@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@node Built-in Styles, Adding Styles, , Styles@comment node-name, next, previous, up@subsection Built-in Styles@cindex built-in styles@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!If you're lucky, one of @ccmode{}'s built-in styles might be justwhat you're looking for. These include:@itemize @bullet@cindex GNU style@item@code{gnu} --- Coding style blessed by the Free Software Foundationfor C code in GNU programs.@cindex K&R style@item@code{k&r} --- The classic Kernighan and Ritchie style for C code.@cindex BSD style@item@code{bsd} --- Also known as ``Allman style'' after Eric Allman.@cindex Whitesmiths style@item@code{whitesmith} --- Popularized by the examples that came withWhitesmiths C, an early commercial C compiler.@cindex Stroustrup style@item@code{stroustrup} --- The classic Stroustrup style for C++ code.@cindex Ellemtel style@item@code{ellemtel} --- Popular C++ coding standards as defined by``Programming in C++, Rules and Recommendations,'' Erik Nyquist and MatsHenricson, Ellemtel@footnote{This document is available at@uref{http://www.doc.ic.ac.uk/lab/cplus/c++.rules/} among otherplaces.}.@cindex Linux style@item@code{linux} --- C coding standard for Linux (the kernel).@cindex Python style@item@code{python} --- C coding standard for Python extensionmodules@footnote{Python is a high level scripting language with a C/C++foreign function interface. For more information, see@uref{http://www.python.org/}.}.@cindex Java style@findex java-mode@item@code{java} --- The style for editing Java code. Note that the defaultvalue for @code{c-default-style} installs this style when you enter@code{java-mode}.@cindex User style@item@code{user} --- This is a special style for several reasons. First, the@ccmode{} customizations you do by using either the Customizationinterface, or by writing @code{setq}'s at the top level of your@file{.emacs} file, will be captured in the @code{user} style. Also,all other styles implicitly inherit their settings from @code{user}style. This means that for any styles you add via @code{c-add-style}(@pxref{Adding Styles}) you need only define the differences betweenyour new style and @code{user} style.@end itemize@vindex c-default-style@vindex default-style (c-)The default style in all newly created buffers is @code{gnu}, but youcan change this by setting variable @code{c-default-style}. Althoughthe @code{user} style is not the default style, any style variablesettings you do with the Customization interface or on the top level inyour @file{.emacs} file will by default override the style system, soyou don't need to set @code{c-default-style} to @code{user} to see theeffect of these settings.@code{c-default-style} takes either a style name string, or anassociation list of major mode symbols to style names. Thus you cancontrol exactly which default style is used for which @ccmode{} languagemode. Here are the rules:@vindex c-style-alist@vindex style-alist (c-)@vindex c-mode-common-hook@vindex mode-common-hook (c-)@enumerate@itemWhen @code{c-default-style} is a string, it must be an existing stylename as found in @code{c-style-alist}. This style is then used for allmodes.@itemWhen @code{c-default-style} is an association list, the current majormode is looked up to find a style name string. In this case, this styleis always used exactly as specified and an error will occur if the namedstyle does not exist.@itemIf @code{c-default-style} is an association list, but the current majormode isn't found, then the special symbol @samp{other} is looked up. Ifthis value is found, the associated style is used.@itemIf @samp{other} is not found, then the @samp{gnu} style is used.@itemIn all cases, the style described in @code{c-default-style} is installed@emph{before} the language hooks are run, so you can always overridethis setting by including an explicit call to @code{c-set-style} in yourlanguage mode hook, or in @code{c-mode-common-hook}.@end enumerate@findex c-set-style@findex set-style (c-)@kindex C-c .If you'd like to experiment with these built-in styles you can simplytype the following in a @ccmode{} buffer:@example@group@kbd{C-c . @var{STYLE-NAME} RET}@end group@end example@noindent@kbd{C-c .} runs the command @code{c-set-style}. Note that all stylenames are case insensitive, even the ones you define.Setting a style in this way does @emph{not} automatically re-indent yourfile. For commands that you can use to view the effect of your changes,see @ref{Commands}.@vindex c-indentation-style@vindex indentation-style (c-)Note that for BOCM compatibility, @samp{gnu} is the default style, andany non-style based customizations you make (i.e. in@code{c-mode-common-hook} in your @file{.emacs} file) will be based on@samp{gnu} style unless you set @code{c-default-style} or do a@code{c-set-style} as the first thing in your hook. The variable@code{c-indentation-style} always contains the buffer's current stylename, as a string.@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@node Adding Styles, File Styles, Built-in Styles, Styles@comment node-name, next, previous, up@subsection Adding Styles@cindex adding styles@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@vindex c-style-alist@vindex style-alist (c-)@findex c-add-style@findex add-style (c-)If none of the built-in styles is appropriate, you'll probably want toadd a new @dfn{style definition}. Styles are kept in the@code{c-style-alist} variable, but you should never modify this variabledirectly. Instead, @ccmode{} provides the function@code{c-add-style} that you can use to easily add new styles or changeexisting styles. This function takes two arguments, a @var{stylename}string, and an association list @var{description} of stylecustomizations. If @var{stylename} is not already in@code{c-style-alist}, the new style is added, otherwise the style ischanged to the new @var{description}.This function also takes an optional third argument, which ifnon-@code{nil}, automatically applies the new style to the currentbuffer.@comment TBD: The next paragraph is bogus. I really need to better@comment document adding styles, including setting up inherited styles.The sample @file{.emacs} file provides a concrete example of how a newstyle can be added and automatically set. @xref{Sample .emacs File}.@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@node File Styles, , Adding Styles, Styles@comment node-name, next, previous, up@subsection File Styles@cindex file styles@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@cindex local variablesThe Emacs manual describes how you can customize certain variables on aper-file basis by including a @dfn{Local Variable} block at the end ofthe file. So far, you've only seen a functional interface to @ccmode{}customization, which is highly inconvenient for use in a Local Variableblock. @ccmode{} provides two variables that make it easier for you tocustomize your style on a per-file basis.@vindex c-file-style@vindex file-style (c-)@vindex c-file-offsets@vindex file-offsets (c-)The variable @code{c-file-style} can be set to a style name string.When the file is visited, @ccmode{} will automatically set thefile's style to this style using @code{c-set-style}.Another variable, @code{c-file-offsets}, takes an association listsimilar to what is allowed in @code{c-offsets-alist}. When the file isvisited, @ccmode{} will automatically institute these offsets using@code{c-set-offset}.Note that file style settings (i.e. @code{c-file-style}) are appliedbefore file offset settings (i.e. @code{c-file-offsets}). Also, ifeither of these are set in a file's local variable section, all thestyle variable values are made local to that buffer.@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@node Advanced Customizations, , Styles, Customizing Indentation@comment node-name, next, previous, up@section Advanced Customizations@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@vindex c-style-alist@vindex style-alist (c-)For most users, @ccmode{} will support their coding styles withvery little need for more advanced customizations. Usually, one of thestandard styles defined in @code{c-style-alist} will do the trick. Atmost, perhaps one of the syntactic symbol offsets will need to betweaked slightly, or maybe @code{c-basic-offset} will need to bechanged. However, some styles require a more flexible framework forcustomization, and one of the real strengths of @ccmode{} is thatthe syntactic analysis model provides just such a framework. This allowsyou to implement custom indentation calculations for situations nothandled by the mode directly.@menu* Custom Indentation Functions::* Custom Brace and Colon Hanging::* Customizing Semi-colons and Commas::* Other Special Indentations::@end menu@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@node Custom Indentation Functions, Custom Brace and Colon Hanging, , Advanced Customizations@comment node-name, next, previous, up@subsection Custom Indentation Functions@cindex custom indentation functions@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!The most flexible way to customize @ccmode{} is by writing customindentation functions, and associating them with specific syntacticsymbols (@pxref{Syntactic Symbols}). @ccmode{} itself uses indentationfunctions to provide more sophisticated indentation, for example whenlining up C++ stream operator blocks:@example@group1: void main(int argc, char**)2: @{3: cout << "There were "4: << argc5: << "arguments passed to the program"6: << endl;7: @}@end group@end exampleIn this example, lines 4 through 6 are assigned the @code{stream-op}syntactic symbol. Here, @code{stream-op} has an offset of @code{+}, andwith a @code{c-basic-offset} of 2, you can see that lines 4 through 6are simply indented two spaces to the right of line 3. But perhaps we'dlike @ccmode{} to be a little more intelligent so that it alignsall the @samp{<<} symbols in lines 3 through 6. To do this, we haveto write a custom indentation function which finds the column of firststream operator on the first line of the statement. Here is samplelisp code implementing this:@example@group(defun c-lineup-streamop (langelem) ;; lineup stream operators (save-excursion (let* ((relpos (cdr langelem)) (curcol (progn (goto-char relpos) (current-column)))) (re-search-forward "<<\\|>>" (c-point 'eol) 'move) (goto-char (match-beginning 0)) (- (current-column) curcol))))@end group@end example@noindentIndentation functions take a single argument, which is a syntacticcomponent cons cell (@pxref{Syntactic Analysis}). The function returnsan integer offset value that will be added to the running totalindentation for the line. Note that what actually gets returned is thedifference between the column that the first stream operator is on, andthe column of the buffer relative position passed in the function'sargument. Remember that @ccmode{} automatically adds in the column ofthe component's relative buffer position and we don't the column offsetadded in twice.The function should return @code{nil} if it's used in a situation whereit doesn't want to do any decision. If the function is used in a listexpression (@pxref{Customizing Indentation}), that will cause @ccmode{}to go on and check the next entry in the list.@cindex stream-op syntactic symbol@findex c-lineup-streamop@findex lineup-streamop (c-)Now, to associate the function @code{c-lineup-streamop} with the@code{stream-op} syntactic symbol, we can add something like thefollowing to our @code{c++-mode-hook}@footnote{It probably makes moresense to add this to @code{c++-mode-hook} than @code{c-mode-common-hook}since stream operators are only relevant for C++.}:@example(c-set-offset 'stream-op 'c-lineup-streamop)@end exampleNow the function looks like this after re-indenting (using @kbd{C-cC-q}):@example@group1: void main(int argc, char**)2: @{3: cout << "There were "4: << argc5: << " arguments passed to the program"6: << endl;7: @}@end group@end exampleCustom indentation functions can be as simple or as complex as you like,and any syntactic symbol that appears in @code{c-offsets-alist} can havea custom indentation function associated with it.@ccmode{} comes with an extensive set of predefined indentationfunctions, not all of which are used by the default styles. So there'sa good chance the function you want already exists. @xref{IndentationFunctions}, for a list of them. If you have written an indentationfunction that you think is generally useful, you're very welcome tocontribute it; please contact @email{bug-cc-mode@@gnu.org}.@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@node Custom Brace and Colon Hanging, Customizing Semi-colons and Commas, Custom Indentation Functions, Advanced Customizations@comment node-name, next, previous, up@subsection Custom Brace and Colon Hanging@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@vindex c-hanging-braces-alist@vindex hanging-braces-alist (c-)Syntactic symbols aren't the only place where you can customize@ccmode{} with the lisp equivalent of callback functions. Brace``hanginess'' can also be determined by custom functions associated withsyntactic symbols on the @code{c-hanging-braces-alist} style variable.Remember that @var{ACTION}'s are typically a list containing somecombination of the symbols @code{before} and @code{after}(@pxref{Hanging Braces}). However, an @var{ACTION} can also be afunction which gets called when a brace matching that syntactic symbolis entered.@cindex customizing brace hangingThese @var{ACTION} functions are called with two arguments: thesyntactic symbol for the brace, and the buffer position at which thebrace was inserted. The @var{ACTION} function is expected to return alist containing some combination of @code{before} and @code{after},including neither of them (i.e. @code{nil}). This return value has thenormal brace hanging semantics.As an example, @ccmode{} itself uses this feature to dynamicallydetermine the hanginess of braces which close ``do-while''constructs:@example@groupvoid do_list( int count, char** atleast_one_string )@{ int i=0; do @{ handle_string( atleast_one_string[i] ); i++; @} while( i < count );@}@end group@end example@findex c-snug-do-while@findex snug-do-while (c-)@ccmode{} assigns the @code{block-close} syntactic symbol to thebrace that closes the @code{do} construct, and normally we'd like theline that follows a @code{block-close} brace to begin on a separateline. However, with ``do-while'' constructs, we want the@code{while} clause to follow the closing brace. To do this, weassociate the @code{block-close} symbol with the @var{ACTION} function@code{c-snug-do-while}:@example(defun c-snug-do-while (syntax pos) "Dynamically calculate brace hanginess for do-while statements.Using this function, `while' clauses that end a `do-while' block willremain on the same line as the brace that closes that block.See `c-hanging-braces-alist' for how to utilize this function as anACTION associated with `block-close' syntax." (save-excursion (let (langelem) (if (and (eq syntax 'block-close) (setq langelem (assq 'block-close c-syntactic-context)) (progn (goto-char (cdr langelem)) (if (= (following-char) ?@{) (forward-sexp -1)) (looking-at "\\<do\\>[^_]"))) '(before) '(before after)))))@end exampleThis function simply looks to see if the brace closes a ``do-while''clause and if so, returns the list @samp{(before)} indicatingthat a newline should be inserted before the brace, but not after it.In all other cases, it returns the list @samp{(before after)} sothat the brace appears on a line by itself.@vindex c-syntactic-context@vindex syntactic-context (c-)During the call to the brace hanging @var{ACTION} function, the variable@code{c-syntactic-context} is bound to the full syntactic analysis list.@cindex customizing colon hanging@vindex c-hanging-colon-alist@vindex hanging-colon-alist (c-)Note that for symmetry, colon hanginess should be customizable byallowing function symbols as @var{ACTION}s on the@code{c-hanging-colon-alist} style variable. Since no use has actuallybeen found for this feature, it isn't currently implemented!@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@node Customizing Semi-colons and Commas, Other Special Indentations, Custom Brace and Colon Hanging, Advanced Customizations@comment node-name, next, previous, up@subsection Customizing Semi-colons and Commas@cindex customizing semi-colons and commas@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@vindex c-hanging-semi&comma-criteria@vindex hanging-semi&comma-criteria (c-)You can also customize the insertion of newlines after semi-colons andcommas, when the auto-newline minor mode is enabled (@pxref{MinorModes}). This is controlled by the style variable@code{c-hanging-semi&comma-criteria}, which contains a list of functionsthat are called in the order they appear. Each function is called withzero arguments, and is expected to return one of the following values:@itemize @bullet@itemnon-@code{nil} --- A newline is inserted, and no more functions from thelist are called.@item@code{stop} --- No more functions from the list are called, but nonewline is inserted.@item@code{nil} --- No determination is made, and the next function in thelist is called.@end itemizeIf every function in the list is called without a determination beingmade, then no newline is added. The default value for this variable is alist containing a single function which inserts newlines only aftersemi-colons which do not appear inside parenthesis lists (i.e. thosethat separate @code{for}-clause statements).@findex c-semi&comma-no-newlines-before-nonblanks@findex semi&comma-no-newlines-before-nonblanks (c-)Here's an example of a criteria function, provided by @ccmode{}, thatwill prevent newlines from being inserted after semicolons when there isa non-blank following line. Otherwise, it makes no determination. Touse, add this to the front of the @code{c-hanging-semi&comma-criteria}list.@example@group(defun c-semi&comma-no-newlines-before-nonblanks () (save-excursion (if (and (eq last-command-char ?\;) (zerop (forward-line 1)) (not (looking-at "^[ \t]*$"))) 'stop nil)))@end group@end example@findex c-semi&comma-inside-parenlist@findex c-semi&comma-no-newlines-for-oneline-inliners@findex semi&comma-inside-parenlist (c-)@findex semi&comma-no-newlines-for-oneline-inliners (c-)The function @code{c-semi&comma-inside-parenlist} is what preventsnewlines from being inserted inside the parenthesis list of @code{for}statements. In addition to@code{c-semi&comma-no-newlines-before-nonblanks} described above,@ccmode{} also comes with the criteria function@code{c-semi&comma-no-newlines-for-oneline-inliners}, which suppressesnewlines after semicolons inside one-line inline method definitions(i.e. in C++ or Java).@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@node Other Special Indentations, , Customizing Semi-colons and Commas, Advanced Customizations@comment node-name, next, previous, up@subsection Other Special Indentations@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@vindex c-label-minimum-indentation@vindex label-minimum-indentation (c-)In @samp{gnu} style (@pxref{Built-in Styles}), a minimum indentationis imposed on lines inside top-level constructs. This minimumindentation is controlled by the style variable@code{c-label-minimum-indentation}. The default value for this variableis 1.@vindex c-special-indent-hook@vindex special-indent-hook (c-)One other customization variable is available in @ccmode{}: The stylevariable @code{c-special-indent-hook}. This is a standard hook variablethat is called after every line is indented by @ccmode{}. You can useit to do any special indentation or line adjustments your styledictates, such as adding extra indentation to constructors or destructordeclarations in a class definition, etc. Note however, that you shouldnot change point or mark inside your @code{c-special-indent-hook}functions (i.e. you'll probably want to wrap your function in a@code{save-excursion}).Setting @code{c-special-indent-hook} in your style definition is handledslightly differently than other variables. In your style definition,you should set the value for@code{c-special-indent-hook} to a function or list of functions, whichwill be appended to @code{c-special-indent-hook} using @code{add-hook}.That way, the current setting for the buffer local value of@code{c-special-indent-hook} won't be overridden.@kindex M-;@findex indent-for-comment@vindex c-indent-comments-syntactically-p@vindex indent-comments-syntactically-p (c-)@vindex comment-columnNormally, the standard Emacs command @kbd{M-;}(@code{indent-for-comment}) will indent comment only lines to@code{comment-column}. Some users however, prefer that @kbd{M-;} actjust like @kbd{TAB} for purposes of indenting comment-only lines;i.e. they want the comments to always indent as they would for normalcode, regardless of whether @kbd{TAB} or @kbd{M-;} were used. Thisbehavior is controlled by the variable@code{c-indent-comments-syntactically-p}. When @code{nil} (thedefault), @kbd{M-;} indents comment-only lines to @code{comment-column},otherwise, they are indented just as they would be if @kbd{TAB} weretyped.Note that this has no effect for comment lines that are inserted with@kbd{M-;} at the end of regular code lines. These comments will alwaysstart at @code{comment-column}.@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@node Syntactic Symbols, Indentation Functions, Customizing Indentation, Top@comment node-name, next, previous, up@chapter Syntactic Symbols@cindex syntactic symbols@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@vindex c-offsets-alist@vindex offsets-alist (c-)Here is a complete list of the recognized syntactic symbols as describedin the @code{c-offsets-alist} style variable, along with a briefdescription. More detailed descriptions follow.@table @code@item stringInside a multi-line string.@item cInside a multi-line C style block comment.@item defun-openBrace that opens a top-level function definition.@item defun-closeBrace that closes a top-level function definition.@item defun-block-introThe first line in a top-level defun.@item class-openBrace that opens a class definition.@item class-closeBrace that closes a class definition.@item inline-openBrace that opens an in-class inline method.@item inline-closeBrace that closes an in-class inline method.@item func-decl-contThe region between a function definition's argument list and thefunction opening brace (excluding K&R argument declarations). In C, youcannot put anything but whitespace and comments in this region, howeverin C++ and Java, @code{throws} declarations and other things can appearhere.@item knr-argdecl-introFirst line of a K&R C argument declaration.@item knr-argdeclSubsequent lines in a K&R C argument declaration.@item topmost-introThe first line in a ``topmost'' definition.@item topmost-intro-contTopmost definition continuation lines.@item member-init-introFirst line in a member initialization list.@item member-init-contSubsequent member initialization list lines.@item inher-introFirst line of a multiple inheritance list.@item inher-contSubsequent multiple inheritance lines.@item block-openStatement block open brace.@item block-closeStatement block close brace.@item brace-list-openOpen brace of an enum or static array list.@item brace-list-closeClose brace of an enum or static array list.@item brace-list-introFirst line in an enum or static array list.@item brace-list-entrySubsequent lines in an enum or static array list.@item brace-entry-openSubsequent lines in an enum or static array list where the line beginswith an open brace.@item statementA statement.@item statement-contA continuation of a statement.@item statement-block-introThe first line in a new statement block.@item statement-case-introThe first line in a case block.@item statement-case-openThe first line in a case block that starts with a brace.@item substatementThe first line after a conditional or loop construct.@item substatement-openThe brace that opens a substatement block.@item case-labelA @code{case} or @code{default} label.@item access-labelC++ access control label.@item labelAny non-special C label.@item do-while-closureThe @code{while} line that ends a @code{do}-@code{while} construct.@item else-clauseThe @code{else} line of an @code{if}-@code{else} construct.@item catch-clauseThe @code{catch} or @code{finally} (in Java) line of a@code{try}-@code{catch} construct.@item comment-introA line containing only a comment introduction.@item arglist-introThe first line in an argument list.@item arglist-contSubsequent argument list lines when no arguments follow on the same lineas the arglist opening paren.@item arglist-cont-nonemptySubsequent argument list lines when at least one argument follows on thesame line as the arglist opening paren.@item arglist-closeThe solo close paren of an argument list.@item stream-opLines continuing a stream operator (C++ only).@item inclassThe line is nested inside a class definition.@item cpp-macroThe start of a C preprocessor macro definition.@item cpp-macro-contSubsequent lines of a multi-line C preprocessor macro definition.@item friendA C++ friend declaration.@item objc-method-introThe first line of an Objective-C method. definition.@item objc-method-args-contLines continuing an Objective-C method. definition@item objc-method-call-contLines continuing an Objective-C method call.@item extern-lang-openBrace that opens an external language block.@item extern-lang-closeBrace that closes an external language block.@item inextern-langAnalogous to @code{inclass} syntactic symbol, but used inside externallanguage blocks (e.g. @code{extern "C" @{}).@item namespace-openBrace that opens a C++ namespace block.@item namespace-closeBrace that closes a C++ namespace block.@item innamespaceAnalogous to @code{inextern-lang} syntactic symbol, but used inside C++namespace blocks.@item template-args-contC++ template argument list continuations.@item inlambdaAnalogous to @code{inclass} syntactic symbol, but used inside lambda(i.e. anonymous) functions. Only used in Pike mode.@item lambda-intro-contLines continuing the header of a lambda function, i.e. between the@code{lambda} keyword and the function body. Only used in Pike mode.@item inexpr-statementA statement block inside an expression. The gcc C extension of this isrecognized. It's also used for the special functions that takes astatement block as an argument in Pike.@item inexpr-classA class definition inside an expression. This is used for anonymousclasses in Java. It's also used for anonymous array initializers inJava.@end table@cindex -open syntactic symbols@cindex -close syntactic symbolsMost syntactic symbol names follow a general naming convention. When aline begins with an open or close brace, the syntactic symbol willcontain the suffix @code{-open} or @code{-close} respectively.@cindex -intro syntactic symbols@cindex -cont syntactic symbols@cindex -block-intro syntactic symbolsUsually, a distinction is made between the first line that introduces aconstruct and lines that continue a construct, and the syntactic symbolsthat represent these lines will contain the suffix @code{-intro} or@code{-cont} respectively. As a sub-classification of this scheme, aline which is the first of a particular brace block construct willcontain the suffix @code{-block-intro}.Let's look at some examples to understand how this works. Remember thatyou can check the syntax of any line by using @kbd{C-c C-s}.@example@group 1: void 2: swap( int& a, int& b ) 3: @{ 4: int tmp = a; 5: a = b; 6: b = tmp; 7: int ignored = 8: a + b; 9: @}@end group@end example@cindex topmost-intro syntactic symbol@cindex topmost-intro-cont syntactic symbol@cindex defun-open syntactic symbol@cindex defun-close syntactic symbol@cindex defun-block-intro syntactic symbolLine 1 shows a @code{topmost-intro} since it is the first line thatintroduces a top-level construct. Line 2 is a continuation of thetop-level construct introduction so it has the syntax@code{topmost-intro-cont}. Line 3 shows a @code{defun-open} since it isthe brace that opens a top-level function definition. Line 9 is thecorresponding@code{defun-close} since it contains the brace that closes the top-levelfunction definition. Line 4 is a @code{defun-block-intro}, i.e. it isthe first line of a brace-block, enclosed in atop-level function definition.@cindex statement syntactic symbol@cindex statement-cont syntactic symbolLines 5, 6, and 7 are all given @code{statement} syntax since thereisn't much special about them. Note however that line 8 is given@code{statement-cont} syntax since it continues the statement begunon the previous line.Here's another example, which illustrates some C++ class syntacticsymbols:@example@group 1: class Bass 2: : public Guitar, 3: public Amplifiable 4: @{ 5: public: 6: Bass() 7: : eString( new BassString( 0.105 )), 8: aString( new BassString( 0.085 )), 9: dString( new BassString( 0.065 )), 10: gString( new BassString( 0.045 )) 11: @{ 12: eString.tune( 'E' ); 13: aString.tune( 'A' ); 14: dString.tune( 'D' ); 15: gString.tune( 'G' ); 16: @} 17: friend class Luthier; 18: @}@end group@end example@cindex class-open syntactic symbol@cindex class-close syntactic symbolAs in the previous example, line 1 has the @code{topmost-intro} syntax.Here however, the brace that opens a C++ class definition on line 4 isassigned the @code{class-open} syntax. Note that in C++, classes,structs, and unions are essentially equivalent syntactically (and arevery similar semantically), so replacing the @code{class} keyword in theexample above with @code{struct} or @code{union} would still result in asyntax of @code{class-open} for line 4 @footnote{This is the case evenfor C and Objective-C. For consistency, structs in all supportedlanguages are syntactically equivalent to classes. Note however thatthe keyword @code{class} is meaningless in C and Objective-C.}.Similarly, line 18 is assigned @code{class-close} syntax.@cindex inher-intro syntactic symbol@cindex inher-cont syntactic symbolLine 2 introduces the inheritance list for the class so it is assignedthe @code{inher-intro} syntax, and line 3, which continues theinheritance list is given @code{inher-cont} syntax.@cindex access-label syntactic symbol@cindex inclass syntactic symbolHitting @kbd{C-c C-s} on line 5 shows the following analysis:@example@group@code{((inclass . 58) (access-label . 67))}@end group@end example@noindentThe primary syntactic symbol for this line is @code{access-label} asthis a label keyword that specifies access protection in C++. However,because this line is also a top-level construct inside a classdefinition, the analysis actually shows two syntactic symbols. Theother syntactic symbol assigned to this line is @code{inclass}.Similarly, line 6 is given both @code{inclass} and @code{topmost-intro}syntax:@example@group@code{((inclass . 58) (topmost-intro . 60))}@end group@end example@cindex member-init-intro syntactic symbol@cindex member-init-cont syntactic symbolLine 7 introduces a C++ member initialization list and as such is given@code{member-init-intro} syntax. Note that in this case it is@emph{not} assigned @code{inclass} since this is not considered atop-level construct. Lines 8 through 10 are all assigned@code{member-init-cont} since they continue the member initializationlist started on line 7.@cindex in-class inline methods@cindex inline-open syntactic symbol@cindex inline-close syntactic symbolLine 11's analysis is a bit more complicated:@example@group@code{((inclass . 58) (inline-open))}@end group@end exampleThis line is assigned a syntax of both @code{inline-open} and@code{inclass} because it opens an @dfn{in-class} C++ inline methoddefinition. This is distinct from, but related to, the C++ notion of aninline function in that its definition occurs inside an enclosing classdefinition, which in C++ implies that the function should be inlined.If though, the definition of the @code{Bass} constructor appearedoutside the class definition, the construct would be given the@code{defun-open} syntax, even if the keyword @code{inline} appearedbefore the method name, as in:@example@groupclass Bass : public Guitar, public Amplifiable@{public: Bass();@}inlineBass::Bass() : eString( new BassString( 0.105 )), aString( new BassString( 0.085 )), dString( new BassString( 0.065 )), gString( new BassString( 0.045 ))@{ eString.tune( 'E' ); aString.tune( 'A' ); dString.tune( 'D' ); gString.tune( 'G' );@}@end group@end example@cindex friend syntactic symbolReturning to the previous example, line 16 is given @code{inline-close}syntax, while line 12 is given @code{defun-block-open} syntax, and lines13 through 15 are all given @code{statement} syntax. Line 17 isinteresting in that its syntactic analysis list contains threeelements:@example@code{((friend) (inclass . 58) (topmost-intro . 380))}@end exampleThe @code{friend} syntactic symbol is a modifier that typically does nothave a relative buffer position.Template definitions introduce yet another syntactic symbol:@example@group 1: ThingManager <int, 2: Framework::Callback *, 3: Mutex> framework_callbacks;@end group@end exampleHere, line 1 is analyzed as a @code{topmost-intro}, but lines 2 and 3are both analyzed as @code{template-args-cont} lines.Here is another (totally contrived) example which illustrates how syntaxis assigned to various conditional constructs:@example@group 1: void spam( int index ) 2: @{ 3: for( int i=0; i<index; i++ ) 4: @{ 5: if( i == 10 ) 6: @{ 7: do_something_special(); 8: @} 9: else 10: do_something( i ); 11: @} 12: do @{ 13: another_thing( i-- ); 14: @} 15: while( i > 0 ); 16: @}@end group@end example@noindentOnly the lines that illustrate new syntactic symbols will be discussed.@cindex substatement-open syntactic symbol@cindex substatement-block-intro syntactic symbol@cindex block-close syntactic symbolLine 4 has a brace which opens a conditional's substatement block. Itis thus assigned @code{substatement-open} syntax, and since line 5 isthe first line in the substatement block, it is assigned@code{substatement-block-intro} syntax. Lines 6 and 7 are assignedsimilar syntax. Line 8 contains the brace that closes the innersubstatement block. It is given the syntax @code{block-close},as are lines 11 and 14.@cindex else-clause syntactic symbol@cindex catch-clause syntactic symbolLine 9 is a little different --- since it contains the keyword@code{else} matching the @code{if} statement introduced on line 5, it isgiven the @code{else-clause} syntax. The @code{try}-@code{catch}constructs in C++ and Java are treated this way too, with the onlydifference that the @code{catch}, and in Java also @code{finally}, ismarked with @code{catch-clause}.@cindex substatement syntactic symbolLine 10 is also slightly different. Because @code{else} is considered aconditional introducing keyword @footnote{The list of conditionalkeywords are (in C, C++, Objective-C, Java, and Pike): @code{for},@code{if}, @code{do}, @code{else}, @code{while}, and @code{switch}. C++and Java have two additional conditional keywords: @code{try} and@code{catch}. Java also has the @code{finally} and @code{synchronized}keywords.}, and because the following substatement is not a brace block,line 10 is assigned the @code{substatement} syntax.@cindex do-while-closure syntactic symbolOne other difference is seen on line 15. The @code{while} constructthat closes a @code{do} conditional is given the special syntax@code{do-while-closure} if it appears on a line by itself. Note that ifthe @code{while} appeared on the same line as the preceding close brace,that line would have been assigned @code{block-close} syntax instead.Switch statements have their own set of syntactic symbols. Here's anexample:@example@group 1: void spam( enum Ingredient i ) 2: @{ 3: switch( i ) @{ 4: case Ham: 5: be_a_pig(); 6: break; 7: case Salt: 8: drink_some_water(); 9: break; 10: default: 11: @{ 12: what_is_it(); 13: break; 14: @} 15: @} 14: @}@end group@end example@cindex case-label syntactic symbol@cindex statement-case-intro syntactic symbol@cindex statement-case-open syntactic symbolHere, lines 4, 7, and 10 are all assigned @code{case-label} syntax,while lines 5 and 8 are assigned @code{statement-case-intro}. Line 11is treated slightly differently since it contains a brace that opens ablock --- it is given @code{statement-case-open} syntax.@cindex brace listsThere are a set of syntactic symbols that are used to recognizeconstructs inside of brace lists. A brace list is defined as an@code{enum} or aggregate initializer list, such as might staticallyinitialize an array of structs. The three special aggregate constructsin Pike, @code{(@{ @})}, @code{([ ])} and @code{(< >)}, are treated asbrace lists too. An example:@example@group 1: static char* ingredients[] = 2: @{ 3: "Ham", 4: "Salt", 5: NULL 6: @}@end group@end example@cindex brace-list-open syntactic symbol@cindex brace-list-intro syntactic symbol@cindex brace-list-close syntactic symbol@cindex brace-list-entry syntactic symbolFollowing convention, line 2 in this example is assigned@code{brace-list-open} syntax, and line 3 is assigned@code{brace-list-intro} syntax. Likewise, line 6 is assigned@code{brace-list-close} syntax. Lines 4 and 5 however, are assigned@code{brace-list-entry} syntax, as would all subsequent lines in thisinitializer list.@cindex brace-entry-open syntactic symbolYour static initializer might be initializing nested structures, forexample:@example@group 1: struct intpairs[] = 2: @{ 3: @{ 1, 2 @}, 4: @{ 5: 3, 6: 4 7: @} 8: @{ 1, 9: 2 @}, 10: @{ 3, 4 @} 11: @}@end group@end exampleHere, you've already seen the analysis of lines 1, 2, 3, and 11. Online 4, things get interesting; this line is assigned@code{brace-entry-open} syntactic symbol because it's a bracelist entryline that starts with an open brace. Lines 5 and 6 (and line 9) arepretty standard, and line 7 is a @code{brace-list-close} as you'dexpect. Once again, line 8 is assigned as @code{brace-entry-open} as isline 10.External language definition blocks also have their own syntacticsymbols. In this example:@example@group 1: extern "C" 2: @{ 3: int thing_one( int ); 4: int thing_two( double ); 5: @}@end group@end example@cindex extern-lang-open syntactic symbol@cindex extern-lang-close syntactic symbol@cindex inextern-lang syntactic symbol@cindex inclass syntactic symbol@noindentline 2 is given the @code{extern-lang-open} syntax, while line 5 is giventhe @code{extern-lang-close} syntax. The analysis for line 3 yields:@code{((inextern-lang) (topmost-intro . 14))}, where@code{inextern-lang} is a modifier similar in purpose to @code{inclass}.Similarly, C++ namespace constructs have their own associated syntacticsymbols. In this example:@example@group 1: namespace foo 2: @{ 3: void xxx() @{@} 4: @}@end group@end example@cindex namespace-open syntactic symbol@cindex namespace-close syntactic symbol@cindex innamespace syntactic symbol@noindentline 2 is given the @code{namespace-open} syntax, while line 4 is giventhe @code{namespace-close} syntax. The analysis for line 3 yields:@code{((innamespace) (topmost-intro . 17))}, where @code{innamespace} isa modifier similar in purpose to @code{inextern-lang} and @code{inclass}.A number of syntactic symbols are associated with parenthesis lists,a.k.a argument lists, as found in function declarations and functioncalls. This example illustrates these:@example@group 1: void a_function( int line1, 2: int line2 ); 3: 4: void a_longer_function( 5: int line1, 6: int line2 7: ); 8: 9: void call_them( int line1, int line2 ) 10: @{ 11: a_function( 12: line1, 13: line2 14: ); 15: 16: a_longer_function( line1, 17: line2 ); 18: @}@end group@end example@cindex arglist-intro syntactic symbol@cindex arglist-close syntactic symbolLines 5 and 12 are assigned @code{arglist-intro} syntax since they arethe first line following the open parenthesis, and lines 7 and 14 areassigned @code{arglist-close} syntax since they contain the parenthesisthat closes the argument list.@cindex arglist-cont-nonempty syntactic symbol@cindex arglist-cont syntactic symbolLines that continue argument lists can be assigned one of two syntacticsymbols. For example, Lines 2 and 17are assigned @code{arglist-cont-nonempty} syntax. What this meansis that they continue an argument list, but that the line containing theparenthesis that opens the list is @emph{not empty} following the openparenthesis. Contrast this against lines 6 and 13 which are assigned@code{arglist-cont} syntax. This is because the parenthesis that openstheir argument lists is the last character on that line.Note that there is no @code{arglist-open} syntax. This is because anyparenthesis that opens an argument list, appearing on a separate line,is assigned the @code{statement-cont} syntax instead.A few miscellaneous syntactic symbols that haven't been previouslycovered are illustrated by this C++ example:@example@group 1: void Bass::play( int volume ) 2: const 3: @{ 4: /* this line starts a multi-line 5: * comment. This line should get `c' syntax */ 6: 7: char* a_multiline_string = "This line starts a multi-line \ 8: string. This line should get `string' syntax."; 9: 10: note: 11: @{ 12: #ifdef LOCK 13: Lock acquire(); 14: #endif // LOCK 15: slap_pop(); 16: cout << "I played " 17: << "a note\n"; 18: @} 19: @}@end group@end exampleThe lines to note in this example include:@itemize @bullet@cindex func-decl-cont syntactic symbol@itemLine 2 is assigned the @code{func-decl-cont} syntax.@cindex comment-intro syntactic symbol@itemLine 4 is assigned both @code{defun-block-intro} @emph{and}@code{comment-intro} syntax.@cindex c syntactic symbol@itemLine 5 is assigned @code{c} syntax.@item@cindex syntactic whitespaceLine 6 which, even though it contains nothing but whitespace, isassigned @code{defun-block-intro}. Note that the appearance of thecomment on lines 4 and 5 do not cause line 6 to be assigned@code{statement} syntax because comments are considered to be@dfn{syntactic whitespace}, which are ignored when analyzingcode.@cindex string syntactic symbol@itemLine 8 is assigned @code{string} syntax.@cindex label syntactic symbol@itemLine 10 is assigned @code{label} syntax.@cindex block-open syntactic symbol@itemLine 11 is assigned @code{block-open} syntax.@cindex cpp-macro syntactic symbol@cindex cpp-macro-cont syntactic symbol@itemLines 12 and 14 are assigned @code{cpp-macro} syntax in addition to thenormal syntactic symbols (@code{statement-block-intro} and@code{statement}, respectively). Normally @code{cpp-macro} isconfigured to cancel out the normal syntactic context to make allpreprocessor directives stick to the first column, but that's easilychanged if you want preprocessor directives to be indented like the restof the code.@cindex stream-op syntactic symbol@itemLine 17 is assigned @code{stream-op} syntax.@end itemize@cindex multi-line macros@cindex syntactic whitespaceMulti-line C preprocessor macros are now (somewhat) supported. At least@ccmode{} now recognizes the fact that it is inside a multi-line macro,and it properly skips such macros as syntactic whitespace. In thisexample:@example@group 1: #define LIST_LOOP(cons, listp) \ 2: for (cons = listp; !NILP (cons); cons = XCDR (cons)) \ 3: if (!CONSP (cons)) \ 4: signal_error ("Invalid list format", listp); \ 5: else@end group@end example@noindentline 1 is given the syntactic symbol @code{cpp-macro}. This first lineof a macro is always given this symbol. The second and subsequent lines(e.g. lines 2 through 5) are given the @code{cpp-macro-cont} syntacticsymbol, with a relative buffer position pointing to the @code{#} whichstarts the macro definition.In Objective-C buffers, there are three additional syntactic symbolsassigned to various message calling constructs. Here's an exampleillustrating these:@example@group 1: - (void)setDelegate:anObject 2: withStuff:stuff 3: @{ 4: [delegate masterWillRebind:self 5: toDelegate:anObject 6: withExtraStuff:stuff]; 7: @}@end group@end example@cindex objc-method-intro syntactic symbol@cindex objc-method-args-cont syntactic symbol@cindex objc-method-call-cont syntactic symbolHere, line 1 is assigned @code{objc-method-intro} syntax, and line 2 isassigned @code{objc-method-args-cont} syntax. Lines 5 and 6 are bothassigned @code{objc-method-call-cont} syntax.Java has a concept of anonymous classes, which may look something likethis:@example@group 1: public void watch(Observable o) @{ 2: o.addObserver(new Observer() @{ 3: public void update(Observable o, Object arg) @{ 4: history.addElement(arg); 5: @} 6: @}); 7: @}@end group@end example@cindex inexpr-class syntactic symbolThe brace following the @code{new} operator opens the anonymous class.Lines 3 and 6 are assigned the @code{inexpr-class} syntax, besides the@code{inclass} symbol used in normal classes. Thus, the class will beindented just like a normal class, with the added indentation given to@code{inexpr-class}.There are a few occasions where a statement block may be used inside anexpression. One is in C code using the gcc extension for this, e.g:@example@group 1: int res = (@{ 2: int y = foo (); int z; 3: if (y > 0) z = y; else z = - y; 4: z; 5: @});@end group@end example@cindex inexpr-statement syntactic symbolLines 2 and 5 get the @code{inexpr-statement} syntax, besides thesymbols they'd get in a normal block. Therefore, the indentation put on@code{inexpr-statement} is added to the normal statement blockindentation.In Pike code, there are a few other situations where blocks occur insidestatements, as illustrated here:@example@group 1: array itgob() 2: @{ 3: string s = map (backtrace()[-2][3..], 4: lambda 5: (mixed arg) 6: @{ 7: return sprintf ("%t", arg); 8: @}) * ", " + "\n"; 9: return catch @{ 10: write (s + "\n"); 11: @}; 12: @}@end group@end example@cindex inlambda syntactic symbol@cindex lambda-intro-cont syntactic symbolLines 4 through 8 contain a lambda function, which @ccmode{} recognizesby the @code{lambda} keyword. If the function argument list is puton a line of its own, as in line 5, it gets the @code{lambda-intro-cont}syntax. The function body is handled as an inline method body, with theaddition of the @code{inlambda} syntactic symbol. This means that line6 gets @code{inlambda} and @code{inline-open}, and line 8 gets@code{inline-close}@footnote{You might wonder why it doesn't get@code{inlambda} too. It's because the closing brace is relative to theopening brace, which stands on its own line in this example. If theopening brace was hanging on the previous line, then the closing bracewould get the @code{inlambda} syntax too to be indented correctly.}.@cindex inexpr-statement syntactic symbolOn line 9, @code{catch} is a special function taking a statement blockas its argument. The block is handled as an in-expression statementwith the @code{inexpr-statement} syntax, just like the gcc extended Cexample above. The other similar special function, @code{gauge}, ishandled like this too.@cindex knr-argdecl-intro syntactic symbol@cindex knr-argdecl syntactic symbolTwo other syntactic symbols can appear in old style, non-prototyped Ccode @footnote{a.k.a. K&R C, or Kernighan & Ritchie C}:@example@group 1: int add_three_integers(a, b, c) 2: int a; 3: int b; 4: int c; 5: @{ 6: return a + b + c; 7: @}@end group@end exampleHere, line 2 is the first line in an argument declaration list and so isgiven the @code{knr-argdecl-intro} syntactic symbol. Subsequent lines(i.e. lines 3 and 4 in this example), are given @code{knr-argdecl}syntax.@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@node Indentation Functions, Performance Issues, Syntactic Symbols, Top@comment node-name, next, previous, up@chapter Indentation Functions@cindex indentation functions@cindex line-up functions@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!Often there are cases when a simple offset setting on a syntactic symbolisn't enough to get the desired indentation. Therefore, it's alsopossible to use a @dfn{indentation function} (a.k.a. line-up function)for a syntactic symbol.@ccmode{} comes with many predefined indentation functions for commonsituations. If none of these does what you want, you can write yourown, see @ref{Custom Indentation Functions}. If you do, it's probably agood idea to start working from one of these predefined functions, theycan be found in the file @file{cc-align.el}.For every function below there is a ``works with'' list that indicateswhich syntactic symbols the function is intended to be used with.@macro workswith@emph{Works with:@ }@end macro@ifinfo@unmacro workswith@macro workswithWorks with:@end macro@end ifinfo@table @code@findex c-lineup-arglist@findex lineup-arglist (c-)@item c-lineup-arglistLine up the current argument line under the first argument.@workswith @code{arglist-cont-nonempty}.@findex c-lineup-arglist-intro-after-paren@findex lineup-arglist-intro-after-paren (c-)@item c-lineup-arglist-intro-after-parenLine up a line just after the open paren of the surrounding paren orbrace block.@workswith @code{defun-block-intro}, @code{brace-list-intro},@code{statement-block-intro}, @code{statement-case-intro},@code{arglist-intro}.@findex c-lineup-arglist-close-under-paren@findex lineup-arglist-close-under-paren (c-)@item c-lineup-arglist-close-under-parenSet e.g. your @code{arglist-close} syntactic symbol to this line-upfunction so that parentheses that close argument lists will line upunder the parenthesis that opened the argument list.@workswith @code{defun-close}, @code{class-close}, @code{inline-close},@code{block-close}, @code{brace-list-close}, @code{arglist-close},@code{extern-lang-close}, @code{namespace-close} (for most of these, azero offset will normally produce the same result, though).@findex c-lineup-close-paren@findex lineup-close-paren (c-)@item c-lineup-close-parenLine up the closing paren under its corresponding open paren if theopen paren is followed by code. If the open paren ends its line, noindentation is added. E.g:@example@groupmain (int, char ** ) // c-lineup-close-paren@end group@end example@noindentand@example@groupmain ( int, char **) // c-lineup-close-paren@end group@end example@workswith @code{defun-close}, @code{class-close}, @code{inline-close},@code{block-close}, @code{brace-list-close}, @code{arglist-close},@code{extern-lang-close}, @code{namespace-close}.@findex c-lineup-streamop@findex lineup-streamop (c-)@item c-lineup-streamopLine up C++ stream operators (i.e. @samp{<<} and @samp{>>}).@workswith @code{stream-op}.@findex c-lineup-multi-inher@findex lineup-multi-inher (c-)@item c-lineup-multi-inherLine up the classes in C++ multiple inheritance clauses and memberinitializers under each other. E.g:@example@groupFoo::Foo (int a, int b): Cyphr (a), Bar (b) // c-lineup-multi-inher@end group@end example@noindentand@example@groupclass Foo : public Cyphr, public Bar // c-lineup-multi-inher@end group@end example@noindentand@example@groupFoo::Foo (int a, int b) : Cyphr (a) , Bar (b) // c-lineup-multi-inher@end group@end example@workswith @code{inher-cont}, @code{member-init-cont}.@findex c-lineup-java-inher@findex lineup-java-inher (c-)@item c-lineup-java-inherLine up Java implements and extends declarations. If class namesfollows on the same line as the @samp{implements}/@samp{extends}keyword, they are lined up under each other. Otherwise, they areindented by adding @code{c-basic-offset} to the column of the keyword.E.g:@example@groupclass Foo extends Bar // c-lineup-java-inher <--> c-basic-offset@end group@end example@noindentand@example@groupclass Foo extends Cyphr, Bar // c-lineup-java-inher@end group@end example@workswith @code{inher-cont}.@findex c-lineup-java-throws@findex lineup-java-throws (c-)@item c-lineup-java-throwsLine up Java throws declarations. If exception names follows on thesame line as the throws keyword, they are lined up under each other.Otherwise, they are indented by adding @code{c-basic-offset} to thecolumn of the @samp{throws} keyword. The @samp{throws} keyword itselfis also indented by @code{c-basic-offset} from the function declarationstart if it doesn't hang. E.g:@example@groupint foo() throws // c-lineup-java-throws Bar // c-lineup-java-throws<--><--> c-basic-offset@end group@end example@noindentand@example@groupint foo() throws Cyphr, Bar, // c-lineup-java-throws Vlod // c-lineup-java-throws@end group@end example@workswith @code{func-decl-cont}.@findex c-indent-one-line-block@findex indent-one-line-block (c-)@item c-indent-one-line-blockIndent a one line block @code{c-basic-offset} extra. E.g:@example@groupif (n > 0) @{m+=n; n=0;@} // c-indent-one-line-block<--> c-basic-offset@end group@end example@noindentand@example@groupif (n > 0)@{ // c-indent-one-line-block m+=n; n=0;@}@end group@end exampleThe block may be surrounded by any kind of parenthesis characters.@code{nil} is returned if the line doesn't start with a one line block,which makes the function usable in list expressions.@workswith Almost all syntactic symbols, but most useful on the@code{-open} symbols.@findex c-indent-multi-line-block@findex indent-multi-line-block (c-)@item c-indent-multi-line-blockIndent a multi line block @code{c-basic-offset} extra. E.g:@example@groupint *foo[] = @{ NULL, @{17@}, // c-indent-multi-line-block@end group@end example@noindentand@example@groupint *foo[] = @{ NULL, @{ // c-indent-multi-line-block 17 @}, <--> c-basic-offset@end group@end exampleThe block may be surrounded by any kind of parenthesis characters.@code{nil} is returned if the line doesn't start with a multi lineblock, which makes the function usable in list expressions.@workswith Almost all syntactic symbols, but most useful on the@code{-open} symbols.@findex c-lineup-C-comments@findex lineup-C-comments (c-)@item c-lineup-C-commentsLine up C block comment continuation lines. Various heuristics are usedto handle most of the common comment styles. Some examples:@example@group/* /** /* * text * text text */ */ */@end group@group/* text /* /** text ** text ** text*/ */ */@end group@group/************************************************** * text *************************************************/@end group@vindex comment-start-skip@group/************************************************** Free form text comments: In comments with a long delimiter line at the start, the indentation is kept unchanged for lines that start with an empty comment line prefix. The delimiter line is whatever matches the @code{comment-start-skip} regexp.**************************************************/@end group@end exampleThe style variable @code{c-comment-prefix-regexp} is used to recognizethe comment line prefix, e.g. the @samp{*} that usually starts everyline inside a comment.@workswith The @code{c} syntactic symbol.@findex c-lineup-comment@findex lineup-comment (c-)@item c-lineup-commentLine up a comment-only line according to the style variable@code{c-comment-only-line-offset}. If the comment is lined up with acomment starter on the previous line, that alignment is preserved.@vindex c-comment-only-line-offset@vindex comment-only-line-offset (c-)@code{c-comment-only-line-offset} specifies the extra offset for theline. It can contain an integer or a cons cell of the form@example (@r{<non-anchored-offset>} . @r{<anchored-offset>})@end example@noindentwhere @var{non-anchored-offset} is the amount of offset given tonon-column-zero anchored lines, and @var{anchored-offset} is the amountof offset to give column-zero anchored lines. Just an integer as valueis equivalent to @code{(@r{<value>} . -1000)}.@workswith @code{comment-intro}.@findex c-lineup-runin-statements@findex lineup-runin-statements (c-)@item c-lineup-runin-statementsLine up statements for coding standards which place the first statementin a block on the same line as the block opening brace@footnote{Run-instyle doesn't really work too well. You might need to write your owncustom indentation functions to better support this style.}. E.g:@example@groupint main()@{ puts (\"Hello world!\"); return 0; // c-lineup-runin-statements@}@end group@end exampleIf there is no statement after the opening brace to align with,@code{nil} is returned. This makes the function usable in listexpressions.@workswith The @code{statement} syntactic symbol.@findex c-lineup-math@findex lineup-math (c-)@item c-lineup-mathLine up the current line after the equal sign on the first line in thestatement. If there isn't any, indent with @code{c-basic-offset}. Ifthe current line contains an equal sign too, try to align it with thefirst one.@workswith @code{statement-cont}.@findex c-lineup-template-args@findex lineup-template-args (c-)@item c-lineup-template-argsLine up the arguments of a template argument list under each other, butonly in the case where the first argument is on the same line as theopening @samp{<}.To allow this function to be used in a list expression, @code{nil} isreturned if there's no template argument on the first line.@workswith @code{template-args-cont}.@findex c-lineup-ObjC-method-call@findex lineup-ObjC-method-call (c-)@item c-lineup-ObjC-method-callFor Objective-C code, line up selector args as @code{elisp-mode} doeswith function args: go to the position right after the message receiver,and if you are at the end of the line, indent the current linec-basic-offset columns from the opening bracket; otherwise you arelooking at the first character of the first method call argument, solineup the current line with it.@workswith @code{objc-method-call-cont}.@findex c-lineup-ObjC-method-args@findex lineup-ObjC-method-args (c-)@item c-lineup-ObjC-method-argsFor Objective-C code, line up the colons that separate args. The colonon the current line is aligned with the one on the first line.@workswith @code{objc-method-args-cont}.@findex c-lineup-ObjC-method-args-2@findex lineup-ObjC-method-args-2 (c-)@item c-lineup-ObjC-method-args-2Similar to @code{c-lineup-ObjC-method-args} but lines up the colon onthe current line with the colon on the previous line.@workswith @code{objc-method-args-cont}.@findex c-lineup-inexpr-block@findex lineup-inexpr-block (c-)@item c-lineup-inexpr-blockThis can be used with the in-expression block symbols to indent thewhole block to the column where the construct is started. E.g. for Javaanonymous classes, this lines up the class under the @samp{new} keyword,and in Pike it lines up the lambda function body under the @samp{lambda}keyword. Returns @code{nil} if the block isn't part of such aconstruct.@workswith @code{inlambda}, @code{inexpr-statement},@code{inexpr-class}.@findex c-lineup-whitesmith-in-block@findex lineup-whitesmith-in-block (c-)@item c-lineup-whitesmith-in-blockLine up lines inside a block in Whitesmiths style. It's done in a waythat works both when the opening brace hangs and when it doesn't. E.g:@example@groupsomething @{ foo; // c-lineup-whitesmith-in-block @}@end group@end example@noindentand@example@groupsomething @{ foo; // c-lineup-whitesmith-in-block @}<--> c-basic-offset@end group@end exampleIn the first case the indentation is kept unchanged, in the second@code{c-basic-offset} is added.@workswith @code{defun-close}, @code{defun-block-intro},@code{block-close}, @code{brace-list-close}, @code{brace-list-intro},@code{statement-block-intro}, @code{inclass}, @code{inextern-lang},@code{innamespace}.@findex c-lineup-dont-change@findex lineup-dont-change (c-)@item c-lineup-dont-changeThis lineup function makes the line stay at whatever indentation italready has; think of it as an identity function for lineups. It isused for @code{cpp-macro-cont} lines.@workswith Any syntactic symbol.@end table@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@node Performance Issues, Limitations and Known Bugs, Indentation Functions, Top@comment node-name, next, previous, up@chapter Performance Issues@cindex performance issues@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!C and its derivative languages are highly complex creatures. Often,ambiguous code situations arise that require @ccmode{} to scanlarge portions of the buffer to determine syntactic context. Suchpathological code@footnote{such as the output of @code{lex(1)}!}can cause @ccmode{} to perform fairly badly.This section identifies some of the coding styles to watch out for, andsuggests some workarounds that you can use to improve performance.Because @ccmode{} has to scan the buffer backwards from the currentinsertion point, and because C's syntax is fairly difficult to parse inthe backwards direction, @ccmode{} often tries to find the nearestposition higher up in the buffer from which to begin a forward scan.The farther this position is from the current insertion point, theslower the mode gets. Some coding styles can even force @ccmode{}to scan from the beginning of the buffer for every line of code!@findex beginning-of-defun@findex defun-prompt-regexpOne of the simplest things you can do to reduce scan time, is make sureany brace that opens a top-level construct@footnote{E.g. a function inC, or outermost class definition in C++ or Java.} always appears in theleftmost column. This is actually an Emacs constraint, as embodied inthe @code{beginning-of-defun} function which @ccmode{} uses heavily. Ifyou insist on hanging top-level open braces on the right side of theline, then you might want to set the variable @code{defun-prompt-regexp}to something reasonable, however that ``something reasonable'' isdifficult to define, so @ccmode{} doesn't do it for you.@vindex c-Java-defun-prompt-regexp@vindex Java-defun-prompt-regexp (c-)A special note about @code{defun-prompt-regexp} in Java mode: while muchof the early sample Java code seems to encourage a style where the bracethat opens a class is hung on the right side of the line, this is not agood style to pursue in Emacs. @ccmode{} comes with a variable@code{c-Java-defun-prompt-regexp} which tries to define a regularexpression usable for this style, but there are problems with it. Insome cases it can cause @code{beginning-of-defun} to hang@footnote{Thishas been observed in Emacs 19.34 and XEmacs 19.15.}. For this reason,it is not used by default, but if you feel adventurous, you can set@code{defun-prompt-regexp} to it in your mode hook. In any event,setting and rely on @code{defun-prompt-regexp} will definitely slowthings down anyway because you'll be doing regular expression searchesfor every line you indent, so you're probably screwed either way!@vindex c-enable-xemacs-performance-kludge-p@vindex enable-xemacs-performance-kludge-p (c-)Another alternative for XEmacs users, is to set the variable@code{c-enable-xemacs-performance-kludge-p} to non-@code{nil}. Thistells @ccmode{} to use XEmacs-specific built-in functions which, in somecircumstances, can locate the top-most opening brace much quicker than@code{beginning-of-defun}. Preliminary testing has shown that forstyles where these braces are hung (e.g. most JDK-derived Java styles),this hack can improve performance of the core syntax parsing routinesfrom 3 to 60 times. However, for styles which @emph{do} conform toEmacs' recommended style of putting top-level braces in column zero,this hack can degrade performance by about as much. Thus this variableis set to @code{nil} by default, since the Emacs-friendly stylesshould be more common (andencouraged!). Note that this variable has no effect in Emacs since thenecessary built-in functions don't exist (in Emacs 20.2 or 20.3 as ofthis writing 27-Apr-1998).You will probably notice pathological behavior from @ccmode{} whenworking in files containing large amounts of C preprocessor macros.This is because Emacs cannot skip backwards over these lines as quicklyas it can comments.@vindex c-recognize-knr-p@vindex recognize-knr-p (c-)Previous versions of @ccmode{} had potential performance problemswhen recognizing K&R style function argument declarations. This wasbecause there are ambiguities in the C syntax when K&R style argumentlists are used@footnote{It is hard to distinguish them from top-leveldeclarations.}. @ccmode{} has adopted BOCM's convention forlimiting the search: it assumes that argdecls are indented at least onespace, and that the function headers are not indented at all. Withcurrent versions of @ccmode{}, user customization of@code{c-recognize-knr-p} is deprecated. Just don't put argdecls incolumn zero!@cindex @file{cc-lobotomy.el} file@vindex cc-lobotomy-pith-listYou might want to investigate the speed-ups contained in thefile @file{cc-lobotomy.el}, which comes as part of the @ccmode{}distribution, but is completely unsupported.As mentioned previous, @ccmode{} always trades speed for accuracy,however it is recognized that sometimes you need speed and can sacrificesome accuracy in indentation. The file @file{cc-lobotomy.el} containshacks that will ``dumb down'' @ccmode{} in some specific ways, makingthat trade-off of accuracy for speed. I won't go into details of itsuse here; you should read the comments at the top of the file, and lookat the variable @code{cc-lobotomy-pith-list} for details.@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@node Limitations and Known Bugs, Frequently Asked Questions, Performance Issues, Top@comment node-name, next, previous, up@chapter Limitations and Known Bugs@cindex limitations@cindex bugs@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@itemize @bullet@itemRe-indenting large regions or expressions can be slow.@findex c-indent-exp@findex indent-exp (c-)@item@code{c-indent-exp} has not been fully optimized. It essentiallyequivalent to hitting @kbd{TAB} (@code{c-indent-command}) on everyline. Some information is cached from line to line, but such cachinginvariable causes inaccuracies in analysis in some bizarre situations.@vindex signal-error-on-buffer-boundary@itemXEmacs versions from 19.15 until (as of this writing 12-Mar-1998) 20.4contain a variable called @code{signal-error-on-buffer-boundary}. Thiswas intended as a solution to user interface problems associated withbuffer movement and the @code{zmacs-region} deactivation on errors.However, setting this variable to a non-default value had thedeleterious side effect of breaking many built-in primitive functions.Most users will not be affected since they never change the value ofthis variable. @strong{Do not set this variable to @code{nil}}; youwill cause serious problems in @ccmode{} and probably other XEmacspackages! As of at least XEmacs 20.4, the effects this variable triedto correct have been fixed in other, better ways.@end itemize@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@node Frequently Asked Questions, Getting the Latest CC Mode Release, Limitations and Known Bugs, Top@comment node-name, next, previous, up@appendix Frequently Asked Questions@cindex frequently asked questions@cindex FAQ@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@kindex C-x h@kindex C-M-\@kindex C-M-x@kindex C-M-q@kindex C-M-u@kindex RET@kindex C-j@quotation@strong{Q.} @emph{How do I re-indent the whole file?}@strong{A.} Visit the file and hit @kbd{C-x h} to mark the wholebuffer. Then hit @kbd{C-M-\}.@sp 1@strong{Q.} @emph{How do I re-indent the entire function?@kbd{C-M-x} doesn't work.}@strong{A.} @kbd{C-M-x} is reserved for future Emacs use.To re-indent the entire function hit @kbd{C-c C-q}.@sp 1@strong{Q.} @emph{How do I re-indent the current block?}@strong{A.} First move to the brace which opens the block with@kbd{C-M-u}, then re-indent that expression with@kbd{C-M-q}.@sp 1@strong{Q.} @emph{Why doesn't the @kbd{RET} key indent the new line?}@strong{A.} Emacs' convention is that @kbd{RET} just adds a newline,and that @kbd{C-j} adds a newline and indents it. You can make@kbd{RET} do this too by adding this to your@code{c-mode-common-hook}:@example(define-key c-mode-base-map "\C-m" 'c-context-line-break)@end exampleThis is a very common question. If you want this to be the defaultbehavior, don't lobby me, lobby RMS! @t{:-)}@sp 1@strong{Q.} @emph{I put @code{(c-set-offset 'substatement-open 0)}in my @file{.emacs} file but I get an error saying that@code{c-set-offset}'s function definition is void.}@strong{A.} This means that @ccmode{} wasn't loaded into yourEmacs session by the time the @code{c-set-offset} call was reached,most likely because @ccmode{} is being autoloaded. Insteadof putting the @code{c-set-offset} line in your top-level@file{.emacs} file, put it in your @code{c-mode-common-hook}, orsimply modify @code{c-offsets-alist} directly:@example(setq c-offsets-alist '((substatement-open . 0)))@end example@sp 1@strong{Q.} @emph{How do I make strings, comments, keywords, and otherconstructs appear in different colors, or in bold face, etc.?}@strong{A.} ``Syntax Colorization'' is a standard Emacs feature,controlled by @code{font-lock-mode}. @ccmode{} does not containfont-lock definitions for any of its supported languages.@sp 1@strong{Q.} @emph{@kbd{M-a} and @kbd{M-e} used to move over entirebalanced brace lists, but now they move into blocks. How do I get theold behavior back?}@strong{A.} Use @kbd{C-M-f} and @kbd{C-M-b} to move over balanced braceblocks. Use @kbd{M-a} and @kbd{M-e} to move by statements, which willalso move into blocks.@sp 1@strong{Q.} @emph{Whenever I try to indent a line or type an``electric'' key such as @kbd{;}, @kbd{@{}, or @kbd{@}}, I get an errorthat look like this: @code{Invalid function: (macro . #[...}. Whatgives?}@strong{A.} This is a common error when @ccmode{} hasn't been compiledcorrectly, especially under Emacs 19.34@footnote{Technically, it'sbecause some macros wasn't defined during the compilation, so the bytecompiler put in function calls instead of the macro expansions. Later,when the interpreter tries to call the macros as functions, it showsthis (somewhat cryptic) error message.}. If you are using the standalone@ccmode{} distribution, try recompiling it according to the instructionsin the @file{README} file.@end quotation@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@node Getting the Latest CC Mode Release, Mailing Lists and Submitting Bug Reports, Frequently Asked Questions, Top@comment node-name, next, previous, up@appendix Getting the Latest CC Mode Release@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@ccmode{} is standard with all versions of Emacs since 19.34 and ofXEmacs since 19.16.Due to release schedule skew, it is likely that all of these Emacsenhave old versions of @ccmode{} and so should be upgraded. Access to the@ccmode{} source code, as well as more detailed information on Emacsencompatibility, etc. are all available via the Web at:@example@group @uref{http://cc-mode.sourceforge.net/}@end group@end example@emph{Old URLs, including the FTP URLs, should no longer be used.}There are many files under these directories; you can pick up the entiredistribution (named @code{cc-mode.tar.gz}; a gzip'd tar file), or any ofthe individual files, including PostScript documentation.@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@node Mailing Lists and Submitting Bug Reports, Sample .emacs File, Getting the Latest CC Mode Release, Top@comment node-name, next, previous, up@appendix Mailing Lists and Submitting Bug Reports@cindex mailing lists@cindex reporting bugs@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@kindex C-c C-b@findex c-submit-bug-report@findex submit-bug-report (c-)To report bugs, use the @kbd{C-c C-b} (@code{c-submit-bug-report})command. This provides vital information we need to reproduce yourproblem. Make sure you include a concise, but complete code example.Please try to boil your example down to just the essential code neededto reproduce the problem, and include an exact recipe of steps needed toexpose the bug. Be especially sure to include any code that appears@emph{before} your bug example, if you think it might affect our abilityto reproduce it.Please try to produce the problem in an Emacs instance without anycustomizations loaded (i.e. start it with the @code{-q -no-site-file}arguments). If it works correctly there, the problem might be caused byfaulty customizations in either your own or your site configuration. Inthat case, we'd appreciate if you isolate the Emacs Lisp code that trigsthe bug and include it in your report.@cindex bug report mailing listBug reports are now sent to the following email addresses:@email{bug-cc-mode@@gnu.org} and @email{bug-gnu-emacs@@gnu.org}; thelatter is mirrored on the Usenet newsgroup @code{gnu.emacs.bug}. Youcan send other questions and suggestions (kudos? @t{;-)} to@email{bug-cc-mode@@gnu.org}.@cindex announcement mailing listIf you want to get announcements of new @ccmode{} releases, send theword @emph{subscribe} in the body of a message to@email{cc-mode-announce-request@@lists.sourceforge.net}. Announcementswill also be posted to the Usenet newsgroups @code{gnu.emacs.sources},@code{comp.emacs} and @code{comp.emacs.xemacs}.@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@node Sample .emacs File, Concept Index, Mailing Lists and Submitting Bug Reports, Top@comment node-name, next, previous, up@appendix Sample .emacs file@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@example;; Here's a sample .emacs file that might help you along the way. Just;; copy this region and paste it into your .emacs file. You may want to;; change some of the actual values.(defconst my-c-style '((c-tab-always-indent . t) (c-comment-only-line-offset . 4) (c-hanging-braces-alist . ((substatement-open after) (brace-list-open))) (c-hanging-colons-alist . ((member-init-intro before) (inher-intro) (case-label after) (label after) (access-label after))) (c-cleanup-list . (scope-operator empty-defun-braces defun-close-semi)) (c-offsets-alist . ((arglist-close . c-lineup-arglist) (substatement-open . 0) (case-label . 4) (block-open . 0) (knr-argdecl-intro . -))) (c-echo-syntactic-information-p . t) ) "My C Programming Style");; offset customizations not in my-c-style(setq c-offsets-alist '((member-init-intro . ++)));; Customizations for all modes in CC Mode.(defun my-c-mode-common-hook () ;; add my personal style and set it for the current buffer (c-add-style "PERSONAL" my-c-style t) ;; other customizations (setq tab-width 8 ;; this will make sure spaces are used instead of tabs indent-tabs-mode nil) ;; we like auto-newline and hungry-delete (c-toggle-auto-hungry-state 1) ;; key bindings for all supported languages. We can put these in ;; c-mode-base-map because c-mode-map, c++-mode-map, objc-mode-map, ;; java-mode-map, idl-mode-map, and pike-mode-map inherit from it. (define-key c-mode-base-map "\C-m" 'c-context-line-break) )(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)@end example@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@node Concept Index, Command Index, Sample .emacs File, Top@comment node-name, next, previous, up@unnumbered Concept Index@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@printindex cp@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@node Command Index, Key Index, Concept Index, Top@comment node-name, next, previous, up@unnumbered Command Index@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!Since most @ccmode{} commands are prepended with the string@samp{c-}, each appears under its @code{c-@var{<thing>}} name and its@code{@var{<thing>} (c-)} name.@iftex@sp 2@end iftex@printindex fn@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@node Key Index, Variable Index, Command Index, Top@comment node-name, next, previous, up@unnumbered Key Index@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@printindex ky@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@node Variable Index, , Key Index, Top@comment node-name, next, previous, up@unnumbered Variable Index@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!Since most @ccmode{} variables are prepended with the string@samp{c-}, each appears under its @code{c-@var{<thing>}} name and its@code{@var{<thing>} (c-)} name.@iftex@sp 2@end iftex@printindex vr@iftex@page@summarycontents@contents@end iftex@bye@ignore arch-tag: c4cab162-5e57-4366-bdce-4a9db2fc97f0@end ignore