X-Git-Url: https://git.hcoop.net/bpt/emacs.git/blobdiff_plain/020716e178cdae443a3630c4307023cb3fc4c350..29993416fb4d19c1c3bb146367fc4bed74845486:/doc/misc/cc-mode.texi diff --git a/doc/misc/cc-mode.texi b/doc/misc/cc-mode.texi index 8818904982..74e3485441 100644 --- a/doc/misc/cc-mode.texi +++ b/doc/misc/cc-mode.texi @@ -81,14 +81,15 @@ the second with them pointing to the XEmacs manuals. @comment No overfull hbox marks in the dvi file. @finalout -@setfilename ../../info/ccmode +@setfilename ../../info/ccmode.info @settitle CC Mode Manual +@documentencoding UTF-8 @footnotestyle end @c The following four macros generate the filenames and titles of the @c main (X)Emacs manual and the Elisp/Lispref manual. Leave the @c Texinfo variable `XEMACS' unset to generate a GNU Emacs version, set it -@c to generate an XEmacs version, e.g. with +@c to generate an XEmacs version, e.g., with @c "makeinfo -DXEMACS cc-mode.texi". @ifset XEMACS @macro emacsman @@ -147,10 +148,7 @@ CC Mode @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @comment Define an index for syntactic symbols. -@ifnottex @c In texi2dvi, the @defindex would create an empty cc-mode.ss - @c For Info, unlike tex, @syncodeindex needs a matching @defindex. @defindex ss -@end ifnottex @comment Combine key, syntactic symbol and concept indices into one. @syncodeindex ss cp @@ -159,19 +157,18 @@ CC Mode @copying This manual is for CC Mode in Emacs. -Copyright @copyright{} 1995-2011 Free Software Foundation, Inc. +Copyright @copyright{} 1995--2014 Free Software Foundation, Inc. @quotation Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no -Invariant Sections, with the Front-Cover texts being ``A GNU Manual'', +Invariant Sections, with the Front-Cover Texts being ``A GNU Manual'', and with the Back-Cover Texts as in (a) below. A copy of the license is included in the section entitled ``GNU Free Documentation License''. (a) The FSF's Back-Cover Text is: ``You have the freedom to copy and -modify this GNU manual. Buying copies from the FSF supports it in -developing GNU and promoting software freedom.'' +modify this GNU manual.'' @end quotation @end copying @@ -180,7 +177,7 @@ developing GNU and promoting software freedom.'' @dircategory Emacs editing modes @direntry * CC Mode: (ccmode). Emacs mode for editing C, C++, Objective-C, - Java, Pike, AWK, and CORBA IDL code. + Java, Pike, AWK, and CORBA IDL code. @end direntry @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -190,9 +187,9 @@ developing GNU and promoting software freedom.'' @titlepage @sp 10 -@center @titlefont{CC Mode 5.31} +@center @titlefont{CC Mode 5.32} @sp 2 -@center @subtitlefont{A GNU Emacs mode for editing C and C-like languages} +@center A GNU Emacs mode for editing C and C-like languages @sp 2 @center Barry A. Warsaw, Martin Stjernholm, Alan Mackenzie @@ -223,7 +220,7 @@ Objective-C, Java, CORBA IDL (and the variants PSDL and CIDL), Pike and AWK code. It provides syntax-based indentation, font locking, and has several handy commands and some minor modes to make the editing easier. It does not provide tools to look up and navigate between -functions, classes etc - there are other packages for that. +functions, classes, etc.; there are other packages for that. @insertcopying @end ifnottex @@ -245,7 +242,7 @@ functions, classes etc - there are other packages for that. * Customizing Indentation:: * Custom Macros:: * Odds and Ends:: -* Sample .emacs File:: +* Sample Init File:: * Performance Issues:: * Limitations and Known Bugs:: * FAQ:: @@ -287,11 +284,11 @@ Configuration Basics Styles -* Built-in Styles:: -* Choosing a Style:: -* Adding Styles:: -* Guessing the Style:: -* File Styles:: +* Built-in Styles:: +* Choosing a Style:: +* Adding Styles:: +* Guessing the Style:: +* File Styles:: Customizing Auto-newlines @@ -311,19 +308,19 @@ Indentation Engine Basics Syntactic Symbols -* Function Symbols:: -* Class Symbols:: -* Conditional Construct Symbols:: -* Switch Statement Symbols:: -* Brace List Symbols:: -* External Scope Symbols:: -* Paren List Symbols:: -* Literal Symbols:: -* Multiline Macro Symbols:: -* Objective-C Method Symbols:: +* Function Symbols:: +* Class Symbols:: +* Conditional Construct Symbols:: +* Switch Statement Symbols:: +* Brace List Symbols:: +* External Scope Symbols:: +* Paren List Symbols:: +* Literal Symbols:: +* Multiline Macro Symbols:: +* Objective-C Method Symbols:: * Java Symbols:: -* Statement Block Symbols:: -* K&R Symbols:: +* Statement Block Symbols:: +* K&R Symbols:: Customizing Indentation @@ -341,6 +338,11 @@ Line-Up Functions * Comment Line-Up:: * Misc Line-Up:: +Customizing Macros + +* Macro Backslashes:: +* Macros with ;:: + @end detailmenu @end menu @@ -368,12 +370,12 @@ Late in 1997, Martin Stjernholm joined Barry on the @ccmode{} Maintainers Team, and implemented the Pike support. In 2000 Martin took over as the sole maintainer. In 2001 Alan Mackenzie joined the team, implementing AWK support in version 5.30. @ccmode{} did not -originally contain the font lock support for its languages --- that +originally contain the font lock support for its languages; that was added in version 5.30. This manual describes @ccmode{} @comment The following line must appear on its own, so that the -version 5.31. +version 5.32. @comment Release.py script can update the version number automatically @ccmode{} supports the editing of K&R and ANSI C, C++, Objective-C, @@ -440,7 +442,7 @@ increasing detail. @itemize @bullet @item The chapter ``Configuration Basics'' tells you @emph{how} to write -customizations - whether in hooks, in styles, in both, or in neither, +customizations: whether in hooks, in styles, in both, or in neither, depending on your needs. It describes the @ccmode{} style system and lists the standard styles that @ccmode{} supplies. @@ -467,7 +469,7 @@ The FAQ contains a list of common problems and questions. @item The next two chapters tell you how to get in touch with the @ccmode{} -project - whether for updating @ccmode{} or submitting bug reports. +project: whether for updating @ccmode{} or submitting bug reports. @end itemize @noindent @@ -644,17 +646,21 @@ you're better off getting an external program like GNU @code{indent}, which will rearrange brace location, amongst other things. Preprocessor directives are handled as syntactic whitespace from other -code, i.e. they can be interspersed anywhere without affecting the +code, i.e., they can be interspersed anywhere without affecting the indentation of the surrounding code, just like comments. The code inside macro definitions is, by default, still analyzed syntactically so that you get relative indentation there just as you'd get if the same code was outside a macro. However, since there is no -hint about the syntactic context, i.e. whether the macro expands to an +hint about the syntactic context, i.e., whether the macro expands to an expression, to some statements, or perhaps to whole functions, the syntactic recognition can be wrong. @ccmode{} manages to figure it out correctly most of the time, though. +Some macros, when invoked, ''have their own semicolon''. To get the +next line indented correctly, rather than as a continuation line, +@xref{Macros with ;}. + Reindenting large sections of code can take a long time. When @ccmode{} reindents a region of code, it is essentially equivalent to hitting @key{TAB} on every line of the region. @@ -695,7 +701,7 @@ in some circumstances---@code{c-insert-tab-function} then defines precisely what sort of ``whitespace'' this will be. Set the standard Emacs variable @code{indent-tabs-mode} to @code{t} if you want real @samp{tab} characters to be used in the indentation, to @code{nil} if -you want only spaces. @xref{Just Spaces,,, @emacsman{}, +you want only spaces. @xref{Just Spaces,,,@emacsman{}, @emacsmantitle{}}. @defopt c-tab-always-indent @@ -710,7 +716,7 @@ current line. When it is @code{nil}, @key{TAB} (re)indents the line only if point is to the left of the first non-whitespace character on the line. Otherwise it inserts some whitespace (a tab or an equivalent number of -spaces - see below) at point. +spaces; see below) at point. @item With some other value, the line is reindented. Additionally, if point is within a string or comment, some whitespace is inserted. @@ -745,12 +751,6 @@ very useful in this case. @end itemize @table @asis -@item @kbd{C-j} (@code{newline-and-indent}) -@kindex C-j -@findex newline-and-indent -Inserts a newline and indents the new blank line, ready to start -typing. This is a standard (X)Emacs command. - @item @kbd{C-M-q} (@code{c-indent-exp}) @kindex C-M-q @findex c-indent-exp @@ -767,7 +767,7 @@ Indents the entire top-level function, class or macro definition encompassing point. It leaves point unchanged. This function can't be used to reindent a nested brace construct, such as a nested class or function, or a Java method. The top-level construct being reindented -must be complete, i.e. it must have both a beginning brace and an ending +must be complete, i.e., it must have both a beginning brace and an ending brace. @item @kbd{C-M-\} (@code{indent-region}) @@ -815,10 +815,10 @@ often (in seconds) progress messages are to be displayed. @kindex C-c C-c @findex comment-region This command comments out the lines that start in the region. With a -negative argument, it does the opposite - it deletes the comment +negative argument, it does the opposite: it deletes the comment delimiters from these lines. @xref{Multi-Line Comments,,, emacs, GNU Emacs Manual}, for fuller details. @code{comment-region} isn't -actually part of @ccmode{} - it is given a @ccmode{} binding for +actually part of @ccmode{}; it is given a @ccmode{} binding for convenience. @item @kbd{M-;} (@code{comment-dwim} or @code{indent-for-comment} @footnote{The name of this command varies between (X)Emacs versions.}) @@ -903,7 +903,7 @@ construct, should the point start inside it. If @ccmode fails to find function beginnings or ends inside the current declaration scope, it will search the enclosing scopes. If you want @ccmode to recognize functions only at the top level@footnote{this was @ccmode{}'s -behaviour prior to version 5.32.}, set @code{c-defun-tatic} to +behavior prior to version 5.32.}, set @code{c-defun-tactic} to @code{t}. These functions are analogous to the Emacs built-in commands @@ -1015,7 +1015,7 @@ preprocessor statements. A popular programming style, especially for object-oriented languages such as C++ is to write symbols in a mixed case format, where the first letter of each word is capitalized, and not separated by -underscores. E.g. @samp{SymbolsWithMixedCaseAndNoUnderlines}. +underscores. E.g., @samp{SymbolsWithMixedCaseAndNoUnderlines}. These commands move backward or forward to the beginning of the next capitalized word. With prefix argument @var{n}, move @var{n} times. @@ -1037,7 +1037,7 @@ Movement}. They might be removed from a future release of @ccmode{}. Since there's a lot of normal text in comments and string literals, @ccmode{} provides features to edit these like in text mode. The goal -is to do it seamlessly, i.e. you can use auto fill mode, sentence and +is to do it seamlessly, i.e., you can use auto fill mode, sentence and paragraph movement, paragraph filling, adaptive filling etc. wherever there's a piece of normal text without having to think much about it. @ccmode{} keeps the indentation, fixes suitable comment line prefixes, @@ -1052,8 +1052,8 @@ set this up for you, so you probably won't have to bother. @cindex Auto Fill mode @cindex paragraph filling Line breaks are by default handled (almost) the same regardless of -whether they are made by auto fill mode (@pxref{Auto Fill,,, -@emacsman{}, @emacsmantitle{}}), by paragraph filling (e.g. with +whether they are made by auto fill mode (@pxref{Auto +Fill,,,@emacsman{}, @emacsmantitle{}}), by paragraph filling (e.g., with @kbd{M-q}), or explicitly with @kbd{M-j} or similar methods. In string literals, the new line gets the same indentation as the previous nonempty line.@footnote{You can change this default by @@ -1108,13 +1108,13 @@ valid.}. This function is 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 should consider switching to -this function. @xref{Sample .emacs File}. +this function. @xref{Sample Init File}. @item @kbd{M-x c-context-open-line} @findex c-context-open-line @findex context-open-line (c-) This is to @kbd{C-o} (@kbd{M-x open-line}) as -@code{c-context-line-break} is to @kbd{RET}. I.e. it works just like +@code{c-context-line-break} is to @kbd{RET}. I.e., it works just like @code{c-context-line-break} but leaves the point before the inserted line break. @end table @@ -1138,18 +1138,18 @@ editing chaotically formatted code. It can also be disconcerting, especially for users who are new to @ccmode{}. @item auto-newline mode This automatically inserts newlines where you'd probably want to type -them yourself, e.g. after typing @samp{@}}s. Its action is suppressed +them yourself, e.g., after typing @samp{@}}s. Its action is suppressed when electric mode is disabled. @item hungry-delete mode This lets you delete a contiguous block of whitespace with a single -key - for example, the newline and indentation just inserted by +key: for example, the newline and indentation just inserted by auto-newline when you want to back up and write a comment after the last statement. @item subword mode This mode makes basic word movement commands like @kbd{M-f} (@code{forward-word}) and @kbd{M-b} (@code{backward-word}) treat the parts of sillycapsed symbols as different words. -E.g. @samp{NSGraphicsContext} is treated as three words @samp{NS}, +E.g., @samp{NSGraphicsContext} is treated as three words @samp{NS}, @samp{Graphics}, and @samp{Context}. @item syntactic-indentation mode When this is enabled (which it normally is), indentation commands such @@ -1164,14 +1164,14 @@ Full details on how these minor modes work are at @ref{Electric Keys}, and @ref{Indentation Engine Basics}. You can toggle each of these minor modes on and off, and you can -configure @ccmode{} so that it starts up with your favourite -combination of them (@pxref{Sample .emacs File}). By default, when +configure @ccmode{} so that it starts up with your favorite +combination of them (@pxref{Sample Init File}). By default, when you initialize a buffer, electric mode and syntactic-indentation mode -are enabled but the other two modes are disabled. +are enabled but the other three modes are disabled. @ccmode{} displays the current state of the first four of these minor modes on the modeline by appending letters to the major mode's name, -one letter for each enabled minor mode - @samp{l} for electric mode, +one letter for each enabled minor mode: @samp{l} for electric mode, @samp{a} for auto-newline mode, @samp{h} for hungry delete mode, and @samp{w} for subword mode. If all these modes were enabled, you'd see @samp{C/lahw}@footnote{The @samp{C} would be replaced with the name of @@ -1229,7 +1229,7 @@ turn it (or them) off. @cindex electric characters @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -Most punctuation keys provide @dfn{electric} behavior - as well as +Most punctuation keys provide @dfn{electric} behavior: as well as inserting themselves they perform some other action, such as reindenting the line. This reindentation saves you from having to reindent a line manually after typing, say, a @samp{@}}. A few @@ -1282,7 +1282,7 @@ A star (bound to @code{c-electric-star}) or a slash (@code{c-electric-slash}) causes reindentation when you type it as the second component of a C style block comment opener (@samp{/*}) or a C++ line comment opener (@samp{//}) respectively, but only if the -comment opener is the first thing on the line (i.e. there's only +comment opener is the first thing on the line (i.e., there's only whitespace before it). Additionally, you can configure @ccmode{} so that typing a slash at @@ -1396,7 +1396,7 @@ continuation of the preceding @code{if}. @vindex abbrev-mode @findex abbrev-mode @cindex Abbrev mode -@ccmode{} uses Abbrev mode (@pxref{Abbrevs,,, @emacsman{}, @emacsmantitle{}}) +@ccmode{} uses Abbrev mode (@pxref{Abbrevs,,,@emacsman{}, @emacsmantitle{}}) to accomplish this. It's therefore turned on by default in all language modes except IDL mode, since CORBA IDL doesn't have any statements. @end deffn @@ -1420,7 +1420,7 @@ Auto-newline only triggers when the following conditions hold: @itemize @bullet @item Auto-newline minor mode is enabled, as evidenced by the indicator -@samp{a} after the mode name on the modeline (e.g. @samp{C/a} or +@samp{a} after the mode name on the modeline (e.g., @samp{C/a} or @samp{C/la}). @item @@ -1440,7 +1440,7 @@ definition. These constructs are also known as @dfn{syntactic whitespace} since they are usually ignored when scanning C code.}. @item -No numeric argument was supplied to the command (i.e. it was typed as +No numeric argument was supplied to the command (i.e., it was typed as normal, with no @kbd{C-u} prefix). @end itemize @@ -1625,7 +1625,7 @@ trouble with this in GNU Emacs. @cindex nomenclature @cindex subword In spite of the GNU Coding Standards, it is popular to name a symbol -by mixing uppercase and lowercase letters, e.g. @samp{GtkWidget}, +by mixing uppercase and lowercase letters, e.g., @samp{GtkWidget}, @samp{EmacsFrameClass}, or @samp{NSGraphicsContext}. Here we call these mixed case symbols @dfn{nomenclatures}. Also, each capitalized (or completely uppercase) part of a nomenclature is called a @@ -1813,7 +1813,7 @@ Lock,,, emacs, GNU Emacs Manual}, for ways to enable font locking in @strong{Please note:} The font locking in AWK mode is currently not integrated with the rest of @ccmode{}. Only the last section of this -chapter, @ref{AWK Mode Font Locking}, applies to AWK. The other +chapter, @ref{AWK Mode Font Locking}, applies to AWK@. The other sections apply to the other languages. @menu @@ -1906,7 +1906,7 @@ additional regexps to match those you use: For each language there's a variable @code{*-font-lock-extra-types}, where @samp{*} stands for the language in question. It contains a list of regexps that matches identifiers that should be recognized as types, -e.g. @samp{\\sw+_t} to recognize all identifiers ending with @samp{_t} +e.g., @samp{\\sw+_t} to recognize all identifiers ending with @samp{_t} as is customary in C code. Each regexp should not match more than a single identifier. @@ -2003,7 +2003,7 @@ labels. @vindex font-lock-builtin-face @vindex font-lock-reference-face Preprocessor directives get @code{font-lock-preprocessor-face} if it -exists (i.e. XEmacs). In Emacs they get @code{font-lock-builtin-face} +exists (i.e., XEmacs). In Emacs they get @code{font-lock-builtin-face} or @code{font-lock-reference-face}, for lack of a closer equivalent. @item @@ -2029,14 +2029,14 @@ since those aren't syntactic errors in themselves. @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! There are various tools to supply documentation in the source as -specially structured comments, e.g. the standard Javadoc tool in Java. +specially structured comments, e.g., the standard Javadoc tool in Java. @ccmode{} provides an extensible mechanism to fontify such comments and the special markup inside them. @defopt c-doc-comment-style @vindex doc-comment-style (c-) This is a style variable that specifies which documentation comment -style to recognize, e.g. @code{javadoc} for Javadoc comments. +style to recognize, e.g., @code{javadoc} for Javadoc comments. The value may also be a list of styles, in which case all of them are recognized simultaneously (presumably with markup cues that don't @@ -2054,7 +2054,7 @@ The default value for @code{c-doc-comment-style} is Note that @ccmode{} uses this variable to set other variables that handle fontification etc. That's done at mode initialization or when you switch to a style which sets this variable. Thus, if you change it -in some other way, e.g. interactively in a CC Mode buffer, you will need +in some other way, e.g., interactively in a CC Mode buffer, you will need to do @kbd{M-x java-mode} (or whatever mode you're currently using) to reinitialize. @@ -2096,7 +2096,7 @@ initialization and the result is prepended. For an example, see @code{javadoc-font-lock-keywords} in @file{cc-fonts.el}. If you add support for another doc comment style, please consider -contributing it - send a note to @email{bug-cc-mode@@gnu.org}. +contributing it: send a note to @email{bug-cc-mode@@gnu.org}. @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -2106,7 +2106,7 @@ contributing it - send a note to @email{bug-cc-mode@@gnu.org}. @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! The general appearance of font-locking in AWK mode is much like in any -other programming mode. @xref{Faces For Font Lock,,,elisp, GNU Emacs +other programming mode. @xref{Faces for Font Lock,,,elisp, GNU Emacs Lisp Reference Manual}. The following faces are, however, used in a non-standard fashion in @@ -2151,7 +2151,7 @@ A space between the function name and opening parenthesis when calling a user function. The last character of the function name and the opening parenthesis are highlighted. This font-locking rule will spuriously highlight a valid concatenation expression where an -identifier precedes a parenthesised expression. Unfortunately. +identifier precedes a parenthesized expression. Unfortunately. @item Whitespace following the @samp{\} in what otherwise looks like an @@ -2191,7 +2191,7 @@ method, ``Top-level commands or the customization interface''. If you make conflicting settings in several of these ways, the way that takes precedence is the one that appears latest in this list: -@itemize @asis +@itemize @w{} @item @table @asis @item Style @@ -2244,7 +2244,7 @@ more sophisticated facilities, hooks and styles. An Emacs @dfn{hook} is a place to put Lisp functions that you want Emacs to execute later in specific circumstances. @xref{Hooks,,,@lispref{}, @lispreftitle{}}. @ccmode{} supplies a main -hook and a language-specific hook for each language it supports - any +hook and a language-specific hook for each language it supports; any functions you put onto these hooks get executed as the last part of a buffer's initialization. Typically you put most of your customization within the main hook, and use the language-specific hooks to vary the @@ -2289,14 +2289,14 @@ to create them. A @dfn{file local variable setting} is a setting which applies to an individual source file. You put this in a @dfn{local variables list}, a special block at the end of the source file (@pxref{Specifying File -Variables,,, @emacsman{}}). +Variables,,,@emacsman{}}). @item File Styles A @dfn{file style} is a rarely used variant of the ``style'' mechanism described above, which applies to an individual source file. @xref{File Styles}. You use this by setting certain special variables -in a local variables list (@pxref{Specifying File Variables,,, -@emacsman{}}). +in a local variables list (@pxref{Specifying File +Variables,,,@emacsman{}}). @item Hooks with Styles For ultimate flexibility, you can use hooks and styles together. For @@ -2345,7 +2345,7 @@ have it enabled by default by placing the following in your @cindex mode hooks @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @c The node name is "CC Hooks" rather than "Hooks" because of a bug in -@c some older versions of Info, e.g. the info.el in GNU Emacs 21.3. +@c some older versions of Info, e.g., the info.el in GNU Emacs 21.3. @c If you go to "Config Basics" and hit on the xref to "CC @c Hooks" the function Info-follow-reference searches for "*Note: CC @c Hooks" from the beginning of the page. If this node were instead @@ -2373,7 +2373,7 @@ those set by @code{c-default-style}. @vindex initialization-hook (c-) Hook run only once per Emacs session, when @ccmode{} is initialized. This is a good place to change key bindings (or add new ones) in any -of the @ccmode{} key maps. @xref{Sample .emacs File}. +of the @ccmode{} key maps. @xref{Sample Init File}. @end defvar @defvar c-mode-common-hook @@ -2401,7 +2401,7 @@ overwritten when @ccmode{} gets loaded. 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 the Emacs manuals for more information on customizing Emacs via hooks. -@xref{Sample .emacs File}, for a more complete sample @file{.emacs} +@xref{Sample Init File}, for a more complete sample @file{.emacs} file. @example @@ -2423,7 +2423,7 @@ file. The variables that @ccmode{}'s style system control are called @dfn{style variables}. Note that style variables are ordinary Lisp variables, which the style system initializes; you can change their -values at any time (e.g. in a hook function). The style system can +values at any time (e.g., in a hook function). The style system can also set other variables, to some extent. @xref{Styles}. @dfn{Style variables} are handled specially in several ways: @@ -2528,11 +2528,11 @@ As an alternative to writing a style definition yourself, you can have already formatted piece of your code, @ref{Guessing the Style}. @menu -* Built-in Styles:: -* Choosing a Style:: -* Adding Styles:: -* Guessing the Style:: -* File Styles:: +* Built-in Styles:: +* Choosing a Style:: +* Adding Styles:: +* Guessing the Style:: +* File Styles:: @end menu @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -2678,9 +2678,9 @@ string. If none of the built-in styles is appropriate, you'll probably want to create a new @dfn{style definition}, possibly based on an existing style. To do this, put the new style's settings into a list with the -following format - the list can then be passed as an argument to the +following format; the list can then be passed as an argument to the function @code{c-add-style}. You can see an example of a style -definition in @ref{Sample .emacs File}. +definition in @ref{Sample Init File}. @cindex style definition @c @defvr {List} style definition @@ -2748,7 +2748,7 @@ deprecated and it might be removed from @ccmode{} in a future release. You should use @code{c-set-style} instead. The sample @file{.emacs} file provides a concrete example of how a new -style can be added and automatically set. @xref{Sample .emacs File}. +style can be added and automatically set. @xref{Sample Init File}. @end defun @defvar c-style-alist @@ -2891,7 +2891,7 @@ these offsets or the parent style name. The Emacs manual describes how you can customize certain variables on a per-file basis by including a @dfn{file local variable} block at the end -of the file (@pxref{File Variables,, Local Variables in Files, @emacsman{}, +of the file (@pxref{File Variables,, Local Variables in Files,@emacsman{}, @emacsmantitle{}}). So far, you've only seen a functional interface for setting styles in @@ -2915,9 +2915,9 @@ visit the file, @ccmode{} will automatically institute these offsets using @code{c-set-offset}. @end defvar -Note that file style settings (i.e. @code{c-file-style}) are applied +Note that file style settings (i.e., @code{c-file-style}) are applied before file offset settings -(i.e. @code{c-file-offsets})@footnote{Also, if either of these are set +(i.e., @code{c-file-offsets})@footnote{Also, if either of these are set in a file's local variable section, all the style variable values are made local to that buffer, even if @code{c-style-variables-are-local-p} is @code{nil}. Since this @@ -2995,7 +2995,7 @@ subsequent lines of C style block comments like @noindent with zero or more stars at the beginning of every line. If you change this variable, please make sure it still matches the comment starter -(i.e. @code{//}) of line comments @emph{and} the line prefix inside +(i.e., @code{//}) of line comments @emph{and} the line prefix inside block comments. @findex c-setup-paragraph-variables @@ -3018,7 +3018,7 @@ the line prefix from the other lines in the comment. @ccmode{} uses adaptive fill mode (@pxref{Adaptive Fill,,, emacs, GNU Emacs Manual}) to make Emacs correctly keep the line prefix when filling paragraphs. That also makes Emacs preserve the text -indentation @emph{inside} the comment line prefix. E.g. in the +indentation @emph{inside} the comment line prefix. E.g., in the following comment, both paragraphs will be filled with the left margins of the texts kept intact: @@ -3049,7 +3049,7 @@ by default). A patch for that is available from @c 2005/11/22: The above is still believed to be the case. which handles things like bulleted lists nicely. There's a convenience function @code{c-setup-filladapt} that tunes the relevant variables in -Filladapt for use in @ccmode{}. Call it from a mode hook, e.g. with +Filladapt for use in @ccmode{}. Call it from a mode hook, e.g., with something like this in your @file{.emacs}: @example @@ -3075,7 +3075,7 @@ then as the comment prefix. It defaults to @samp{* @code{c-block-comment-prefix} typically gets overridden by the default style @code{gnu}, which sets it to blank. You can see the line splitting effect described here by setting a different style, -e.g. @code{k&r} @xref{Choosing a Style}.}, which makes a comment +e.g., @code{k&r} @xref{Choosing a Style}.}, which makes a comment @example /* Got O(n^2) here, which is a Bad Thing. */ @@ -3102,7 +3102,7 @@ most common comment styles, see @ref{Line-Up Functions}. @defopt c-ignore-auto-fill @vindex ignore-auto-fill (c-) When auto fill mode is enabled, @ccmode{} can selectively ignore it -depending on the context the line break would occur in, e.g. to never +depending on the context the line break would occur in, e.g., to never break a line automatically inside a string literal. This variable takes a list of symbols for the different contexts where auto-filling never should occur: @@ -3117,7 +3117,7 @@ Inside a C++ style line comment. @item cpp Inside a preprocessor directive. @item code -Anywhere else, i.e. in normal code. +Anywhere else, i.e., in normal code. @end table By default, @code{c-ignore-auto-fill} is set to @code{(string cpp @@ -3133,8 +3133,9 @@ results in the current implementation. @end defopt @vindex comment-multi-line -If inside a comment and @code{comment-multi-line} (@pxref{Auto Fill,,, -@emacsman{}, @emacsmantitle{}} is non-@code{nil}, the indentation and +If inside a comment and @code{comment-multi-line} (@pxref{Auto +Fill,,,@emacsman{}, @emacsmantitle{}} is non-@code{nil}, the +indentation and line prefix are preserved. If inside a comment and @code{comment-multi-line} is @code{nil}, a new comment of the same type is started on the next line and indented as appropriate for @@ -3144,7 +3145,7 @@ Note that @ccmode{} sets @code{comment-multi-line} to @code{t} at startup. The reason is that @kbd{M-j} could otherwise produce sequences of single line block comments for texts that should logically be treated as one comment, and the rest of the paragraph handling code -(e.g. @kbd{M-q} and @kbd{M-a}) can't cope with that, which would lead to +(e.g., @kbd{M-q} and @kbd{M-a}) can't cope with that, which would lead to inconsistent behavior. @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -3160,7 +3161,7 @@ different ways, depending on the character just typed: @item Braces and Colons @ccmode{} first determines the syntactic context of the brace or colon (@pxref{Syntactic Symbols}), then looks for a corresponding element in -an alist. This element specifies where to put newlines - this is any +an alist. This element specifies where to put newlines: this is any combination of before and after the brace or colon. If no alist element is found, newlines are inserted both before and after a brace, but none are inserted around a colon. See @ref{Hanging Braces} and @@ -3261,7 +3262,7 @@ syntactic symbol, the associated value is either @code{nil}, a list, or a function. @table @asis -@item The Key - the syntactic symbol +@item The Key: the syntactic symbol The syntactic symbols that are useful as keys in this list are @code{brace-list-intro}, @code{statement-cont}, @code{inexpr-class-open}, @code{inexpr-class-close}, and all the @@ -3284,7 +3285,7 @@ lists in this regard, even though they do for normal indentation purposes. It's currently not possible to set automatic newlines on these constructs. -@item The associated value - the ``ACTION'' list or function +@item The associated value: the ``ACTION'' list or function The value associated with each syntactic symbol in this association list is called an @var{action}, which can be either a list or a function which returns a list. @xref{Custom Braces}, for how to use @@ -3373,12 +3374,12 @@ giving a syntactic symbol an @dfn{action function} in @cindex customization, brace hanging An action function is called with two arguments: the syntactic symbol -for the brace (e.g. @code{substatement-open}), and the buffer position +for the brace (e.g., @code{substatement-open}), and the buffer position where the brace has been inserted. Point is undefined on entry to an -action function, but the function must preserve it (e.g. by using +action function, but the function must preserve it (e.g., by using @code{save-excursion}). The return value should be a list containing some combination of @code{before} and @code{after}, including neither -of them (i.e. @code{nil}). +of them (i.e., @code{nil}). @defvar c-syntactic-context @vindex syntactic-context (c-) @@ -3454,7 +3455,7 @@ that the brace appears on a line by itself. Using 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} - When a colon is typed, @ccmode +@code{c-hanging-colons-alist}: when a colon is typed, @ccmode determines its syntactic context, looks this up in the alist @code{c-changing-colons-alist} and inserts up to two newlines accordingly. Here, however, If @ccmode fails to find an entry for a @@ -3465,17 +3466,17 @@ newly typed colon. @vindex hanging-colons-alist (c-) @table @asis -@item The Key - the syntactic symbol +@item The Key: the syntactic symbol The syntactic symbols appropriate as keys in this association list are: @code{case-label}, @code{label}, @code{access-label}, @code{member-init-intro}, and @code{inher-intro}. @xref{Syntactic Symbols}. Elements with any other value as a key get ignored. -@item The associate value - the ``ACTION'' list +@item The associated value: the ``ACTION'' list The @var{action} here is simply a list containing a combination of the symbols @code{before} and @code{after}. Unlike in @code{c-hanging-braces-alist}, functions as @var{actions} are not -supported - there doesn't seem to be any need for them. +supported; there doesn't seem to be any need for them. @end table @end defopt @@ -3559,7 +3560,7 @@ statements. In addition to @ccmode{} also comes with the criteria function @code{c-semi&comma-no-newlines-for-oneline-inliners}, which suppresses newlines after semicolons inside one-line inline method definitions -(e.g. in C++ or Java). +(e.g., in C++ or Java). @end defun @@ -3573,7 +3574,7 @@ newlines after semicolons inside one-line inline method definitions @dfn{Clean-ups} are mechanisms which remove (or exceptionally, add) whitespace in specific circumstances and are complementary to colon and brace hanging. You enable a clean-up by adding its symbol into -@code{c-cleanup-list}, e.g. like this: +@code{c-cleanup-list}, e.g., like this: @example (add-to-list 'c-cleanup-list 'space-before-funcall) @@ -3581,7 +3582,7 @@ and brace hanging. You enable a clean-up by adding its symbol into On the surface, it would seem that clean-ups overlap the functionality provided by the @code{c-hanging-*-alist} variables. Clean-ups, -however, are used to adjust code ``after-the-fact'', i.e. to adjust +however, are used to adjust code ``after-the-fact'', i.e., to adjust the whitespace in constructs later than when they were typed. Most of the clean-ups remove automatically inserted newlines, and are @@ -3792,7 +3793,7 @@ Auto-newline minor mode are enabled: @item space-before-funcall Insert a space between the function name and the opening parenthesis of a function call. This produces function calls in the style -mandated by the GNU coding standards, e.g. @samp{signal@w{ }(SIGINT, +mandated by the GNU coding standards, e.g., @samp{signal@w{ }(SIGINT, SIG_IGN)} and @samp{abort@w{ }()}. Clean up occurs when the opening parenthesis is typed. This clean-up should never be active in AWK Mode, since such a space is syntactically invalid for user defined @@ -3803,13 +3804,13 @@ Clean up any space between the function name and the opening parenthesis of a function call that has no arguments. This is typically used together with @code{space-before-funcall} if you prefer the GNU function call style for functions with arguments but think it looks ugly when -it's only an empty parenthesis pair. I.e. you will get @samp{signal +it's only an empty parenthesis pair. I.e., you will get @samp{signal (SIGINT, SIG_IGN)}, but @samp{abort()}. Clean up occurs when the closing parenthesis is typed. @item comment-close-slash When inside a block comment, terminate the comment when you type a slash -at the beginning of a line (i.e. immediately after the comment prefix). +at the beginning of a line (i.e., immediately after the comment prefix). This clean-up removes whitespace preceding the slash and if needed, inserts a star to complete the token @samp{*/}. Type @kbd{C-q /} in this situation if you just want a literal @samp{/} inserted. @@ -3903,18 +3904,18 @@ brief and typical example: @noindent The first thing inside each syntactic element is always a @dfn{syntactic symbol}. It describes the kind of construct that was -recognized, e.g. @code{statement}, @code{substatement}, +recognized, 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 their semantics. The remaining entries are various data associated -with the recognized construct - there might be zero or more. +with the recognized construct; there might be zero or more. @cindex anchor position Conceptually, a line of code is always indented relative to some position higher up in the buffer (typically the indentation of the previous line). That position is the @dfn{anchor position} in the syntactic element. If there is an entry after the syntactic symbol in -the syntactic element list then it's either nil or that anchor position. +the syntactic element list then it's either @code{nil} or that anchor position. Here is an example. Suppose we had the following code as the only thing in a C++ buffer @footnote{The line numbers in this and future examples @@ -3944,7 +3945,7 @@ position(s). @end table Running this command on line 4 of this example, we'd see in the echo -area@footnote{With a universal argument (i.e. @kbd{C-u C-c C-s}) the +area@footnote{With a universal argument (i.e., @kbd{C-u C-c C-s}) the analysis is inserted into the buffer as a comment on the current line.}: @@ -4212,7 +4213,7 @@ Method Symbols}. Lines continuing an Objective-C method call. @ref{Objective-C Method Symbols}. @item extern-lang-open -Brace that opens an @code{extern} block (e.g. @code{extern "C" +Brace that opens an @code{extern} block (e.g., @code{extern "C" @{...@}}). @ref{External Scope Symbols}. @item extern-lang-close Brace that closes an @code{extern} block. @ref{External Scope @@ -4239,10 +4240,10 @@ Analogous to the above, but for CORBA CIDL @code{composition} blocks. C++ template argument list continuations. @ref{Class Symbols}. @item inlambda Analogous to @code{inclass} syntactic symbol, but used inside lambda -(i.e. anonymous) functions. Only used in Pike mode. @ref{Statement +(i.e., anonymous) functions. Only used in Pike mode. @ref{Statement Block Symbols}. @item lambda-intro-cont -Lines continuing the header of a lambda function, i.e. between the +Lines continuing the header of a lambda function, i.e., between the @code{lambda} keyword and the function body. Only used in Pike mode. @ref{Statement Block Symbols}. @item inexpr-statement @@ -4257,19 +4258,19 @@ Java. @ref{Java Symbols}. @end table @menu -* Function Symbols:: -* Class Symbols:: -* Conditional Construct Symbols:: -* Switch Statement Symbols:: -* Brace List Symbols:: -* External Scope Symbols:: -* Paren List Symbols:: -* Literal Symbols:: -* Multiline Macro Symbols:: -* Objective-C Method Symbols:: +* Function Symbols:: +* Class Symbols:: +* Conditional Construct Symbols:: +* Switch Statement Symbols:: +* Brace List Symbols:: +* External Scope Symbols:: +* Paren List Symbols:: +* Literal Symbols:: +* Multiline Macro Symbols:: +* Objective-C Method Symbols:: * Java Symbols:: -* Statement Block Symbols:: -* K&R Symbols:: +* Statement Block Symbols:: +* K&R Symbols:: @end menu @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -4304,7 +4305,7 @@ top-level construct introduction so it has the syntax the brace that opens a top-level function definition. Line 9 is the corresponding @code{defun-close} since it contains the brace that closes the top-level -function definition. Line 4 is a @code{defun-block-intro}, i.e. it is +function definition. Line 4 is a @code{defun-block-intro}, i.e., it is the first line of a brace-block, enclosed in a top-level function definition. @@ -4353,7 +4354,7 @@ structs, and unions are essentially equivalent syntactically (and are very similar semantically), so replacing the @code{class} keyword in the example above with @code{struct} or @code{union} would still result in a syntax of @code{class-open} for line 4 @footnote{This is the case even -for C and Objective-C. For consistency, structs in all supported +for C and Objective-C@. For consistency, structs in all supported languages are syntactically equivalent to classes. Note however that the keyword @code{class} is meaningless in C and Objective-C.}. Similarly, line 18 is assigned @code{class-close} syntax. @@ -4564,7 +4565,7 @@ example: Here, lines 4, 7, and 10 are all assigned @code{case-label} syntax, while lines 5 and 8 are assigned @code{statement-case-intro}. Line 11 is treated slightly differently since it contains a brace that opens a -block --- it is given @code{statement-case-open} syntax. +block; it is given @code{statement-case-open} syntax. @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @node Brace List Symbols, External Scope Symbols, Switch Statement Symbols, Syntactic Symbols @@ -4661,7 +4662,7 @@ where @code{inextern-lang} is a modifier similar in purpose to There are various other top level blocks like @code{extern}, and they are all treated in the same way except that the symbols are named after -the keyword that introduces the block. E.g. C++ namespace blocks get +the keyword that introduces the block. E.g., C++ namespace blocks get the three symbols @code{namespace-open}, @code{namespace-close} and @code{innamespace}. The currently recognized top level blocks are: @@ -4792,7 +4793,7 @@ Line 2 is assigned the @code{func-decl-cont} syntax. @ssindex comment-intro Line 4 is assigned both @code{defun-block-intro} @emph{and} @code{comment-intro} syntax. A syntactic element with -@code{comment-intro} has no anchor point --- It is always accompanied +@code{comment-intro} has no anchor point. It is always accompanied by another syntactic element which does have one. @item @@ -4850,9 +4851,9 @@ Line 17 is assigned @code{stream-op} syntax. @ssindex cpp-define-intro @ssindex cpp-macro-cont Multiline preprocessor macro definitions are normally handled just like -other code, i.e. the lines inside them are indented according to the +other code, i.e., the lines inside them are indented according to the syntactic analysis of the preceding lines inside the macro. The first -line inside a macro definition (i.e. the line after the starting line of +line inside a macro definition (i.e., the line after the starting line of the cpp directive itself) gets @code{cpp-define-intro}. In this example: @example @@ -4868,7 +4869,7 @@ line 1 is given the syntactic symbol @code{cpp-macro}. The first line of a cpp directive is always given that symbol. Line 2 is given @code{cpp-define-intro}, so that you can give the macro body as a whole some extra indentation. Lines 3 through 5 are then analyzed as normal -code, i.e. @code{substatement} on lines 3 and 4, and @code{else-clause} +code, i.e., @code{substatement} on lines 3 and 4, and @code{else-clause} on line 5. The syntactic analysis inside macros can be turned off with @@ -4953,7 +4954,7 @@ the declaration is an annotation. There are a few occasions where a statement block might be used inside an expression. One is in C or C++ code using the gcc extension for -this, e.g: +this, e.g.: @example 1: int res = (@{ @@ -5018,7 +5019,7 @@ handled like this too. @ssindex knr-argdecl-intro @ssindex knr-argdecl Two other syntactic symbols can appear in old style, non-prototyped C -code @footnote{a.k.a. K&R C, or Kernighan & Ritchie C}: +code @footnote{a.k.a.@: K&R C, or Kernighan & Ritchie C}: @example 1: int add_three_integers(a, b, c) @@ -5032,7 +5033,7 @@ code @footnote{a.k.a. K&R C, or Kernighan & Ritchie C}: Here, line 2 is the first line in an argument declaration list and so is given the @code{knr-argdecl-intro} syntactic symbol. Subsequent lines -(i.e. lines 3 and 4 in this example), are given @code{knr-argdecl} +(i.e., lines 3 and 4 in this example), are given @code{knr-argdecl} syntax. @@ -5189,7 +5190,7 @@ indentation. @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! This section explains the structure and semantics of the style -variable @code{c-offset-alist}, the principal variable for configuring +variable @code{c-offsets-alist}, the principal variable for configuring indentation. Details of how to set it up, and its relationship to @ccmode{}'s style system are given in @ref{Style Variables}. @@ -5276,15 +5277,15 @@ values that the special symbols correspond to: @item + @code{c-basic-offset} times 1 @item - -@code{c-basic-offset} times -1 +@code{c-basic-offset} times @minus{}1 @item ++ @code{c-basic-offset} times 2 @item -- -@code{c-basic-offset} times -2 +@code{c-basic-offset} times @minus{}2 @item * @code{c-basic-offset} times 0.5 @item / -@code{c-basic-offset} times -0.5 +@code{c-basic-offset} times @minus{}0.5 @end table @item A vector @@ -5326,10 +5327,10 @@ Use the first offset that doesn't evaluate to @code{nil}. Subsequent elements of the list don't get evaluated. @item min Use the minimum of all the offsets. All must be either relative or -absolute - they can't be mixed. +absolute; they can't be mixed. @item max Use the maximum of all the offsets. All must be either relative or -absolute - they can't be mixed. +absolute; they can't be mixed. @item add Add all the evaluated offsets together. Exactly one of them may be absolute, in which case the result is absolute. Any relative offsets @@ -5487,7 +5488,7 @@ any problems writing custom line-up functions for AWK mode. The calling convention for line-up functions is described fully in @ref{Custom Line-Up}. Roughly speaking, the return value is either an offset itself (such as @code{+} or @code{[0]}) or it's @code{nil}, -meaning ``this function is inappropriate in this case - try a +meaning ``this function is inappropriate in this case; try a different one''. @xref{c-offsets-alist}. The subsections below describe all the standard line-up functions, @@ -5546,7 +5547,7 @@ parentheses and statements within brace blocks. @findex lineup-close-paren (c-) Line up the closing paren under its corresponding open paren if the open paren is followed by code. If the open paren ends its line, no -indentation is added. E.g: +indentation is added. E.g.: @example @group @@ -5600,7 +5601,7 @@ discussion of this ``DWIM'' measure. @defun c-indent-one-line-block @findex indent-one-line-block (c-) -Indent a one line block @code{c-basic-offset} extra. E.g: +Indent a one line block @code{c-basic-offset} extra. E.g.: @example @group @@ -5634,7 +5635,7 @@ which makes the function usable in list expressions. @defun c-indent-multi-line-block @findex indent-multi-line-block (c-) -Indent a multiline block @code{c-basic-offset} extra. E.g: +Indent a multiline block @code{c-basic-offset} extra. E.g.: @example @group @@ -5673,7 +5674,7 @@ block, which makes the function usable in list expressions. Line up statements for coding standards which place the first statement in a block on the same line as the block opening brace@footnote{Run-in style doesn't really work too well. You might need to write your own -custom line-up functions to better support this style.}. E.g: +custom line-up functions to better support this style.}. E.g.: @example @group @@ -5696,7 +5697,7 @@ expressions. @defun c-lineup-inexpr-block @findex lineup-inexpr-block (c-) This can be used with the in-expression block symbols to indent the -whole block to the column where the construct is started. E.g. for Java +whole block to the column where the construct is started. E.g., for Java anonymous 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 a @@ -5756,7 +5757,7 @@ indents relative to the surrounding block just like @defun c-lineup-whitesmith-in-block @findex lineup-whitesmith-in-block (c-) Line up lines inside a block in Whitesmith style. It's done in a way -that works both when the opening brace hangs and when it doesn't. E.g: +that works both when the opening brace hangs and when it doesn't. E.g.: @example @group @@ -5786,7 +5787,7 @@ In the first case the indentation is kept unchanged, in the second @code{inline-close}, @code{block-close}, @code{brace-list-close}, @code{brace-list-intro}, @code{statement-block-intro}, @code{arglist-intro}, @code{arglist-cont-nonempty}, -@code{arglist-close}, and all @code{in*} symbols, e.g. @code{inclass} +@code{arglist-close}, and all @code{in*} symbols, e.g., @code{inclass} and @code{inextern-lang}. @end defun @@ -5810,7 +5811,7 @@ Line up the current argument line under the first argument. As a special case, if an argument on the same line as the open parenthesis starts with a brace block opener, the indentation is @code{c-basic-offset} only. This is intended as a ``DWIM'' measure in -cases like macros that contain statement blocks, e.g: +cases like macros that contain statement blocks, e.g.: @example @group @@ -5846,7 +5847,7 @@ brace block. @defun c-lineup-multi-inher @findex lineup-multi-inher (c-) Line up the classes in C++ multiple inheritance clauses and member -initializers under each other. E.g: +initializers under each other. E.g.: @example @group @@ -5889,7 +5890,7 @@ Line up Java implements and extends declarations. If class names follow on the same line as the @samp{implements}/@samp{extends} keyword, they are lined up under each other. Otherwise, they are indented by adding @code{c-basic-offset} to the column of the keyword. -E.g: +E.g.: @example @group @@ -5923,7 +5924,7 @@ same line as the throws keyword, they are lined up under each other. Otherwise, they are indented by adding @code{c-basic-offset} to the column of the @samp{throws} keyword. The @samp{throws} keyword itself is also indented by @code{c-basic-offset} from the function declaration -start if it doesn't hang. E.g: +start if it doesn't hang. E.g.: @example @group @@ -6008,7 +6009,7 @@ line. @defun c-lineup-argcont @findex lineup-argcont (c-) -Line up a continued argument. E.g: +Line up a continued argument. E.g.: @example @group @@ -6046,7 +6047,7 @@ if ( x < 10 Since this function doesn't do anything for lines without an infix operator you typically want to use it together with some other lineup -settings, e.g. as follows (the @code{arglist-close} setting is just a +settings, e.g., as follows (the @code{arglist-close} setting is just a suggestion to get a consistent style): @example @@ -6066,7 +6067,7 @@ suggestion to get a consistent style): @defun c-lineup-assignments @findex lineup-assignments (c-) Line up the current line after the assignment operator on the first line -in the statement. If there isn't any, return nil to allow stacking with +in the statement. If there isn't any, return @code{nil} to allow stacking with other line-up functions. If the current line contains an assignment operator too, try to align it with the first one. @@ -6080,7 +6081,7 @@ operator too, try to align it with the first one. @defun c-lineup-math @findex lineup-math (c-) Like @code{c-lineup-assignments} but indent with @code{c-basic-offset} -if no assignment operator was found on the first line. I.e. this +if no assignment operator was found on the first line. I.e., this function is the same as specifying a list @code{(c-lineup-assignments +)}. It's provided for compatibility with old configurations. @@ -6095,7 +6096,7 @@ function is the same as specifying a list @code{(c-lineup-assignments Line up ``cascaded calls'' under each other. If the line begins with @code{->} or @code{.} and the preceding line ends with one or more function calls preceded by the same token, then the arrow is lined up -with the first of those tokens. E.g: +with the first of those tokens. E.g.: @example @group @@ -6116,7 +6117,7 @@ expressions. @defun c-lineup-streamop @findex lineup-streamop (c-) -Line up C++ stream operators (i.e. @samp{<<} and @samp{>>}). +Line up C++ stream operators (i.e., @samp{<<} and @samp{>>}). @workswith @code{stream-op}. @end defun @@ -6127,7 +6128,7 @@ Line up C++ stream operators (i.e. @samp{<<} and @samp{>>}). @findex lineup-string-cont (c-) Line up a continued string under the one it continues. A continued string in this sense is where a string literal follows directly after -another one. E.g: +another one. E.g.: @example @group @@ -6197,7 +6198,7 @@ to handle most of the common comment styles. Some examples: @end example The style variable @code{c-comment-prefix-regexp} is used to recognize -the comment line prefix, e.g. the @samp{*} that usually starts every +the comment line prefix, e.g., the @samp{*} that usually starts every line inside a comment. @workswith The @code{c} syntactic symbol. @@ -6236,7 +6237,7 @@ is equivalent to @code{(@r{@var{value}} . -1000)}. @findex lineup-knr-region-comment (c-) Line up a comment in the ``K&R region'' with the declaration. That is the region between the function or class header and the beginning of the -block. E.g: +block. E.g.: @example @group @@ -6276,7 +6277,7 @@ already has; think of it as an identity function for lineups. @defun c-lineup-cpp-define @findex lineup-cpp-define (c-) Line up macro continuation lines according to the indentation of the -construct preceding the macro. E.g: +construct preceding the macro. E.g.: @example @group @@ -6308,7 +6309,7 @@ int dribble() @{ If @code{c-syntactic-indentation-in-macros} is non-@code{nil}, the function returns the relative indentation to the macro start line to -allow accumulation with other offsets. E.g. in the following cases, +allow accumulation with other offsets. E.g., in the following cases, @code{cpp-define-intro} is combined with the @code{statement-block-intro} that comes from the @samp{do @{} that hangs on the @samp{#define} line: @@ -6383,7 +6384,7 @@ The @samp{x} line is aligned to the text after the @samp{:} on the This is done only in an @samp{asm} or @samp{__asm__} block, and only to those lines mentioned. Anywhere else @code{nil} is returned. The usual arrangement is to have this routine as an extra feature at the start of -arglist lineups, e.g. +arglist lineups, e.g.: @example (c-lineup-gcc-asm-reg c-lineup-arglist) @@ -6403,7 +6404,7 @@ that those lines could be analyzed as either topmost-intro-cont or statement-cont. It's used for @code{topmost-intro-cont} by default, but you might consider using @code{+} instead.}. For lines preceding a definition, zero is used. For other lines, @code{c-basic-offset} is -added to the indentation. E.g: +added to the indentation. E.g.: @example @group @@ -6469,17 +6470,18 @@ think is generally useful, you're very welcome to contribute it; please contact @email{bug-cc-mode@@gnu.org}. Line-up functions are passed a single argument, the syntactic -element (see below). The return value is a @code{c-offsets-alist} -offset specification: for example, an integer, a symbol such as -@code{+}, a vector, @code{nil}@footnote{Returning @code{nil} is useful -when the offset specification for a syntactic element is a list -containing the line-up function (@pxref{c-offsets-alist}).}, or even -another line-up function. Full details of these are in -@ref{c-offsets-alist}. +element (see below). At the time of the call, point will be somewhere +on the line being indented. The return value is a +@code{c-offsets-alist} offset specification: for example, an integer, +a symbol such as @code{+}, a vector, @code{nil}@footnote{Returning +@code{nil} is useful when the offset specification for a syntactic +element is a list containing the line-up function +(@pxref{c-offsets-alist}).}, or even another line-up function. Full +details of these are in @ref{c-offsets-alist}. Line-up functions must not move point or change the content of the buffer (except temporarily). They are however allowed to do -@dfn{hidden buffer changes}, i.e. setting text properties for caching +@dfn{hidden buffer changes}, i.e., setting text properties for caching purposes etc. Buffer undo recording is disabled while they run. The syntactic element passed as the parameter to a line-up function is @@ -6501,19 +6503,19 @@ earlier. Line-up functions are still passed this cons cell, so as to preserve compatibility with older configurations. In the future, we may decide to convert to using the full list format---you can prepare your setup for this by using the access functions -(@code{c-langelem-sym}, etc.) described below. +(@code{c-langelem-sym}, etc.)@: described below. @vindex c-syntactic-element @vindex syntactic-element (c-) @vindex c-syntactic-context @vindex syntactic-context (c-) -Some syntactic symbols, e.g. @code{arglist-cont-nonempty}, have more -info in the syntactic element - typically other positions that can be +Some syntactic symbols, e.g., @code{arglist-cont-nonempty}, have more +info in the syntactic element: typically other positions that can be interesting besides the anchor position. That info can't be accessed through the passed argument, which is a cons cell. Instead, you can get this information from the variable @code{c-syntactic-element}, which is dynamically bound to the complete syntactic element. The -variable @code{c-syntactic-context} might also be useful - it gets +variable @code{c-syntactic-context} might also be useful: it gets dynamically bound to the complete syntactic context. @xref{Custom Braces}. @@ -6530,7 +6532,7 @@ Return the syntactic symbol in @var{langelem}. @defun c-langelem-pos langelem @findex langelem-pos (c-) -Return the anchor position in @var{langelem}, or nil if there is none. +Return the anchor position in @var{langelem}, or @code{nil} if there is none. @end defun @defun c-langelem-col langelem &optional preserve-point @@ -6561,6 +6563,9 @@ custom line-up function associated with it. @section Other Special Indentations @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +To configure macros which you invoke without a terminating @samp{;}, +see @xref{Macros with ;}. + Here are the remaining odds and ends regarding indentation: @defopt c-label-minimum-indentation @@ -6590,9 +6595,9 @@ Line-Up}). When the indentation engine calls this hook, the variable @code{c-syntactic-context} is bound to the current syntactic context -(i.e. what you would get by typing @kbd{C-c C-s} on the source line. +(i.e., what you would get by typing @kbd{C-c C-s} on the source line. @xref{Custom Braces}.). Note that you should not change point or mark -inside a @code{c-special-indent-hook} function, i.e. you'll probably +inside a @code{c-special-indent-hook} function, i.e., you'll probably want to wrap your function in a @code{save-excursion}@footnote{The numerical value returned by @code{point} will change if you change the indentation of the line within a @code{save-excursion} form, but point @@ -6612,6 +6617,13 @@ functions to this hook, not remove them. @xref{Style Variables}. @cindex preprocessor directives @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +Preprocessor macros in C, C++, and Objective C (introduced by +@code{#define}) have a syntax different from the main language---for +example, a macro declaration is not terminated by a semicolon, and if +it is more than a line long, line breaks in it must be escaped with +backslashes. @ccmode{} has some commands to manipulate these, see +@ref{Macro Backslashes}. + Normally, the lines in a multi-line macro are indented relative to each other as though they were code. You can suppress this behavior by setting the following user option: @@ -6623,6 +6635,28 @@ is @code{nil}, all lines inside macro definitions are analyzed as @code{cpp-macro-cont}. @end defopt +Because a macro can expand into anything at all, near where one is +invoked @ccmode{} can only indent and fontify code heuristically. +Sometimes it gets it wrong. Usually you should try to design your +macros so that they ''look like ordinary code'' when you invoke them. +However, one situation is so common that @ccmode{} handles it +specially: that is when certain macros needn't (or mustn't) be +followed by a @samp{;}. You need to configure @ccmode{} to handle +these macros properly, see @ref{Macros with ;}. + +@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +@menu +* Macro Backslashes:: +* Macros with ;:: +@end menu + +@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +@node Macro Backslashes, Macros with ;, Custom Macros, Custom Macros +@comment node-name, next, previous, up +@section Customizing Macro Backslashes +@cindex @code{#define} +@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + @ccmode{} provides some tools to help keep the line continuation backslashes in macros neat and tidy. Their precise action is customized with these variables: @@ -6634,11 +6668,11 @@ customized with these variables: These variables control the alignment columns for line continuation backslashes in multiline macros. They are used by the functions that automatically insert or align such backslashes, -e.g. @code{c-backslash-region} and @code{c-context-line-break}. +e.g., @code{c-backslash-region} and @code{c-context-line-break}. @code{c-backslash-column} specifies the minimum column for the backslashes. If any line in the macro goes past this column, then the -next tab stop (i.e. next multiple of @code{tab-width}) in that line is +next tab stop (i.e., next multiple of @code{tab-width}) in that line is used as the alignment column for all the backslashes, so that they remain in a single column. However, if any lines go past @code{c-backslash-max-column} then the backslashes in the rest of the @@ -6654,7 +6688,7 @@ the automatic alignment of backslashes, use @vindex auto-align-backslashes (c-) Align automatically inserted line continuation backslashes if non-@code{nil}. When line continuation backslashes are inserted -automatically for line breaks in multiline macros, e.g. by +automatically for line breaks in multiline macros, e.g., by @code{c-context-line-break}, they are aligned with the other backslashes in the same macro if this flag is set. @@ -6665,7 +6699,63 @@ get aligned only when you explicitly invoke the command @end defopt @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -@node Odds and Ends, Sample .emacs File, Custom Macros, Top +@node Macros with ;, , Macro Backslashes, Custom Macros +@comment node-name, next, previous, up +@section Macros with semicolons +@cindex macros with semicolons +@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +Macros which needn't (or mustn't) be followed by a semicolon when you +invoke them, @dfn{macros with semicolons}, are very common. These can +cause @ccmode{} to parse the next line wrongly as a +@code{statement-cont} (@pxref{Function Symbols}) and thus mis-indent +it. + +You can prevent this by specifying which macros have semicolons. It +doesn't matter whether or not such a macro has a parameter list: + +@defopt c-macro-names-with-semicolon +@vindex macro-names-with-semicolon (c-) +This buffer-local variable specifies which macros have semicolons. +After setting its value, you need to call +@code{c-make-macro-with-semi-re} for it to take effect. It should be +set to one of these values: + +@table @asis +@item nil +There are no macros with semicolons. +@item a list of strings +Each string is the name of a macro with a semicolon. Only valid +@code{#define} names are allowed here. For example, to set the +default value, you could write the following into your @file{.emacs}: + +@example +(setq c-macro-names-with-semicolon + '("Q_OBJECT" "Q_PROPERTY" "Q_DECLARE" "Q_ENUMS")) +@end example + +@item a regular expression +This matches each symbol which is a macro with a semicolon. It must +not match any string which isn't a valid @code{#define} name. For +example: + +@example +(setq c-macro-names-with-semicolon + "\\<\\(CLEAN_UP_AND_RETURN\\|Q_[[:upper:]]+\\)\\>") +@end example +@end table +@end defopt + +@defun c-make-macro-with-semi-re +@findex make-macro-with-semi-re (c-) +Call this (non-interactive) function, which sets internal variables, +each time you change the value of +@code{c-macro-names-with-semicolon}. It takes no arguments, and its +return value has no meaning. This function is called by @ccmode{}'s +initialization code. +@end defun + +@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +@node Odds and Ends, Sample Init File, Custom Macros, Top @comment node-name, next, previous, up @chapter Odds and Ends @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -6677,7 +6767,7 @@ The stuff that didn't fit in anywhere else is documented here. Controls whether a final newline is enforced when the file is saved. The value is an association list that for each language mode specifies the value to give to @code{require-final-newline} (@pxref{Saving -Buffers,,, @lispref{}, @lispreftitle{}}) at mode initialization. If a +Buffers,,,@lispref{}, @lispreftitle{}}) at mode initialization. If a language isn't present on the association list, CC Mode won't touch @code{require-final-newline} in buffers for that language. @@ -6709,9 +6799,9 @@ anchoring position to indent the line in that case. @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -@node Sample .emacs File, Performance Issues, Odds and Ends, Top +@node Sample Init File, Performance Issues, Odds and Ends, Top @comment node-name, next, previous, up -@appendix Sample .emacs File +@appendix Sample Init File @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Here's a sample .emacs file fragment that might help you along the way. @@ -6768,7 +6858,7 @@ to change some of the actual values. @end verbatim @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -@node Performance Issues, Limitations and Known Bugs, Sample .emacs File, Top +@node Performance Issues, Limitations and Known Bugs, Sample Init File, Top @comment node-name, next, previous, up @chapter Performance Issues @cindex performance @@ -6783,9 +6873,9 @@ pathological code can cause @ccmode{} to perform fairly badly. This section gives some insight in how @ccmode{} operates, how that interacts with some coding styles, and what you can use to improve performance. -The overall goal is that @ccmode{} shouldn't be overly slow (i.e. take +The overall goal is that @ccmode{} shouldn't be overly slow (i.e., take more than a fraction of a second) in any interactive operation. -I.e. it's tuned to limit the maximum response time in single operations, +I.e., it's tuned to limit the maximum response time in single operations, which is sometimes at the expense of batch-like operations like reindenting whole blocks. If you find that @ccmode{} gradually gets slower and slower in certain situations, perhaps as the file grows in @@ -6803,7 +6893,7 @@ gets. @findex beginning-of-defun In earlier versions of @ccmode{}, we used to recommend putting the -opening brace of a top-level construct@footnote{E.g. a function in C, +opening brace of a top-level construct@footnote{E.g., a function in C, or outermost class definition in C++ or Java.} into the leftmost column. Earlier still, this used to be a rigid Emacs constraint, as embodied in the @code{beginning-of-defun} function. @ccmode now @@ -6845,10 +6935,10 @@ XEmacs users can set the variable tells @ccmode{} to use XEmacs-specific built-in functions which, in some circumstances, can locate the top-most opening brace much more quickly than @code{beginning-of-defun}. Preliminary testing has shown that for -styles where these braces are hung (e.g. most JDK-derived Java styles), +styles where these braces are hung (e.g., most JDK-derived Java styles), this hack can improve performance of the core syntax parsing routines from 3 to 60 times. However, for styles which @emph{do} conform to -Emacs' recommended style of putting top-level braces in column zero, +Emacs's recommended style of putting top-level braces in column zero, this hack can degrade performance by about as much. Thus this variable is set to @code{nil} by default, since the Emacs-friendly styles should be more common (and encouraged!). Note that this variable has no effect @@ -6856,7 +6946,7 @@ in Emacs since the necessary built-in functions don't exist (in Emacs 22.1 as of this writing in February 2007). Text properties are used to speed up skipping over syntactic whitespace, -i.e. comments and preprocessor directives. Indenting a line after a +i.e., comments and preprocessor directives. Indenting a line after a huge macro definition can be slow the first time, but after that the text properties are in place and it should be fast (even after you've edited other parts of the file and then moved back). @@ -6864,7 +6954,7 @@ edited other parts of the file and then moved back). Font locking can be a CPU hog, especially the font locking done on decoration level 3 which tries to be very accurate. Note that that level is designed to be used with a font lock support mode that only -fontifies the text that's actually shown, i.e. Lazy Lock or Just-in-time +fontifies the text that's actually shown, i.e., Lazy Lock or Just-in-time Lock mode, so make sure you use one of them. Fontification of a whole buffer with some thousand lines can often take over a minute. That is a known weakness; the idea is that it never should happen. @@ -6903,14 +6993,14 @@ geared to be used interactively to edit new code. There's currently no intention to change this goal. If you want to reformat old code, you're probably better off using some -other tool instead, e.g. @ref{Top, , GNU indent, indent, The `indent' +other tool instead, e.g., @ref{Top, , GNU indent, indent, The `indent' Manual}, which has more powerful reformatting capabilities than @ccmode{}. @item The support for C++ templates (in angle brackets) is not yet complete. When a non-nested template is used in a declaration, @ccmode{} indents -it and font-locks it OK. Templates used in expressions, and nested +it and font-locks it OK@. Templates used in expressions, and nested templates do not fare so well. Sometimes a workaround is to refontify the expression after typing the closing @samp{>}. @@ -6957,18 +7047,20 @@ Set the variable @code{c-basic-offset}. @xref{Getting Started}. @item @kindex RET @kindex C-j -@emph{Why doesn't the @kbd{RET} key indent the new line?} +@emph{Why does/doesn't the @kbd{RET} key indent the new line?} + +Emacs's convention used to be that @kbd{RET} just adds a newline, and that +@kbd{C-j} adds a newline and indents it. In Emacs-24.4, this convention was +reversed. -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-initialization-hook}: +If you use an older Emacs and you want @kbd{RET} do this +too, add this to your @code{c-initialization-hook}: @example (define-key c-mode-base-map "\C-m" 'c-context-line-break) @end example -@xref{Getting Started}. This is a very common question. If you want -this to be the default behavior, don't lobby us, lobby RMS! @t{:-)} +@xref{Getting Started}. This was a very common question. @item @emph{How do I stop my code jumping all over the place when I type?} @@ -7074,7 +7166,7 @@ to include any code that appears @emph{before} your bug example, if you think it might affect our ability to reproduce it. Please try to produce the problem in an Emacs instance without any -customizations loaded (i.e. start it with the @samp{-q --no-site-file} +customizations loaded (i.e., start it with the @samp{-q --no-site-file} arguments). If it works correctly there, the problem might be caused by faulty customizations in either your own or your site configuration. In that case, we'd appreciate it if you isolate the