comparison man/cc-mode.texi @ 181:bfd6434d15b3 r20-3b17

Import from CVS: tag r20-3b17
author cvs
date Mon, 13 Aug 2007 09:53:19 +0200
parents 6075d714658b
children e121b013d1f0
comparison
equal deleted inserted replaced
180:add28d59e586 181:bfd6434d15b3
44 44
45 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 45 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
46 @comment The title is printed in a large font. 46 @comment The title is printed in a large font.
47 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 47 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
48 48
49 @center @titlefont{CC Mode 5.14} 49 @center @titlefont{CC Mode 5.15}
50 @sp 2 50 @sp 2
51 @center @subtitlefont{A GNU Emacs mode for editing C and C-like languages} 51 @center @subtitlefont{A GNU Emacs mode for editing C and C-like languages}
52 @sp 2 52 @sp 2
53 @center Barry A. Warsaw 53 @center Barry A. Warsaw
54 54
178 @chapter Getting Connected 178 @chapter Getting Connected
179 @cindex Getting Connected 179 @cindex Getting Connected
180 180
181 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 181 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
182 182
183 If you got this version of @ccmode{} with Emacs, it should work just 183 If you got this version of @ccmode{} with Emacs or XEmacs, it should
184 fine right out of the box, and you can safely skip to the next chapter. 184 work just fine right out of the box. Note however that you may not have
185 Note however that you may not have the latest @ccmode{} release and may 185 the latest @ccmode{} release and may want to upgrade your copy.
186 want to upgrade your copy. See the @file{README} file, or the @ccmode{} 186
187 Web pages latest information on Emacs version compatibility, 187 If you are upgrading an existing @ccmode{} installation, please see the
188 @ref{Getting the latest CC Mode release}. 188 @file{README} file for installation details. @ccmode{} may not work
189 with older versions of Emacs or XEmacs. See the @ccmode{} release notes
190 Web pages for the latest information on Emacs version and package
191 compatibility, etc. The Web page locations are outlined in @ref{Getting
192 the latest CC Mode release}.
189 193
190 @cindex @file{cc-mode-18.el} file 194 @cindex @file{cc-mode-18.el} file
191 @emph{@ccmode{} no longer works with Emacs 18!} The 195 @emph{Note that @ccmode{} no longer works with Emacs 18!} The
192 @file{cc-mode-18.el} file is no longer distributed with @ccmode{}. If 196 @file{cc-mode-18.el} file is no longer distributed with @ccmode{}. If
193 you haven't upgraded from Emacs 18 by now, you are out of luck. The 197 you haven't upgraded from Emacs 18 by now, you are out of luck.
194 rest of these installation instructions assume you are using one of the 198
195 new Emacs or XEmacs releases, that already come with @ccmode{}. These 199 @findex c-version
196 instructions explain how to upgrade to use the latest @ccmode{} 200 @findex version (c-)
197 release. 201 You can find out what version of @ccmode{} you are using by visiting a C
198 202 file and entering @kbd{M-x c-version RET}. You should see this message in
199 @cindex .emacs file 203 the echo area:
200 204 @example
201 The first thing you will want to do is put the @ccmode{} source files in 205
202 a subdirectory somewhere on your @code{load-path} so Emacs can find it. 206 Using CC Mode version 5.XX
203 The distribution tarball unpacks into its own subdirectory,
204 e.g. @file{cc-mode/}. Assuming you unpacked the distribution in your
205 home directory, you should add the following to your @file{.emacs} file
206 in order to pick up the latest version of @ccmode{} over the one
207 distributed with your Emacs:
208
209 @example
210
211 (setq load-path (cons "~/cc-mode" load-path))
212
213 @end example
214
215 @cindex byte compile
216
217 Next you want to @dfn{byte compile} all the @ccmode{} source files.
218 @ccmode{} uses a lot of macros so if you don't byte compile it,
219 things will be unbearably slow. @emph{You can ignore all byte-compiler
220 warnings!} They are the result of the supporting different versions of
221 Emacs, and none of the warnings have any effect on operation. Let me say
222 this again: @strong{You really can ignore all byte-compiler warnings!}
223
224 To byte-compile the source files, first @code{cd} to the directory you
225 unpacked the tarball into. Then run the following command at your shell
226 prompt:
227
228 @example
229
230 % $EMACS -batch -no-site-file -q -l cc-make.el cc-*.el
231 207
232 @end example 208 @end example
233 209
234 @noindent 210 @noindent
235 where $EMACS is either @code{emacs} or @code{xemacs} depending on the 211 where @samp{XX} is the minor release number.
236 version you use. 212
237
238 Next time you start up Emacs you should be using the latest @ccmode{}.
239 You can test this by visiting a C file and hitting @kbd{M-x c-version
240 RET}; you should see this message in the echo area:
241 @example
242
243 Using CC Mode version 5.XX
244
245 @end example
246 213
247 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 214 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
248 @node New Indentation Engine, Minor Modes, Getting Connected, Top 215 @node New Indentation Engine, Minor Modes, Getting Connected, Top
249 @comment node-name, next, previous, up 216 @comment node-name, next, previous, up
250 217
588 @cindex electric characters 555 @cindex electric characters
589 556
590 @menu 557 @menu
591 * Auto-newline insertion:: 558 * Auto-newline insertion::
592 * Hungry-deletion of whitespace:: 559 * Hungry-deletion of whitespace::
560 * Auto-fill mode interaction::
593 @end menu 561 @end menu
594 562
595 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 563 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
596 @node Auto-newline insertion, Hungry-deletion of whitespace, , Minor Modes 564 @node Auto-newline insertion, Hungry-deletion of whitespace, , Minor Modes
597 @comment node-name, next, previous,up 565 @comment node-name, next, previous,up
625 @kindex C-u 593 @kindex C-u
626 No numeric argument was supplied to the command (i.e. it was typed as 594 No numeric argument was supplied to the command (i.e. it was typed as
627 normal, with no @kbd{C-u} prefix). 595 normal, with no @kbd{C-u} prefix).
628 596
629 @end itemize 597 @end itemize
630
631 @findex c-enable-//-in-c-mode
632 @findex enable-//-in-c-mode (c-)
633 Some characters are electric in some languages, and not in others. For
634 example, the second slash (@kbd{/}) of a C++ style line comment is
635 electric in @code{c++-mode}, @code{objc-mode}, @code{java-mode}, and
636 @code{idl-mode}, but not in @code{c-mode}@footnote{Ordinarily, @samp{//}
637 does not introduce a comment in @code{c-mode}. However, if you call the
638 function @code{c-enable-//-in-c-mode}, @code{c-mode} will recognize C++
639 style line comments. Note however that this is a global change which
640 will affect all your @code{c-mode} buffers.}.
641
642 598
643 @menu 599 @menu
644 * Hanging Braces:: 600 * Hanging Braces::
645 * Hanging Colons:: 601 * Hanging Colons::
646 * Hanging Semi-colons and commas:: 602 * Hanging Semi-colons and commas::
1026 982
1027 @end itemize 983 @end itemize
1028 984
1029 985
1030 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 986 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1031 @node Hungry-deletion of whitespace, , Auto-newline insertion, Minor Modes 987 @node Hungry-deletion of whitespace, Auto-fill mode interaction, Auto-newline insertion, Minor Modes
1032 @comment node-name, next, previous,up 988 @comment node-name, next, previous,up
1033 989
1034 @section Hungry-deletion of whitespace 990 @section Hungry-deletion of whitespace
1035 @cindex Hungry-deletion of whitespace 991 @cindex Hungry-deletion of whitespace
1036 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 992 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1096 @code{delete-char} by default. 1052 @code{delete-char} by default.
1097 1053
1098 However, if @code{delete-key-deletes-forward} is @code{nil}, or your 1054 However, if @code{delete-key-deletes-forward} is @code{nil}, or your
1099 Emacs does not support separation of @kbd{Backspace} and @kbd{DEL}, then 1055 Emacs does not support separation of @kbd{Backspace} and @kbd{DEL}, then
1100 @code{c-electric-delete} simply calls @code{c-electric-backspace}. 1056 @code{c-electric-delete} simply calls @code{c-electric-backspace}.
1057
1058
1059 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1060 @node Auto-fill mode interaction, , Hungry-deletion of whitespace, Minor Modes
1061 @comment node-name, next, previous,up
1062
1063 @section Auto-fill mode interaction
1064 @cindex Auto-fill mode interaction
1065 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1066
1067 One other note about minor modes is worth mentioning here. CC Mode now
1068 works much better with auto-fill mode (a standard Emacs minor mode) by
1069 correctly auto-filling both line (e.g. C++ style) and block (e.g. C
1070 style) oriented comments. When @code{auto-fill-mode} is enabled, line
1071 oriented comments will also be auto-filled by inserting a newline at the
1072 line break, and inserting @samp{//} at the start of the next line.
1073
1074 @vindex c-comment-continuation-stars
1075 @vindex comment-continuation-stars (c-)
1076 @vindex comment-line-break-function
1077 When auto-filling block oriented comments, the behavior is dependent on
1078 the value of the variable @code{c-comment-continuation-stars}. When
1079 this variable is @code{nil}, the old behavior for auto-filling C
1080 comments is in effect. In this case, the line is broken by closing the
1081 comment and starting a new comment on the next line.
1082
1083 If you set @code{c-comment-continuation-stars} to a string, then a long
1084 C block comment line is broken by inserting a newline at the line break
1085 position, and inserting this string at the beginning of the next comment
1086 line. The default value for @code{c-comment-continuation-stars} is
1087 @samp{* } (a star followed by a single space)@footnote{To get block
1088 comment continuation lines indented under the block comment starter
1089 (e.g. the @samp{/*}), it is not enough to set
1090 @code{c-comment-continuation-stars} to the empty string. You need to do
1091 this, but you also need to set the offset for the @code{c} syntactic
1092 symbol to be zero.}.
1101 1093
1102 1094
1103 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 1095 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1104 @node Commands, Customizing Indentation, Minor Modes, Top 1096 @node Commands, Customizing Indentation, Minor Modes, Top
1105 @comment node-name, next, previous,up 1097 @comment node-name, next, previous,up
1864 The Emacs manual describes how you can customize certain variables on a 1856 The Emacs manual describes how you can customize certain variables on a
1865 per-file basis by including a @dfn{Local Variable} block at the end of 1857 per-file basis by including a @dfn{Local Variable} block at the end of
1866 the file. So far, you've only seen a functional interface to @ccmode{} 1858 the file. So far, you've only seen a functional interface to @ccmode{}
1867 customization, which is highly inconvenient for use in a Local Variable 1859 customization, which is highly inconvenient for use in a Local Variable
1868 block. @ccmode{} provides two variables that make it easier for you to 1860 block. @ccmode{} provides two variables that make it easier for you to
1869 customize your style on a per-file basis@footnote{Note that file styles 1861 customize your style on a per-file basis@footnote{Note that this feature
1870 don't work with Emacs versions before XEmacs 19.12 and Emacs 19.29. 1862 doesn't work with Emacs versions before XEmacs 19.12 and Emacs 19.29.
1871 File styles work via the standard Emacs hook variable 1863 It works via the standard Emacs hook variable
1872 @code{hack-local-variables-hook}.}. 1864 @code{hack-local-variables-hook}.}
1873 1865
1874 @vindex c-file-style 1866 @vindex c-file-style
1875 @vindex file-style (c-) 1867 @vindex file-style (c-)
1876 @vindex c-file-offsets 1868 @vindex c-file-offsets
1877 @vindex file-offsets (c-) 1869 @vindex file-offsets (c-)
2321 @vindex c-indent-comments-syntactically-p 2313 @vindex c-indent-comments-syntactically-p
2322 @vindex indent-comments-syntactically-p (c-) 2314 @vindex indent-comments-syntactically-p (c-)
2323 @vindex comment-column 2315 @vindex comment-column
2324 2316
2325 Normally, the standard Emacs command @kbd{M-;} 2317 Normally, the standard Emacs command @kbd{M-;}
2326 (@code{indent-for-comment}) will indent comment-only lines to 2318 (@code{indent-for-comment}) will indent comment only lines to
2327 @code{comment-column}. Some users however, prefer that @kbd{M-;} act 2319 @code{comment-column}. Some users however, prefer that @kbd{M-;} act
2328 just like @kbd{TAB} for purposes of indenting comment-only lines; 2320 just like @kbd{TAB} for purposes of indenting comment-only lines;
2329 i.e. they want the comments to always indent as they would for normal 2321 i.e. they want the comments to always indent as they would for normal
2330 code, regardless of whether @kbd{TAB} or @kbd{M-;} were used. This 2322 code, regardless of whether @kbd{TAB} or @kbd{M-;} were used. This
2331 behavior is controlled by the variable 2323 behavior is controlled by the variable
2460 @item 2452 @item
2461 @code{extern-lang-close} --- brace that closes an external language block 2453 @code{extern-lang-close} --- brace that closes an external language block
2462 @item 2454 @item
2463 @code{inextern-lang} --- analogous to `inclass' syntactic symbol, but 2455 @code{inextern-lang} --- analogous to `inclass' syntactic symbol, but
2464 for @code{extern} blocks. 2456 for @code{extern} blocks.
2457 @item
2458 @code{template-args-cont} --- C++ template argument list continuations
2465 @end itemize 2459 @end itemize
2466 2460
2467 @cindex -open syntactic symbols 2461 @cindex -open syntactic symbols
2468 @cindex -close syntactic symbols 2462 @cindex -close syntactic symbols
2469 Most syntactic symbol names follow a general naming convention. When a 2463 Most syntactic symbol names follow a general naming convention. When a
2668 2662
2669 @end example 2663 @end example
2670 2664
2671 The @code{friend} syntactic symbol is a modifier that typically does not 2665 The @code{friend} syntactic symbol is a modifier that typically does not
2672 have a relative buffer position. 2666 have a relative buffer position.
2667
2668 Template definitions introduce yet another syntactic symbol:
2669
2670 @example
2671 @group
2672
2673 1: ThingManager <int,
2674 2: Framework::Callback *,
2675 3: Mutex> framework_callbacks;
2676
2677 @end group
2678 @end example
2679
2680 Here, line 1 is analyzed as a @code{topmost-intro}, but lines 2 and 3
2681 are both analyzed as @code{template-args-cont} lines.
2673 2682
2674 Here is another (totally contrived) example which illustrates how syntax 2683 Here is another (totally contrived) example which illustrates how syntax
2675 is assigned to various conditional constructs: 2684 is assigned to various conditional constructs:
2676 @example 2685 @example
2677 @group 2686 @group
3123 @key{RET} do this too by adding this to your 3132 @key{RET} do this too by adding this to your
3124 @code{c-mode-common-hook} (see the sample @file{.emacs} file 3133 @code{c-mode-common-hook} (see the sample @file{.emacs} file
3125 @ref{Sample .emacs File}): 3134 @ref{Sample .emacs File}):
3126 @example 3135 @example
3127 3136
3128 (define-key c-mode-map "\C-m" 'newline-and-indent) 3137 (define-key c-mode-base-map "\C-m" 'newline-and-indent)
3129 3138
3130 @end example 3139 @end example
3131 3140
3132 This is a very common question. If you want this to be the default 3141 This is a very common question. If you want this to be the default
3133 behavior, don't lobby me, lobby RMS! @code{:-)} 3142 behavior, don't lobby me, lobby RMS! @code{:-)}
3385 @node Variable Index, , Key Index, Top 3394 @node Variable Index, , Key Index, Top
3386 @comment node-name, next, previous, up 3395 @comment node-name, next, previous, up
3387 @unnumbered Variable Index 3396 @unnumbered Variable Index
3388 @c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 3397 @c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
3389 3398
3399 @ifinfo
3400
3401 @end ifinfo
3390 Since all @ccmode{} variables are prepended with the string 3402 Since all @ccmode{} variables are prepended with the string
3391 @samp{c-}, each appears under its @code{c-@var{<thing>}} name and its 3403 @samp{c-}, each appears under its @code{c-@var{<thing>}} name and its
3392 @code{@var{<thing>} (c-)} name. 3404 @code{@var{<thing>} (c-)} name.
3393 @iftex 3405 @iftex
3394 @sp 2 3406 @sp 2
3395 @end iftex 3407 @end iftex
3396 @printindex vr 3408 @printindex vr
3409 @page
3397 @summarycontents 3410 @summarycontents
3398 @contents 3411 @contents
3399 @bye 3412 @bye