Mercurial > emacs
comparison man/cc-mode.texi @ 89966:d8411455de48
Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-32
Merge from emacs--cvs-trunk--0
Patches applied:
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-486
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-487
Tweak permissions
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-488
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-489
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-490
Update from CVS: man/fixit.texi (Spelling): Fix typo.
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-491
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-494
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-495
Update from CVS: Add missing lisp/mh-e files
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-496
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-499
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-500
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-513
Update from CVS
author | Miles Bader <miles@gnu.org> |
---|---|
date | Fri, 27 Aug 2004 07:00:34 +0000 |
parents | 4c90ffeb71c5 b7446b6f097d |
children | eac554634bfa |
comparison
equal
deleted
inserted
replaced
89965:5e9097d1ad99 | 89966:d8411455de48 |
---|---|
1338 | 1338 |
1339 @findex c-setup-paragraph-variables | 1339 @findex c-setup-paragraph-variables |
1340 @findex setup-paragraph-variables (c-) | 1340 @findex setup-paragraph-variables (c-) |
1341 Also note that since @ccmode{} uses the value of | 1341 Also note that since @ccmode{} uses the value of |
1342 @code{c-comment-prefix-regexp} to set up several other variables at mode | 1342 @code{c-comment-prefix-regexp} to set up several other variables at mode |
1343 initialization, there won't have any effect if you change it inside a | 1343 initialization, there won't be any effect if you just change it inside a |
1344 @ccmode{} buffer. You need to call the command | 1344 @ccmode{} buffer. You need to call the command |
1345 @code{c-setup-paragraph-variables} to update those other variables with | 1345 @code{c-setup-paragraph-variables} too, to update those other variables with |
1346 the new value. That's also the case if you modify this variable in a | 1346 the new value. That's also the case if you modify this variable in a |
1347 mode hook, since @ccmode{} sets up all variables before calling them. | 1347 mode hook, since @ccmode{} sets up all variables before calling them. |
1348 @end defopt | 1348 @end defopt |
1349 | 1349 |
1350 @findex auto-fill-mode | 1350 @findex auto-fill-mode |
1413 situation when there's no hint about what the prefix should look like, | 1413 situation when there's no hint about what the prefix should look like, |
1414 namely when a block comment is broken for the first time. This style | 1414 namely when a block comment is broken for the first time. This style |
1415 variable@footnote{In versions before 5.26, this variable was called | 1415 variable@footnote{In versions before 5.26, this variable was called |
1416 @code{c-comment-continuation-stars}. As a compatibility measure, | 1416 @code{c-comment-continuation-stars}. As a compatibility measure, |
1417 @ccmode{} still uses the value on that variable if it's set.} is used | 1417 @ccmode{} still uses the value on that variable if it's set.} is used |
1418 then as the comment prefix. It defaults to @samp{* }, which makes a | 1418 then as the comment prefix. It defaults to @samp{* |
1419 comment | 1419 }@footnote{Actually, this default setting of |
1420 @code{c-block-comment-prefix} typically gets overriden by the default | |
1421 style @code{gnu}, which sets it to blank. You can see the line | |
1422 splitting effect described here by setting a different style, | |
1423 e.g. @code{k&r} @xref{Choosing a Style}}, which makes a comment | |
1420 | 1424 |
1421 @example | 1425 @example |
1422 /* Got O(n^2) here, which is a Bad Thing. */ | 1426 /* Got O(n^2) here, which is a Bad Thing. */ |
1423 @end example | 1427 @end example |
1424 | 1428 |
2055 | 2059 |
2056 @defopt c-tab-always-indent | 2060 @defopt c-tab-always-indent |
2057 @vindex tab-always-indent (c-) | 2061 @vindex tab-always-indent (c-) |
2058 @kindex TAB | 2062 @kindex TAB |
2059 @cindex literal | 2063 @cindex literal |
2060 This variable controls how @kbd{TAB} (@code{c-indent-command}) operates. | 2064 This variable controls how @kbd{TAB} (@code{c-indent-command}) |
2061 When it is @code{t}, @kbd{TAB} always indents the current line. When it | 2065 operates. When it is @code{t}, @kbd{TAB} always indents the current |
2062 is @code{nil}, the line is indented only if point is at the left margin, | 2066 line. When it is @code{nil}, the line is indented only if point is at |
2063 or on or before the first non-whitespace character on the line, | 2067 the left margin, or on or before the first non-whitespace character on |
2064 otherwise some whitespace is inserted. If this variable is the symbol | 2068 the line, otherwise some whitespace is inserted. If this variable is |
2065 @code{other}, then some whitespace is inserted only within strings and | 2069 some other value (not @code{nil} or @code{t}), then some whitespace is |
2066 comments (literals), and inside preprocessor directives, but the line is | 2070 inserted only within strings and comments (literals), but the line is |
2067 always reindented. | 2071 always reindented. |
2068 @end defopt | 2072 @end defopt |
2069 | 2073 |
2070 @defopt c-insert-tab-function | 2074 @defopt c-insert-tab-function |
2071 @vindex insert-tab-function (c-) | 2075 @vindex insert-tab-function (c-) |
2876 | 2880 |
2877 | 2881 |
2878 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 2882 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2879 @node Adding Styles, File Styles, Choosing a Style, Styles | 2883 @node Adding Styles, File Styles, Choosing a Style, Styles |
2880 @comment node-name, next, previous, up | 2884 @comment node-name, next, previous, up |
2881 @subsection Adding Styles | 2885 @subsection Adding and Amending Styles |
2882 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 2886 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2883 | 2887 |
2884 If none of the built-in styles is appropriate, you'll probably want to | 2888 If none of the built-in styles is appropriate, you'll probably want to |
2885 add a new @dfn{style definition}. Styles are kept in the | 2889 create a new @dfn{style definition}, possibly based on an existing |
2886 @code{c-style-alist} variable, but you should never modify this | 2890 style. To do this, put the new style's settings into a list with the |
2887 variable directly. Instead, @ccmode{} provides the function | 2891 following format - the list can then be passed as an argument to the |
2888 @code{c-add-style} that you can use to easily add new styles or change | 2892 function @code{c-add-style}: |
2889 existing styles: | 2893 |
2894 @cindex style definition | |
2895 @defvr {List} style definition | |
2896 ([@var{base-style}] [(@var{variable} . @var{value}) @dots{}]) | |
2897 | |
2898 Optional @var{base-style}, if present, must be a string which is the | |
2899 name of the @dfn{base style} from which this style inherits. At most | |
2900 one @var{base-style} is allowed in a style definition. If | |
2901 @var{base-style} is not specified, the style inherits from a table of | |
2902 default values@footnote{This table is stored internally in the | |
2903 variable c-fallback-style. It is computed during the initialisation | |
2904 of @ccmode{} from the factory defaults of the style variables and any | |
2905 global values they may have been given since starting Emacs.} instead. | |
2906 All styles eventually inherit from this internal table. Style loops | |
2907 generate errors. The list of pre-existing styles can be seen in | |
2908 @ref{Built-in Styles}. | |
2909 | |
2910 The dotted pairs (@var{variable} . @var{value}) each consist of a | |
2911 variable and the value it is to be set to when the style is later | |
2912 activated.@footnote{In certain circumstances, this value can get | |
2913 overridden by another value.} The variable can be either a @ccmode{} | |
2914 style variable or an arbitrary Emacs variable. In the latter case, it | |
2915 is @emph{not} made buffer local by the @ccmode{} style system. | |
2916 @end defvr | |
2917 | |
2918 Two variables are treated specially in the dotted pair list: | |
2919 | |
2920 @table @code | |
2921 @item c-offsets-alist | |
2922 The value is in turn a dotted list on the form | |
2923 | |
2924 (@var{syntactic-symbol} . @var{offset}) | |
2925 | |
2926 as described in @ref{Customizing Indentation}. These are passed to | |
2927 @code{c-set-offset} so there is no need to set every syntactic symbol in | |
2928 your style, only those that are different from the inherited style. | |
2929 | |
2930 @item c-special-indent-hook | |
2931 The value is added to @code{c-special-indent-hook} using | |
2932 @code{add-hook}, so any functions already on it are kept. If the value | |
2933 is a list, each element of the list is added with @code{add-hook}. | |
2934 @end table | |
2935 | |
2936 Styles are kept in the @code{c-style-alist} variable, but you | |
2937 should never modify this variable directly. Instead, @ccmode{} | |
2938 provides the function @code{c-add-style} for this purpose. | |
2890 | 2939 |
2891 @defun c-add-style stylename description &optional set-p | 2940 @defun c-add-style stylename description &optional set-p |
2892 @findex add-style (c-) | 2941 @findex add-style (c-) |
2893 Add or update a style. If @var{stylename} is not already in | 2942 Add or update a style called @var{stylename}, a string. |
2894 @code{c-style-alist} then a new style according to @var{description} | 2943 @var{description} is the new style definition in the form described |
2895 is added, otherwise the existing style is changed. If the optional | 2944 above. If @var{stylename} already exists in @code{c-style-alist} then |
2896 @var{set-p} is non-@code{nil} then the new style is applied to the | 2945 it is replaced by @var{description}. (Note, this replacement is |
2897 current buffer as well. | 2946 total. The old style is @emph{not} merged into the new one.) |
2898 | 2947 Otherwise, a new style is added. If the optional @var{set-p} is |
2899 @comment TBD: The next paragraph is bogus. I really need to better | 2948 non-@code{nil} then the new style is applied to the current buffer as |
2900 @comment document adding styles, including setting up inherited styles. | 2949 well. |
2901 | 2950 |
2902 The sample @file{.emacs} file provides a concrete example of how a new | 2951 The sample @file{.emacs} file provides a concrete example of how a new |
2903 style can be added and automatically set. @xref{Sample .emacs File}. | 2952 style can be added and automatically set. @xref{Sample .emacs File}. |
2904 @end defun | 2953 @end defun |
2905 | 2954 |
3414 (i.e., anonymous) functions. Only used in Pike mode. | 3463 (i.e., anonymous) functions. Only used in Pike mode. |
3415 @item lambda-intro-cont | 3464 @item lambda-intro-cont |
3416 Lines continuing the header of a lambda function, i.e., between the | 3465 Lines continuing the header of a lambda function, i.e., between the |
3417 @code{lambda} keyword and the function body. Only used in Pike mode. | 3466 @code{lambda} keyword and the function body. Only used in Pike mode. |
3418 @item inexpr-statement | 3467 @item inexpr-statement |
3419 A statement block inside an expression. The gcc C extension of this is | 3468 A statement block inside an expression. The gcc C and C++ extension for |
3420 recognized. It's also used for the special functions that takes a | 3469 this is recognized. It's also used for the special functions that take |
3421 statement block as an argument in Pike. | 3470 a statement block as an argument in Pike. |
3422 @item inexpr-class | 3471 @item inexpr-class |
3423 A class definition inside an expression. This is used for anonymous | 3472 A class definition inside an expression. This is used for anonymous |
3424 classes in Java. It's also used for anonymous array initializers in | 3473 classes in Java. It's also used for anonymous array initializers in |
3425 Java. | 3474 Java. |
3426 @end table | 3475 @end table |
4020 @code{inclass} symbol used in normal classes. Thus, the class will be | 4069 @code{inclass} symbol used in normal classes. Thus, the class will be |
4021 indented just like a normal class, with the added indentation given to | 4070 indented just like a normal class, with the added indentation given to |
4022 @code{inexpr-class}. | 4071 @code{inexpr-class}. |
4023 | 4072 |
4024 There are a few occasions where a statement block may be used inside an | 4073 There are a few occasions where a statement block may be used inside an |
4025 expression. One is in C code using the gcc extension for this, e.g: | 4074 expression. One is in C or C++ code using the gcc extension for this, |
4075 e.g: | |
4026 | 4076 |
4027 @example | 4077 @example |
4028 1: int res = (@{ | 4078 1: int res = (@{ |
4029 2: int y = foo (); int z; | 4079 2: int y = foo (); int z; |
4030 3: if (y > 0) z = y; else z = - y; | 4080 3: if (y > 0) z = y; else z = - y; |
5223 @vindex require-final-newline (c-) | 5273 @vindex require-final-newline (c-) |
5224 Controls whether a final newline is ensured when the file is saved. The | 5274 Controls whether a final newline is ensured when the file is saved. The |
5225 value is an association list that for each language mode specifies the | 5275 value is an association list that for each language mode specifies the |
5226 value to give to @code{require-final-newline} at mode initialization; | 5276 value to give to @code{require-final-newline} at mode initialization; |
5227 see that variable for details about the value. If a language isn't | 5277 see that variable for details about the value. If a language isn't |
5228 present on the association list, CC Mode won't set | 5278 present on the association list, CC Mode won't touch |
5229 @code{require-final-newline} in buffers for that language. | 5279 @code{require-final-newline} in buffers for that language. |
5230 | 5280 |
5231 The default is to set @code{require-final-newline} to @code{t} in the | 5281 The default is to set @code{require-final-newline} to @code{t} in the |
5232 languages that mandates that source files should end with newlines, | 5282 languages that mandates that source files should end with newlines, |
5233 i.e., C, C++ and Objective-C. | 5283 i.e., C, C++ and Objective-C. |
5482 in function calls instead of the macro expansions. Later, when the | 5532 in function calls instead of the macro expansions. Later, when the |
5483 interpreter tries to call the macro as a function, it shows this | 5533 interpreter tries to call the macro as a function, it shows this |
5484 (somewhat cryptic) error message.}. If you are using the standalone | 5534 (somewhat cryptic) error message.}. If you are using the standalone |
5485 @ccmode{} distribution, try recompiling it according to the instructions | 5535 @ccmode{} distribution, try recompiling it according to the instructions |
5486 in the @file{README} file. | 5536 in the @file{README} file. |
5537 | |
5538 @item | |
5539 @cindex open paren in column zero | |
5540 @emph{I have an open paren character at column zero inside a comment or | |
5541 multiline string literal, and it causes the fontification and/or | |
5542 indentation to go haywire. What gives?} | |
5543 | |
5544 It's due to the ad-hoc rule in (X)Emacs that such open parens always | |
5545 start defuns (which translates to functions, classes, namespaces or any | |
5546 other top-level block constructs in the @ccmode{} languages). | |
5547 @xref{Left Margin Paren,,, emacs, The Emacs Editor}, for details | |
5548 (@xref{Defuns,,, emacs, The Emacs Editor}, in the Emacs 20 manual). | |
5549 | |
5550 This heuristic is built into the core syntax analysis routines in | |
5551 (X)Emacs, so it's not really a @ccmode{} issue. However, in Emacs 21.4 | |
5552 it has become possible to turn it off@footnote{Using the variable | |
5553 @code{open-paren-in-column-0-is-defun-start}.} and @ccmode{} does so | |
5554 there since it got its own system to keep track of blocks. | |
5555 | |
5487 @end itemize | 5556 @end itemize |
5488 | 5557 |
5489 | 5558 |
5490 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 5559 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
5491 @node Getting the Latest CC Mode Release, Mailing Lists and Submitting Bug Reports, Frequently Asked Questions, Top | 5560 @node Getting the Latest CC Mode Release, Mailing Lists and Submitting Bug Reports, Frequently Asked Questions, Top |