18 |
|
|
19 |
|
|
20 |
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
21 |
@comment |
@comment |
22 |
@comment Texinfo manual for CC Mode |
@comment Texinfo manual for CC Mode |
23 |
@comment Generated from the original README file by Krishna Padmasola |
@comment Generated from the original README file by Krishna Padmasola |
24 |
@comment <krishna@earth-gw.njit.edu> |
@comment <krishna@earth-gw.njit.edu> |
28 |
@comment Martin Stjernholm |
@comment Martin Stjernholm |
29 |
@comment |
@comment |
30 |
@comment Maintained by Martin Stjernholm <bug-cc-mode@gnu.org> |
@comment Maintained by Martin Stjernholm <bug-cc-mode@gnu.org> |
31 |
@comment |
@comment |
32 |
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
33 |
|
|
34 |
@macro copyrightblurb |
@copying |
35 |
Copyright @copyright{} 1995, 96, 97, 98, 99, 2000, 01 Free Software Foundation, Inc. |
This manual is for CC Mode in Emacs. |
|
@end macro |
|
|
|
|
|
@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 The following lines inserts the copyright notice |
|
|
@comment into the Info file. |
|
|
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|
36 |
|
|
37 |
@ifnottex |
Copyright @copyright{} 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 Free |
38 |
Copyright @copyright{} 1995, 96, 97, 98, 99, 2000, 2001 Free Software Foundation, Inc. |
Software Foundation, Inc. |
39 |
|
|
40 |
|
@quotation |
41 |
Permission is granted to copy, distribute and/or modify this document |
Permission is granted to copy, distribute and/or modify this document |
42 |
under the terms of the GNU Free Documentation License, Version 1.1 or |
under the terms of the GNU Free Documentation License, Version 1.1 or |
43 |
any later version published by the Free Software Foundation; with the |
any later version published by the Free Software Foundation; with the |
55 |
Documentation License. If you want to distribute this document |
Documentation License. If you want to distribute this document |
56 |
separately from the collection, you can do so by adding a copy of the |
separately from the collection, you can do so by adding a copy of the |
57 |
license to the document, as described in section 6 of the license. |
license to the document, as described in section 6 of the license. |
58 |
@end ifnottex |
@end quotation |
59 |
|
@end copying |
60 |
|
|
61 |
|
|
62 |
|
@comment Info directory entry for use by install-info. The indentation |
63 |
|
@comment here is by request from the FSF folks. |
64 |
|
@dircategory Emacs |
65 |
|
@direntry |
66 |
|
* CC Mode: (ccmode). Emacs mode for editing C, C++, Objective-C, |
67 |
|
Java, Pike, and IDL code. |
68 |
|
@end direntry |
69 |
|
|
70 |
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
71 |
@comment TeX title page |
@comment TeX title page |
82 |
|
|
83 |
@page |
@page |
84 |
@vskip 0pt plus 1filll |
@vskip 0pt plus 1filll |
85 |
Copyright @copyright{} 1995, 96, 97, 98, 99, 2000, 2001 Free Software Foundation, Inc. |
@insertcopying |
|
@sp 1 |
|
|
Permission is granted to copy, distribute and/or modify this document |
|
|
under the terms of the GNU Free Documentation License, Version 1.1 or |
|
|
any later version published by the Free Software Foundation; with the |
|
|
Invariant Sections being ``The GNU Manifesto'', ``Distribution'' and |
|
|
``GNU GENERAL PUBLIC LICENSE'', 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'' in the Emacs manual. |
|
|
|
|
|
(a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify |
|
|
this GNU Manual, like GNU software. Copies published by the Free |
|
|
Software Foundation raise funds for GNU development.'' |
|
|
|
|
|
This document is part of a collection distributed under the GNU Free |
|
|
Documentation License. If you want to distribute this document |
|
|
separately from the collection, you can do so by adding a copy of the |
|
|
license to the document, as described in section 6 of the license. |
|
86 |
@end titlepage |
@end titlepage |
87 |
|
|
88 |
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
398 |
which is the brace just after the function header. |
which is the brace just after the function header. |
399 |
|
|
400 |
Here's another example: |
Here's another example: |
401 |
@example |
@example |
402 |
@group |
@group |
403 |
|
|
404 |
1: int add( int val, int incr, int doit ) |
1: int add( int val, int incr, int doit ) |
889 |
@example |
@example |
890 |
@group |
@group |
891 |
|
|
892 |
void spam( int i ) |
void spam( int i ) |
893 |
@{ |
@{ |
894 |
// this is a comment-only line... |
// this is a comment-only line... |
895 |
if( i == 7 ) // but this is not |
if( i == 7 ) // but this is not |
1480 |
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
1481 |
|
|
1482 |
The following list of commands re-indent C constructs. Note that when |
The following list of commands re-indent C constructs. Note that when |
1483 |
you change your coding style, either interactively or through some other |
you change your coding style, either interactively or through some other |
1484 |
means, your file does @emph{not} automatically get re-indented. You |
means, your file does @emph{not} automatically get re-indented. You |
1485 |
will need to execute one of the following commands to see the effects of |
will need to execute one of the following commands to see the effects of |
1486 |
your changes. |
your changes. |
1487 |
|
|
1488 |
@cindex GNU indent program |
@cindex GNU indent program |
1495 |
|
|
1496 |
Re-indenting large sections of code can take a long time. When |
Re-indenting large sections of code can take a long time. When |
1497 |
@ccmode{} reindents a region of code, it is essentially equivalent to |
@ccmode{} reindents a region of code, it is essentially equivalent to |
1498 |
hitting @kbd{TAB} on every line of the region. Especially vulnerable is |
hitting @kbd{TAB} on every line of the region. Especially vulnerable is |
1499 |
code generator output@footnote{In particular, I have had people |
code generator output@footnote{In particular, I have had people |
1500 |
complain about the speed with which @code{lex(1)} output is re-indented. |
complain about the speed with which @code{lex(1)} output is re-indented. |
1501 |
Lex, yacc, and other code generators usually output some pretty |
Lex, yacc, and other code generators usually output some pretty |
1589 |
@vindex c-progress-interval |
@vindex c-progress-interval |
1590 |
@vindex progress-interval (c-) |
@vindex progress-interval (c-) |
1591 |
@item c-progress-interval |
@item c-progress-interval |
1592 |
When indenting large regions of code, this variable controls how often a |
When indenting large regions of code, this variable controls how often a |
1593 |
progress message is displayed. Set this variable to @code{nil} to |
progress message is displayed. Set this variable to @code{nil} to |
1594 |
inhibit the progress messages, or set it to an integer which is the |
inhibit the progress messages, or set it to an integer which is the |
1595 |
interval in seconds that progress messages are displayed. |
interval in seconds that progress messages are displayed. |
1870 |
none of the list elements return a non-@code{nil} value, then an offset |
none of the list elements return a non-@code{nil} value, then an offset |
1871 |
of 0 (zero) is used@footnote{There is however a variable |
of 0 (zero) is used@footnote{There is however a variable |
1872 |
@code{c-strict-syntax-p} that, when set to non-@code{nil}, will cause an |
@code{c-strict-syntax-p} that, when set to non-@code{nil}, will cause an |
1873 |
error to be signalled in that case. It's now considered obsolete since |
error to be signaled in that case. It's now considered obsolete since |
1874 |
it doesn't work well with some of the alignment functions that now |
it doesn't work well with some of the alignment functions that now |
1875 |
returns @code{nil} instead of zero to be more usable in lists. You |
returns @code{nil} instead of zero to be more usable in lists. You |
1876 |
should therefore leave @code{c-strict-syntax-p} set to @code{nil}.}. |
should therefore leave @code{c-strict-syntax-p} set to @code{nil}.}. |
2280 |
@item |
@item |
2281 |
@code{bsd} --- Also known as ``Allman style'' after Eric Allman. |
@code{bsd} --- Also known as ``Allman style'' after Eric Allman. |
2282 |
|
|
2283 |
@cindex Whitesmith style |
@cindex Whitesmiths style |
2284 |
@item |
@item |
2285 |
@code{whitesmith} --- Popularized by the examples that came with |
@code{whitesmith} --- Popularized by the examples that came with |
2286 |
Whitesmiths C, an early commercial C compiler. |
Whitesmiths C, an early commercial C compiler. |
2355 |
|
|
2356 |
@item |
@item |
2357 |
When @code{c-default-style} is an association list, the current major |
When @code{c-default-style} is an association list, the current major |
2358 |
mode is looked up to find a style name string. In this case, this style |
mode is looked up to find a style name string. In this case, this style |
2359 |
is always used exactly as specified and an error will occur if the named |
is always used exactly as specified and an error will occur if the named |
2360 |
style does not exist. |
style does not exist. |
2361 |
|
|
2362 |
@item |
@item |
2363 |
If @code{c-default-style} is an association list, but the current major |
If @code{c-default-style} is an association list, but the current major |
2364 |
mode isn't found, then the special symbol @samp{other} is looked up. If |
mode isn't found, then the special symbol @samp{other} is looked up. If |
2365 |
this value is found, the associated style is used. |
this value is found, the associated style is used. |
2366 |
|
|
2367 |
@item |
@item |
2368 |
If @samp{other} is not found, then the @samp{gnu} style is used. |
If @samp{other} is not found, then the @samp{gnu} style is used. |
2369 |
|
|
2370 |
@item |
@item |
2371 |
In all cases, the style described in @code{c-default-style} is installed |
In all cases, the style described in @code{c-default-style} is installed |
2372 |
@emph{before} the language hooks are run, so you can always override |
@emph{before} the language hooks are run, so you can always override |
2373 |
this setting by including an explicit call to @code{c-set-style} in your |
this setting by including an explicit call to @code{c-set-style} in your |
2374 |
language mode hook, or in @code{c-mode-common-hook}. |
language mode hook, or in @code{c-mode-common-hook}. |
2375 |
|
|
2376 |
@end enumerate |
@end enumerate |
2533 |
like @ccmode{} to be a little more intelligent so that it aligns |
like @ccmode{} to be a little more intelligent so that it aligns |
2534 |
all the @samp{<<} symbols in lines 3 through 6. To do this, we have |
all the @samp{<<} symbols in lines 3 through 6. To do this, we have |
2535 |
to write a custom indentation function which finds the column of first |
to write a custom indentation function which finds the column of first |
2536 |
stream operator on the first line of the statement. Here is sample |
stream operator on the first line of the statement. Here is sample |
2537 |
lisp code implementing this: |
lisp code implementing this: |
2538 |
@example |
@example |
2539 |
@group |
@group |
2823 |
code, regardless of whether @kbd{TAB} or @kbd{M-;} were used. This |
code, regardless of whether @kbd{TAB} or @kbd{M-;} were used. This |
2824 |
behavior is controlled by the variable |
behavior is controlled by the variable |
2825 |
@code{c-indent-comments-syntactically-p}. When @code{nil} (the |
@code{c-indent-comments-syntactically-p}. When @code{nil} (the |
2826 |
default), @kbd{M-;} indents comment-only lines to @code{comment-column}, |
default), @kbd{M-;} indents comment-only lines to @code{comment-column}, |
2827 |
otherwise, they are indented just as they would be if @kbd{TAB} were |
otherwise, they are indented just as they would be if @kbd{TAB} were |
2828 |
typed. |
typed. |
2829 |
|
|
3374 |
@example |
@example |
3375 |
@group |
@group |
3376 |
|
|
3377 |
1: extern "C" |
1: extern "C" |
3378 |
2: @{ |
2: @{ |
3379 |
3: int thing_one( int ); |
3: int thing_one( int ); |
3380 |
4: int thing_two( double ); |
4: int thing_two( double ); |
3412 |
@noindent |
@noindent |
3413 |
line 2 is given the @code{namespace-open} syntax, while line 4 is given |
line 2 is given the @code{namespace-open} syntax, while line 4 is given |
3414 |
the @code{namespace-close} syntax. The analysis for line 3 yields: |
the @code{namespace-close} syntax. The analysis for line 3 yields: |
3415 |
@code{((innamespace) (topmost-intro . 17))}, where @code{innamespace} is |
@code{((innamespace) (topmost-intro . 17))}, where @code{innamespace} is |
3416 |
a modifier similar in purpose to @code{inextern-lang} and @code{inclass}. |
a modifier similar in purpose to @code{inextern-lang} and @code{inclass}. |
3417 |
|
|
3418 |
A number of syntactic symbols are associated with parenthesis lists, |
A number of syntactic symbols are associated with parenthesis lists, |
3423 |
|
|
3424 |
1: void a_function( int line1, |
1: void a_function( int line1, |
3425 |
2: int line2 ); |
2: int line2 ); |
3426 |
3: |
3: |
3427 |
4: void a_longer_function( |
4: void a_longer_function( |
3428 |
5: int line1, |
5: int line1, |
3429 |
6: int line2 |
6: int line2 |
3430 |
7: ); |
7: ); |
3431 |
8: |
8: |
3432 |
9: void call_them( int line1, int line2 ) |
9: void call_them( int line1, int line2 ) |
3433 |
10: @{ |
10: @{ |
3434 |
11: a_function( |
11: a_function( |
3435 |
12: line1, |
12: line1, |
3436 |
13: line2 |
13: line2 |
3437 |
14: ); |
14: ); |
3438 |
15: |
15: |
3439 |
16: a_longer_function( line1, |
16: a_longer_function( line1, |
3440 |
17: line2 ); |
17: line2 ); |
3441 |
18: @} |
18: @} |
3475 |
3: @{ |
3: @{ |
3476 |
4: /* this line starts a multi-line |
4: /* this line starts a multi-line |
3477 |
5: * comment. This line should get `c' syntax */ |
5: * comment. This line should get `c' syntax */ |
3478 |
6: |
6: |
3479 |
7: char* a_multiline_string = "This line starts a multi-line \ |
7: char* a_multiline_string = "This line starts a multi-line \ |
3480 |
8: string. This line should get `string' syntax."; |
8: string. This line should get `string' syntax."; |
3481 |
9: |
9: |
3482 |
10: note: |
10: note: |
3483 |
11: @{ |
11: @{ |
3484 |
12: #ifdef LOCK |
12: #ifdef LOCK |
3567 |
@end example |
@end example |
3568 |
@noindent |
@noindent |
3569 |
line 1 is given the syntactic symbol @code{cpp-macro}. This first line |
line 1 is given the syntactic symbol @code{cpp-macro}. This first line |
3570 |
of a macro is always given this symbol. The second and subsequent lines |
of a macro is always given this symbol. The second and subsequent lines |
3571 |
(e.g. lines 2 through 5) are given the @code{cpp-macro-cont} syntactic |
(e.g. lines 2 through 5) are given the @code{cpp-macro-cont} syntactic |
3572 |
symbol, with a relative buffer position pointing to the @code{#} which |
symbol, with a relative buffer position pointing to the @code{#} which |
3573 |
starts the macro definition. |
starts the macro definition. |
3778 |
@group |
@group |
3779 |
|
|
3780 |
main (int, |
main (int, |
3781 |
char ** |
char ** |
3782 |
) // c-lineup-close-paren |
) // c-lineup-close-paren |
3783 |
|
|
3784 |
@end group |
@end group |
3857 |
@group |
@group |
3858 |
|
|
3859 |
class Foo |
class Foo |
3860 |
extends |
extends |
3861 |
Bar // c-lineup-java-inher |
Bar // c-lineup-java-inher |
3862 |
|
|
3863 |
<--> c-basic-offset |
<--> c-basic-offset |
3921 |
|
|
3922 |
if (n > 0) |
if (n > 0) |
3923 |
@{m+=n; n=0;@} // c-indent-one-line-block |
@{m+=n; n=0;@} // c-indent-one-line-block |
3924 |
|
|
3925 |
<--> c-basic-offset |
<--> c-basic-offset |
3926 |
|
|
3927 |
@end group |
@end group |
3928 |
@end example |
@end example |
3954 |
@group |
@group |
3955 |
|
|
3956 |
int *foo[] = @{ |
int *foo[] = @{ |
3957 |
NULL, |
NULL, |
3958 |
@{17@}, // c-indent-multi-line-block |
@{17@}, // c-indent-multi-line-block |
3959 |
|
|
3960 |
@end group |
@end group |
4142 |
@findex c-lineup-whitesmith-in-block |
@findex c-lineup-whitesmith-in-block |
4143 |
@findex lineup-whitesmith-in-block (c-) |
@findex lineup-whitesmith-in-block (c-) |
4144 |
@item c-lineup-whitesmith-in-block |
@item c-lineup-whitesmith-in-block |
4145 |
Line up lines inside a block in Whitesmith style. It's done in a way |
Line up lines inside a block in Whitesmiths style. It's done in a way |
4146 |
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: |
4147 |
@example |
@example |
4148 |
@group |
@group |
4284 |
however it is recognized that sometimes you need speed and can sacrifice |
however it is recognized that sometimes you need speed and can sacrifice |
4285 |
some accuracy in indentation. The file @file{cc-lobotomy.el} contains |
some accuracy in indentation. The file @file{cc-lobotomy.el} contains |
4286 |
hacks that will ``dumb down'' @ccmode{} in some specific ways, making |
hacks that will ``dumb down'' @ccmode{} in some specific ways, making |
4287 |
that trade-off of accurancy for speed. I won't go into details of its |
that trade-off of accuracy for speed. I won't go into details of its |
4288 |
use here; you should read the comments at the top of the file, and look |
use here; you should read the comments at the top of the file, and look |
4289 |
at the variable @code{cc-lobotomy-pith-list} for details. |
at the variable @code{cc-lobotomy-pith-list} for details. |
4290 |
|
|
4440 |
XEmacs since 19.16. |
XEmacs since 19.16. |
4441 |
|
|
4442 |
Due to release schedule skew, it is likely that all of these Emacsen |
Due to release schedule skew, it is likely that all of these Emacsen |
4443 |
have old versions of @ccmode{} and so should be upgraded. Access to the |
have old versions of @ccmode{} and so should be upgraded. Access to the |
4444 |
@ccmode{} source code, as well as more detailed information on Emacsen |
@ccmode{} source code, as well as more detailed information on Emacsen |
4445 |
compatibility, etc. are all available via the Web at: |
compatibility, etc. are all available via the Web at: |
4446 |
|
|