Mercurial > hg > xemacs-beta
comparison man/cc-mode.texi @ 2:ac2d302a0011 r19-15b2
Import from CVS: tag r19-15b2
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:46:35 +0200 |
parents | 376386a54a3c |
children | e04119814345 |
comparison
equal
deleted
inserted
replaced
1:c0c6a60d29db | 2:ac2d302a0011 |
---|---|
15 | 15 |
16 | 16 |
17 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 17 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
18 @comment | 18 @comment |
19 @comment texinfo manual for @file{cc-mode.el} version 4 | 19 @comment texinfo manual for @file{cc-mode.el} version 4 |
20 @comment manual version: 2.35 | 20 @comment manual version: 2.55 |
21 @comment generated from the original README file by Krishna Padmasola | 21 @comment generated from the original README file by Krishna Padmasola |
22 @comment <krishna@earth-gw.njit.edu> | 22 @comment <krishna@earth-gw.njit.edu> |
23 @comment | 23 @comment |
24 @comment Barry A. Warsaw <bwarsaw@cnri.reston.va.us> | 24 @comment Barry A. Warsaw <bwarsaw@cnri.reston.va.us> |
25 @comment Last modification: 1996/01/19 20:50:48 | 25 @comment Last modification: 1996/08/21 19:29:16 |
26 @comment | 26 @comment |
27 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 27 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
28 | 28 |
29 | 29 |
30 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 30 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
31 @comment The following line inserts the copyright notice | 31 @comment The following line inserts the copyright notice |
32 @comment into the Info file. | 32 @comment into the Info file. |
33 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 33 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
34 | 34 |
35 @ifinfo | 35 @ifinfo |
36 Copyright @copyright{} 1995 Free Software Foundation, Inc. | 36 Copyright @copyright{} 1995, 1996 Free Software Foundation, Inc. |
37 @end ifinfo | 37 @end ifinfo |
38 | 38 |
39 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 39 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
40 @comment !!!The titlepage section does not appear in the Info file.!!! | 40 @comment !!!The titlepage section does not appear in the Info file.!!! |
41 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 41 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
48 @comment The title is printed in a large font. | 48 @comment The title is printed in a large font. |
49 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 49 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
50 | 50 |
51 @center @titlefont{CC-MODE Version 4} | 51 @center @titlefont{CC-MODE Version 4} |
52 @sp 2 | 52 @sp 2 |
53 @center A GNU Emacs mode for editing C, C++, and Objective-C code. | 53 @center A GNU Emacs mode for editing C, C++, Objective-C, and Java code. |
54 @center (manual revision: 2.35) | 54 @center (manual revision: 2.55) |
55 @sp 2 | 55 @sp 2 |
56 @center Barry A. Warsaw | 56 @center Barry A. Warsaw |
57 | 57 |
58 | 58 |
59 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 59 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
82 @menu | 82 @menu |
83 * Introduction:: | 83 * Introduction:: |
84 * Getting Connected:: | 84 * Getting Connected:: |
85 * New Indentation Engine:: | 85 * New Indentation Engine:: |
86 * Minor Modes:: | 86 * Minor Modes:: |
87 * Indentation Commands:: | 87 * Commands:: |
88 * Customizing Indentation:: | 88 * Customizing Indentation:: |
89 * Syntactic Symbols:: | 89 * Syntactic Symbols:: |
90 * Performance Issues:: | 90 * Performance Issues:: |
91 * Frequently Asked Questions:: | 91 * Frequently Asked Questions:: |
92 * Getting the latest cc-mode release:: | 92 * Getting the latest cc-mode release:: |
93 * Sample .emacs File:: | 93 * Sample .emacs File:: |
94 * Requirements:: | |
95 * Limitations and Known Bugs:: | 94 * Limitations and Known Bugs:: |
96 * Mailing Lists and Submitting Bug Reports:: | 95 * Mailing Lists and Submitting Bug Reports:: |
97 * Concept Index:: | 96 * Concept Index:: |
98 * Command Index:: Command Index | 97 * Command Index:: Command Index |
99 * Key Index:: Key Index | 98 * Key Index:: Key Index |
121 | 120 |
122 @code{cc-mode} version 4 supports the editing of K&R and ANSI C, | 121 @code{cc-mode} version 4 supports the editing of K&R and ANSI C, |
123 @dfn{ARM} @footnote{i.e. ``The Annotated C++ Reference Manual'', by | 122 @dfn{ARM} @footnote{i.e. ``The Annotated C++ Reference Manual'', by |
124 Ellis and Stroustrup.} C++, Objective-C, and Java files. In this way, | 123 Ellis and Stroustrup.} C++, Objective-C, and Java files. In this way, |
125 you can easily set up consistent coding styles for use in editing all C, | 124 you can easily set up consistent coding styles for use in editing all C, |
126 C++, Objective-C, and Java programs. | 125 C++, Objective-C, and Java programs. @code{cc-mode} does @emph{not} |
126 handle font-locking (a.k.a. syntax coloring, keyword highlighting) or | |
127 anything of that nature, for any of the 4 modes. Those are handled by | |
128 other Emacs packages. | |
127 | 129 |
128 This manual will describe the following: | 130 This manual will describe the following: |
129 | 131 |
130 @itemize @bullet | 132 @itemize @bullet |
131 @item | 133 @item |
141 | 143 |
142 Note that the name of this file is @file{cc-mode.el}, and I'll often | 144 Note that the name of this file is @file{cc-mode.el}, and I'll often |
143 refer to the package as @code{cc-mode}, but there really is no top level | 145 refer to the package as @code{cc-mode}, but there really is no top level |
144 @code{cc-mode} entry point. I call it @code{cc-mode} simply to | 146 @code{cc-mode} entry point. I call it @code{cc-mode} simply to |
145 differentiate it from @file{c-mode.el}. All of the variables, commands, | 147 differentiate it from @file{c-mode.el}. All of the variables, commands, |
146 and functions in @code{cc-mode} are prefixed with @code{c-<thing>}, and | 148 and functions in @code{cc-mode} are prefixed with |
147 @code{c-mode}, @code{c++-mode}, @code{objc-mode}, and @code{java-mode} | 149 @code{c-@var{<thing>}}, and @code{c-mode}, @code{c++-mode}, |
148 entry points are provided. This file is intended to be a replacement | 150 @code{objc-mode}, and @code{java-mode} entry points are provided. This |
149 for @file{c-mode.el} and @file{c++-mode.el}. | 151 file is intended to be a replacement for @file{c-mode.el} and |
152 @file{c++-mode.el}. | |
150 | 153 |
151 @findex c-version | 154 @findex c-version |
152 The major version number was incremented to 4 with the addition of | 155 The major version number was incremented to 4 with the addition of |
153 @code{objc-mode}. To find the minor revision number of this release, use | 156 @code{objc-mode}. To find the minor revision number of this release, use |
154 @kbd{M-x c-version RET}. Work has already begun on @code{cc-mode} | 157 @kbd{M-x c-version RET}. |
155 version 5, in which Emacs 18 will not be supported. | 158 |
156 | 159 As of this writing (20-Aug-1996), both Emacs 19.33 and XEmacs 19.14 are |
157 As of this writing (19-Jan-1996), both Emacs 19.30 and XEmacs 19.13 are | 160 distributed with @code{cc-mode}, however neither have the very latest |
158 distributed with @code{cc-mode}. Emacs 19.31 and XEmacs 19.14 will both | 161 version. In all likelihood, Emacs 19.34 and XEmacs 19.15 will contain |
159 contain the latest version of cc-mode when it is released. If you are | 162 the latest version of @code{cc-mode}. You may therefore, want to |
160 running older versions of these Emacsen, you may want to upgrade your | 163 upgrade your copy of @code{cc-mode}. See @ref{Getting the latest |
161 copy of @code{cc-mode}. See @ref{Getting the latest cc-mode release}. | 164 cc-mode release}. |
162 | 165 |
163 @cindex @file{cc-compat.el} file | 166 @cindex @file{cc-compat.el} file |
164 This distribution also contains a file called @file{cc-compat.el} | 167 This distribution also contains a file called @file{cc-compat.el} which |
165 which should ease your transition from BOCM to @code{cc-mode}. It | 168 should ease your transition from BOCM to @code{cc-mode}. It currently |
166 currently comes unguaranteed and unsupported, but this may change for | 169 comes unguaranteed and unsupported, but this may change for future |
167 future versions. | 170 versions. If you have a BOCM configuration you are really happy with, |
171 and want to postpone learning how to configure @code{cc-mode}, take a | |
172 look at that file. It maps BOCM configuration variables to | |
173 @code{cc-mode}'s new indentation model. | |
168 | 174 |
169 A special word of thanks goes to Krishna Padmasola for his work in | 175 A special word of thanks goes to Krishna Padmasola for his work in |
170 converting the original @file{README} file to texinfo format. | 176 converting the original @file{README} file to texinfo format. |
171 @code{cc-mode} users have been clamoring for a manual for a long time, | |
172 and thanks to Krishna, it is now available <clap> <clap> <clap>! | |
173 @code{:-)} | |
174 | 177 |
175 | 178 |
176 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 179 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
177 | 180 |
178 @node Getting Connected, New Indentation Engine, Introduction, Top | 181 @node Getting Connected, New Indentation Engine, Introduction, Top |
181 @cindex Getting Connected | 184 @cindex Getting Connected |
182 | 185 |
183 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 186 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
184 | 187 |
185 @file{cc-mode.el} works well with the 2 main branches of Emacs 19: | 188 @file{cc-mode.el} works well with the 2 main branches of Emacs 19: |
186 XEmacs and the Emacs 19 maintained by the FSF. Emacs 19 users will want | 189 XEmacs, maintained by @code{xemacs.org} and the Emacs 19 maintained by |
187 to use Emacs version 19.21 or better, XEmacs users will want 19.6 or | 190 the Free Software Foundation. Emacs 19 users will want to use Emacs |
188 better. Earlier versions of these Emacsen have deficiencies and/or bugs | 191 version 19.21 or better, XEmacs users will want 19.6 or better. Earlier |
189 which will adversely affect the performance and usability of | 192 versions of these Emacsen have deficiencies and/or bugs which will |
190 @code{cc-mode}. | 193 adversely affect the performance and usability of @code{cc-mode}. You |
194 are better off just getting the latest version of Emacs or XEmacs. | |
191 | 195 |
192 @cindex @file{cc-mode-18.el} file | 196 @cindex @file{cc-mode-18.el} file |
193 Similarly if you use the @file{cc-mode-18.el} compatibility file, | 197 @file{cc-mode.el} will work with Emacs 18 if you use the |
194 @file{cc-mode.el} will work with Emacs 18, but only moderately well. A | 198 @file{cc-mode-18.el} compatibility file, but only moderately well. A |
195 word of warning though, @emph{Emacs 18 lacks some fundamental | 199 word of warning though, @emph{Emacs 18 lacks some fundamental |
196 functionality and that ultimately means using Emacs 18 is a losing | 200 functionality and ultimately, using Emacs 18 is a losing |
197 battle}. Hence @code{cc-mode} under Emacs 18 is no longer supported and | 201 battle}. Hence @code{cc-mode} under Emacs 18 is no longer supported and |
198 it is highly recommended that you upgrade to Emacs 19. If you use | 202 it is highly recommended that you upgrade to Emacs 19. If you use |
199 @code{cc-mode} under Emacs 18, you're on your own. With @code{cc-mode} | 203 @code{cc-mode} under Emacs 18, you're on your own. With @code{cc-mode} |
200 version 5, Emacs 18 support will be dropped altogether. | 204 version 5, Emacs 18 support will be dropped altogether. |
201 | 205 |
202 Note that as of XEmacs 19.13 and Emacs 19.30, your Emacs already comes | 206 Note that as of XEmacs 19.13 and Emacs 19.30, your Emacs already comes |
203 with @code{cc-mode} version 4 preconfigured for your use. You should be | 207 with @code{cc-mode} version 4 preconfigured for your use. You should be |
204 able to safely skip the rest of the setup information in this chapter. | 208 able to safely skip the rest of the setup information in this chapter, |
209 unless you want to install the latest version of @code{cc-mode} into one | |
210 of these Emacsen. | |
205 | 211 |
206 @cindex @file{.emacs} file | 212 @cindex @file{.emacs} file |
207 The first thing you will want to do is put @file{cc-mode.el} somewhere | 213 The first thing you will want to do is put @file{cc-mode.el} somewhere |
208 on your @code{load-path} so Emacs can find it. Do a @kbd{C-h v | 214 on your @code{load-path} so Emacs can find it. Do a @kbd{C-h v |
209 load-path RET} to see all the directories Emacs looks at when loading a | 215 load-path RET} to see all the directories Emacs looks at when loading a |
288 | 294 |
289 @end group | 295 @end group |
290 @end example | 296 @end example |
291 | 297 |
292 Alternatively, if you want to make sure @code{cc-mode} is loaded when | 298 Alternatively, if you want to make sure @code{cc-mode} is loaded when |
293 Emacs starts up, you could use this line instead of the three autoloads | 299 Emacs starts up, you could use this line instead of the autoloads |
294 above: | 300 above: |
295 @example | 301 @example |
296 | 302 |
297 (require 'cc-mode) | 303 (require 'cc-mode) |
298 | 304 |
299 @end example | 305 @end example |
300 | 306 |
301 Next, you will want to set up Emacs so that it edits C files in | 307 Next, you will want to set up Emacs so that it edits C files in |
302 @code{c-mode}, C++ files in @code{c++-mode}, and Objective-C files in | 308 @code{c-mode}, C++ files in @code{c++-mode}, Objective-C files in |
303 @code{objc-mode}. All users should add the following to their | 309 @code{objc-mode}, and Java files in @code{java-mode}. You should |
304 @file{.emacs} file. Note that this assumes you'll be editing @code{.h} | 310 add the following to your @file{.emacs} file, which assumes |
305 and @code{.c} files as C, @code{.hh}, @code{.cc}, @code{.H}, and | 311 you'll be editing @code{.h} and @code{.c} files as C, @code{.hh}, |
306 @code{.C} files as C++, @code{.m} files as Objective-C, and @code{.java} | 312 @code{.cc}, @code{.H}, and @code{.C} files as C++, @code{.m} files as |
307 files as Java code. YMMV: | 313 Objective-C, and @code{.java} files as Java code. YMMV: |
308 @example | 314 @example |
309 @group | 315 @group |
310 | 316 |
311 (setq auto-mode-alist | 317 (setq auto-mode-alist |
312 (append | 318 (append |
324 @end example | 330 @end example |
325 | 331 |
326 You may already have some or all of these settings on your | 332 You may already have some or all of these settings on your |
327 @code{auto-mode-alist}, but it won't hurt to put them on there again. | 333 @code{auto-mode-alist}, but it won't hurt to put them on there again. |
328 | 334 |
329 That's all you need -- I know, I know, it sounds like a lot @code{:-)}, | 335 That's all you need --- I know, I know, it sounds like a lot @code{:-)}, |
330 but after you've done all this, you should only need to quit and restart | 336 but after you've done all this, you should only need to quit and restart |
331 Emacs. The next time you visit a C, C++, Objective-C, or Java file you | 337 Emacs. The next time you visit a C, C++, Objective-C, or Java file you |
332 should be using @code{cc-mode}. You can check this easily by hitting | 338 should be using @code{cc-mode}. You can check this easily by hitting |
333 @kbd{M-x c-version RET} in the @code{c-mode}, @code{c++-mode}, or | 339 @kbd{M-x c-version RET} in the @code{c-mode}, @code{c++-mode}, or |
334 @code{objc-mode} buffer. You should see this message in the echo area: | 340 @code{objc-mode} buffer. You should see this message in the echo area: |
339 Where @var{xxx} is the latest release minor number. | 345 Where @var{xxx} is the latest release minor number. |
340 | 346 |
341 @end example | 347 @end example |
342 | 348 |
343 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 349 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
350 @node New Indentation Engine, Minor Modes, Getting Connected, Top | |
351 @comment node-name, next, previous,up | |
352 | |
353 @chapter New Indentation Engine | |
354 @cindex New Indentation Engine | |
355 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
356 | |
357 @code{cc-mode} has a new indentation engine, providing a simplified, yet | |
358 flexible and general mechanism for customizing indentation. It breaks | |
359 indentation calculation into two steps. First, for the line of code being | |
360 indented, @code{cc-mode} analyzes what kind of language construct it's | |
361 looking at, then it applies user defined offsets to the current line | |
362 based on this analysis. | |
363 | |
364 This section will briefly cover how indentation is calculated in | |
365 @code{cc-mode}. It is important to understand the indentation model | |
366 being used so that you will know how to customize @code{cc-mode} for | |
367 your personal coding style. | |
344 | 368 |
345 @menu | 369 @menu |
346 * Syntactic Analysis:: | 370 * Syntactic Analysis:: |
347 * Indentation Calculation:: | 371 * Indentation Calculation:: |
348 @end menu | 372 @end menu |
349 | 373 |
350 @node New Indentation Engine, Minor Modes, Getting Connected, Top | |
351 @comment node-name, next, previous,up | |
352 | |
353 @chapter New Indentation Engine | |
354 @cindex New Indentation Engine | |
355 | |
356 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
357 | |
358 @code{cc-mode} has a new indentation engine, providing a simplified, yet | |
359 flexible and general mechanism for customizing indentation. It breaks | |
360 indentation calculation into two steps. First for the line of code being | |
361 indented, @code{cc-mode} analyzes what kind of language construct it's | |
362 looking at, then it applies user defined offsets to the current line | |
363 based on this analysis. | |
364 | |
365 This section will briefly cover how indentation is calculated in | |
366 @code{cc-mode}. It is important to understand the indentation model | |
367 being used so that you will know how to customize @code{cc-mode} for | |
368 your personal coding style. | |
369 | |
370 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
371 @menu | |
372 * Syntactic Analysis:: | |
373 * Indentation Calculation:: | |
374 @end menu | |
375 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
376 | 374 |
377 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 375 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
378 @node Syntactic Analysis, Indentation Calculation, , New Indentation Engine | 376 @node Syntactic Analysis, Indentation Calculation, , New Indentation Engine |
379 @comment node-name, next, previous,up | 377 @comment node-name, next, previous,up |
380 @section Syntactic Analysis | 378 @section Syntactic Analysis |
427 @findex c-show-syntactic-information | 425 @findex c-show-syntactic-information |
428 @findex show-syntactic-information (c-) | 426 @findex show-syntactic-information (c-) |
429 We can use the command @kbd{C-c C-s} | 427 We can use the command @kbd{C-c C-s} |
430 (@code{c-show-syntactic-information}) to simply report what the | 428 (@code{c-show-syntactic-information}) to simply report what the |
431 syntactic analysis is for the current line. Running this command on | 429 syntactic analysis is for the current line. Running this command on |
432 line 4 this example, we'd see in the echo area: | 430 line 4 this example, we'd see in the echo area@footnote{With a universal |
431 argument (i.e. @kbd{C-u C-c C-s}) the analysis is inserted into the | |
432 buffer as a comment | |
433 on the current line.}: | |
433 @example | 434 @example |
434 | 435 |
435 ((statement . 35)) | 436 ((statement . 35)) |
436 | 437 |
437 @end example | 438 @end example |
438 | 439 |
439 This tells us that the line is a statement and it is indented relative | 440 This tells us that the line is a statement and it is indented relative |
440 to buffer position 35, which happens to be the @samp{i} in @code{int} on | 441 to buffer position 35, which happens to be the @samp{i} in @code{int} on |
441 line 3. If you were to move point to line 3 and hit @kbd{C-c C-s}, you | 442 line 3. If you were to move Point to line 3 and hit @kbd{C-c C-s}, you |
442 would see: | 443 would see: |
443 @example | 444 @example |
444 | 445 |
445 ((defun-block-intro . 29)) | 446 ((defun-block-intro . 29)) |
446 | 447 |
502 | 503 |
503 @end group | 504 @end group |
504 @end example | 505 @end example |
505 | 506 |
506 @noindent | 507 @noindent |
507 Hitting @kbd{C-c C-s} on line 3 of example 3 gives us: | 508 Hitting @kbd{C-c C-s} on line 3 of this example gives: |
508 @example | 509 @example |
509 | 510 |
510 ((comment-intro) (defun-block-intro . 46)) | 511 ((comment-intro) (defun-block-intro . 46)) |
511 | 512 |
512 @end example | 513 @end example |
513 | 514 |
514 @noindent | 515 @noindent |
515 so you can see that the syntactic component list contains two syntactic | 516 and you can see that the syntactic component list contains two syntactic |
516 components. Also notice that the first component, | 517 components. Also notice that the first component, |
517 @samp{(comment-intro)} has no relative buffer position. | 518 @samp{(comment-intro)} has no relative buffer position. |
518 | 519 |
519 | 520 |
520 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 521 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
531 Each component contributes to the final total indentation of the line in | 532 Each component contributes to the final total indentation of the line in |
532 two ways. | 533 two ways. |
533 | 534 |
534 First, the syntactic symbols are looked up in the @code{c-offsets-alist} | 535 First, the syntactic symbols are looked up in the @code{c-offsets-alist} |
535 variable, which is an association list of syntactic symbols and the | 536 variable, which is an association list of syntactic symbols and the |
536 offsets to apply for those symbols. These offsets are added to the | 537 offsets to apply for those symbols. These offsets are added to a |
537 running total. | 538 running total. |
538 | 539 |
539 Second, if the component has a relative buffer position, @code{cc-mode} | 540 Second, if the component has a relative buffer position, @code{cc-mode} |
540 adds the column number of that position to the running total. By adding | 541 adds the column number of that position to the running total. By adding |
541 up the offsets and columns for every syntactic component on the list, | 542 up the offsets and columns for every syntactic component on the list, |
555 | 556 |
556 @end group | 557 @end group |
557 @end example | 558 @end example |
558 | 559 |
559 @kindex TAB | 560 @kindex TAB |
560 Let's say point is on line 3 and we hit the @key{TAB} key to re-indent | 561 Let's say Point is on line 3 and we hit the @key{TAB} key to re-indent |
561 the line. Remember that the syntactic component list for that | 562 the line. Remember that the syntactic component list for that |
562 line is: | 563 line is: |
563 @example | 564 @example |
564 | 565 |
565 ((defun-block-intro . 29)) | 566 ((defun-block-intro . 29)) |
571 @code{c-offsets-alist} variable. Let's say it finds the value @samp{4}; | 572 @code{c-offsets-alist} variable. Let's say it finds the value @samp{4}; |
572 it adds this to the running total (initialized to zero), yielding a | 573 it adds this to the running total (initialized to zero), yielding a |
573 running total indentation of 4 spaces. | 574 running total indentation of 4 spaces. |
574 | 575 |
575 Next @code{cc-mode} goes to buffer position 29 and asks for the current | 576 Next @code{cc-mode} goes to buffer position 29 and asks for the current |
576 column. Since the brace at buffer position 29 is in column zero, it | 577 column. This brace is in column zero, so @code{cc-mode} |
577 adds @samp{0} to the running total. Since there is only one syntactic | 578 adds @samp{0} to the running total. Since there is only one syntactic |
578 component on the list for this line, indentation calculation is | 579 component on the list for this line, indentation calculation is |
579 complete, and the total indentation for the line | 580 complete, and the total indentation for the line |
580 is 4 spaces. | 581 is 4 spaces. |
581 | 582 |
626 syntactic component list and calculated offset will always be echoed in | 627 syntactic component list and calculated offset will always be echoed in |
627 the minibuffer when you hit @kbd{TAB}. | 628 the minibuffer when you hit @kbd{TAB}. |
628 | 629 |
629 | 630 |
630 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 631 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
631 @node Minor Modes, Indentation Commands, New Indentation Engine, Top | 632 @node Minor Modes, Commands, New Indentation Engine, Top |
632 @comment node-name, next, previous,up | 633 @comment node-name, next, previous,up |
633 | 634 |
634 @chapter Minor Modes | 635 @chapter Minor Modes |
635 @cindex Minor Modes | 636 @cindex Minor Modes |
636 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 637 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
637 | 638 |
638 @code{cc-mode} contains two minor-mode-like features that you should | 639 @code{cc-mode} contains two minor-mode-like features that you should |
639 find useful while you enter new C code. The first is called | 640 find useful while you enter new C code. The first is called |
640 @dfn{auto-newline} mode, and the second is called @dfn{hungry-delete} | 641 @dfn{auto-newline} mode, and the second is called @dfn{hungry-delete} |
641 mode. These minor modes can be toggled on and off independently, and | 642 mode. These minor modes can be toggled on and off independently, and |
642 @code{cc-mode} can be configured so that it comes up with any | 643 @code{cc-mode} can be configured so that it starts up with any |
643 combination of these minor modes. By default, both of these minor modes | 644 combination of these minor modes. By default, both of these minor modes |
644 are turned off. | 645 are turned off. |
645 | 646 |
646 The state of the minor modes is always reflected in the minor mode list | 647 The state of the minor modes is always reflected in the minor mode list |
647 on the modeline of the @code{cc-mode} buffer. When auto-newline mode is | 648 on the modeline of the @code{cc-mode} buffer. When auto-newline mode is |
648 enabled, you will see @samp{C/a} on the mode line @footnote{Remember | 649 enabled, you will see @samp{C/a} on the mode line @footnote{Remember |
649 that the @samp{C} would be replaced with @samp{C++} or @samp{ObjC} if | 650 that the @samp{C} could be replaced with @samp{C++}, @samp{ObjC}, or |
650 you were editing C++ or Objective-C code.}. When hungry delete mode is | 651 @samp{Java}.}. When hungry delete mode is enabled you would see |
651 enabled you would see @samp{C/h} and when both modes are enabled, you'd | 652 @samp{C/h} and when both modes are enabled, you'd see @samp{C/ah}. |
652 see @samp{C/ah}. | |
653 | 653 |
654 @kindex C-c C-a | 654 @kindex C-c C-a |
655 @kindex C-c C-d | 655 @kindex C-c C-d |
656 @kindex C-c C-t | 656 @kindex C-c C-t |
657 @findex c-toggle-hungry-state | 657 @findex c-toggle-hungry-state |
659 @findex c-toggle-auto-hungry-state | 659 @findex c-toggle-auto-hungry-state |
660 @findex toggle-hungry-state (c-) | 660 @findex toggle-hungry-state (c-) |
661 @findex toggle-auto-state (c-) | 661 @findex toggle-auto-state (c-) |
662 @findex toggle-auto-hungry-state (c-) | 662 @findex toggle-auto-hungry-state (c-) |
663 @code{cc-mode} provides keybindings which allow you to toggle the minor | 663 @code{cc-mode} provides keybindings which allow you to toggle the minor |
664 modes while editing code on the fly. To toggle just the auto-newline | 664 modes on the fly while editing code. To toggle just the auto-newline |
665 state, hit @kbd{C-c C-a} (@code{c-toggle-auto-state}). When you do | 665 state, hit @kbd{C-c C-a} (@code{c-toggle-auto-state}). When you do |
666 this, you should see the @samp{a} indicator either appear or disappear | 666 this, you should see the @samp{a} indicator either appear or disappear |
667 on the modeline. Similarly, to toggle just the hungry-delete state, use | 667 on the modeline. Similarly, to toggle just the hungry-delete state, use |
668 @kbd{C-c C-d} (@code{c-toggle-hungry-state}), and to toggle both states | 668 @kbd{C-c C-d} (@code{c-toggle-hungry-state}), and to toggle both states, |
669 together, use @kbd{C-c C-t} (@code{c-toggle-auto-hungry-state}). | 669 use @kbd{C-c C-t} (@code{c-toggle-auto-hungry-state}). |
670 | 670 |
671 To set up the auto-newline and hungry-delete states to your preferred | 671 To set up the auto-newline and hungry-delete states to your preferred |
672 values, you would need to add some lisp to your @file{.emacs} file that | 672 values, you would need to add some lisp to your @file{.emacs} file that |
673 called one of the @code{c-toggle-*-state} functions directly. When | 673 called one of the @code{c-toggle-*-state} functions directly. When |
674 called programmatically, each function takes a numeric value, where | 674 called programmatically, each function takes a numeric value, where |
762 two electric formatting behaviors. First, it will perform some | 762 two electric formatting behaviors. First, it will perform some |
763 re-indentation of the line the brace was typed on, and second, it will | 763 re-indentation of the line the brace was typed on, and second, it will |
764 add various newlines before and/or after the typed brace. | 764 add various newlines before and/or after the typed brace. |
765 Re-indentation occurs automatically whenever the electric behavior is | 765 Re-indentation occurs automatically whenever the electric behavior is |
766 enabled. If the brace ends up on a line other than the one it was typed | 766 enabled. If the brace ends up on a line other than the one it was typed |
767 on, then that line is on is also indented according to | 767 on, then that line is also indented according to |
768 @code{c-offsets-alist}. | 768 @code{c-offsets-alist}. |
769 | 769 |
770 @cindex class-open syntactic symbol | 770 @cindex class-open syntactic symbol |
771 @cindex class-close syntactic symbol | 771 @cindex class-close syntactic symbol |
772 @cindex defun-open syntactic symbol | 772 @cindex defun-open syntactic symbol |
779 @cindex brace-list-entry syntactic symbol | 779 @cindex brace-list-entry syntactic symbol |
780 @cindex block-open syntactic symbol | 780 @cindex block-open syntactic symbol |
781 @cindex block-close syntactic symbol | 781 @cindex block-close syntactic symbol |
782 @cindex substatement-open syntactic symbol | 782 @cindex substatement-open syntactic symbol |
783 @cindex statement-case-open syntactic symbol | 783 @cindex statement-case-open syntactic symbol |
784 @cindex extern-lang-open syntactic symbol | |
785 @cindex extern-lang-close syntactic symbol | |
784 | 786 |
785 The insertion of newlines is controlled by the | 787 The insertion of newlines is controlled by the |
786 @code{c-hanging-braces-alist} variable. This variable contains a | 788 @code{c-hanging-braces-alist} variable. This variable contains a |
787 mapping between syntactic symbols related to braces, and a list of | 789 mapping between syntactic symbols related to braces, and a list of |
788 places to insert a newline. The syntactic symbols that are useful for | 790 places to insert a newline. The syntactic symbols that are useful for |
789 this list are: @code{class-open}, @code{class-close}, @code{defun-open}, | 791 this list are: @code{class-open}, @code{class-close}, @code{defun-open}, |
790 @code{defun-close}, @code{inline-open}, @code{inline-close}, | 792 @code{defun-close}, @code{inline-open}, @code{inline-close}, |
791 @code{brace-list-open}, @code{brace-list-close}, | 793 @code{brace-list-open}, @code{brace-list-close}, |
792 @code{brace-list-intro}, @code{brace-list-entry}, @code{block-open}, | 794 @code{brace-list-intro}, @code{brace-list-entry}, @code{block-open}, |
793 @code{block-close}, @code{substatement-open}, and | 795 @code{block-close}, @code{substatement-open}, |
794 @code{statement-case-open}. @xref{Syntactic Symbols} for a more | 796 @code{statement-case-open}, |
797 @code{extern-lang-open}, and @code{extern-lang-close}. | |
798 @xref{Syntactic Symbols} for a more | |
795 detailed description of these syntactic symbols. | 799 detailed description of these syntactic symbols. |
796 | 800 |
797 @cindex custom indentation function | 801 @cindex custom indentation function |
798 The value associated with each syntactic symbol in this association list | 802 The value associated with each syntactic symbol in this association list |
799 is called an @var{ACTION} which can be either a function or a list. | 803 is called an @var{ACTION} which can be either a function or a list. |
800 @xref{Custom Brace and Colon Hanging} for a more detailed discussion of | 804 @xref{Custom Brace and Colon Hanging} for a more detailed discussion of |
801 using a function as a brace hanging @var{ACTION}. | 805 using a function as a brace hanging @var{ACTION}. |
802 | 806 |
803 When @var{ACTION} is a list, it can contain any combination of the | 807 When the @var{ACTION} is a list, it can contain any combination of the |
804 symbols @code{before} or @code{after}, directing @code{cc-mode} where to | 808 symbols @code{before} and @code{after}, directing @code{cc-mode} where to |
805 put newlines in relationship to the brace being inserted. Thus, if the | 809 put newlines in relationship to the brace being inserted. Thus, if the |
806 list contains only the symbol @code{after}, then the brace is said to | 810 list contains only the symbol @code{after}, then the brace is said to |
807 @dfn{hang} on the right side of the line, as in: | 811 @dfn{hang} on the right side of the line, as in: |
808 @example | 812 @example |
809 @group | 813 @group |
828 @example | 832 @example |
829 @group | 833 @group |
830 | 834 |
831 (defvar c-hanging-braces-alist '((brace-list-open) | 835 (defvar c-hanging-braces-alist '((brace-list-open) |
832 (substatement-open after) | 836 (substatement-open after) |
833 (block-close . c-snug-do-while))) | 837 (block-close . c-snug-do-while) |
838 (extern-lang-open after))) | |
834 | 839 |
835 @end group | 840 @end group |
836 @end example | 841 @end example |
837 | 842 |
838 @noindent | 843 @noindent |
839 which says that @code{brace-list-open} braces should both hang on the | 844 which says that @code{brace-list-open} braces should both hang on the |
840 right side, and allow subsequent text to follow on the same line as the | 845 right side, and allow subsequent text to follow on the same line as the |
841 brace. Also, @code{substatement-open} braces should hang on the right | 846 brace. Also, @code{substatement-open} and @code{extern-lang-open} |
842 side, but subsequent text should follow on the next line. Here, in the | 847 braces should hang on the right side, but subsequent text should follow |
843 @code{block-close} entry, you also see an example of using a function as | 848 on the next line. Here, in the @code{block-close} entry, you also see |
844 an @var{ACTION}. | 849 an example of using a function as an @var{ACTION}. |
845 | 850 |
846 | 851 |
847 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 852 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
848 @node Hanging Colons, Hanging Semi-colons and commas, Hanging Braces, Auto-newline insertion | 853 @node Hanging Colons, Hanging Semi-colons and commas, Hanging Braces, Auto-newline insertion |
849 @comment node-name, next, previous,up | 854 @comment node-name, next, previous,up |
857 Using a mechanism similar to brace hanging (see @ref{Hanging Braces}), | 862 Using a mechanism similar to brace hanging (see @ref{Hanging Braces}), |
858 colons can also be made to hang using the variable | 863 colons can also be made to hang using the variable |
859 @code{c-hanging-colons-alist}. The syntactic symbols appropriate for | 864 @code{c-hanging-colons-alist}. The syntactic symbols appropriate for |
860 this assocation list are: @code{case-label}, @code{label}, | 865 this assocation list are: @code{case-label}, @code{label}, |
861 @code{access-label}, @code{member-init-intro}, and @code{inher-intro}. | 866 @code{access-label}, @code{member-init-intro}, and @code{inher-intro}. |
862 @xref{Hanging Braces} and @ref{Custom Brace and Colon Hanging} for | 867 Note however, that for @code{c-hanging-colons-alist} @var{ACTION}s as |
863 details. Note however, that @code{c-hanging-colons-alist} does not | 868 functions are not supported. See also @ref{Custom Brace and Colon |
864 implement functions as @var{ACTION}s. | 869 Hanging} for details. |
865 | 870 |
866 @cindex clean-ups | 871 @cindex clean-ups |
867 In C++, double-colons are used as a scope operator but because these | 872 In C++, double-colons are used as a scope operator but because these |
868 colons always appear right next to each other, newlines before and after | 873 colons always appear right next to each other, newlines before and after |
869 them are controlled by a different mechanism, called @dfn{clean-ups} in | 874 them are controlled by a different mechanism, called @dfn{clean-ups} in |
898 @vindex c-electric-pound-behavior | 903 @vindex c-electric-pound-behavior |
899 @findex electric-pound (c-) | 904 @findex electric-pound (c-) |
900 @vindex electric-pound-behavior (c-) | 905 @vindex electric-pound-behavior (c-) |
901 @vindex c-offsets-alist | 906 @vindex c-offsets-alist |
902 @vindex offsets-alist (c-) | 907 @vindex offsets-alist (c-) |
903 A few other keys also provide electric behavior. For example the | 908 A few other keys also provide electric behavior. For example |
904 @kbd{#} key (@code{c-electric-pound}) is electric when it is typed as | 909 @kbd{#} (@code{c-electric-pound}) is electric when typed as |
905 the first non-whitespace character on a line. In this case, the | 910 the first non-whitespace character on a line. In this case, the |
906 variable @code{c-electric-pound-behavior} is consulted for the electric | 911 variable @code{c-electric-pound-behavior} is consulted for the electric |
907 behavior. This variable takes a list value, although the only element | 912 behavior. This variable takes a list value, although the only element |
908 currently defined is @code{alignleft}, which tells this command to force | 913 currently defined is @code{alignleft}, which tells this command to force |
909 the @samp{#} character into column zero. This is useful for entering | 914 the @samp{#} character into column zero. This is useful for entering |
912 @findex c-electric-star | 917 @findex c-electric-star |
913 @findex c-electric-slash | 918 @findex c-electric-slash |
914 @findex electric-star (c-) | 919 @findex electric-star (c-) |
915 @findex electric-slash (c-) | 920 @findex electric-slash (c-) |
916 @cindex comment-only line | 921 @cindex comment-only line |
917 Stars and slashes (i.e. @kbd{*} and @kbd{/}) are also electric under | 922 Stars and slashes (i.e. @kbd{*} and @kbd{/}, @code{c-electric-star} and |
923 @code{c-electric-slash} respectively) are also electric under | |
918 certain circumstances. If a star is inserted as the second character of | 924 certain circumstances. If a star is inserted as the second character of |
919 a C style block comment on a @dfn{comment-only} line, then the comment | 925 a C style block comment on a @dfn{comment-only} line, then the comment |
920 delimiter is indented as defined by @code{c-offsets-alist}. A | 926 delimiter is indented as defined by @code{c-offsets-alist}. A |
921 comment-only line is defined as a line which contains only a comment, as | 927 comment-only line is defined as a line which contains only a comment, as |
922 in: | 928 in: |
937 | 943 |
938 Likewise, if a slash is inserted as the second slash in a C++ style line | 944 Likewise, if a slash is inserted as the second slash in a C++ style line |
939 comment (also only on a comment-only line), then the line is indented as | 945 comment (also only on a comment-only line), then the line is indented as |
940 defined by @code{c-offsets-alist}. | 946 defined by @code{c-offsets-alist}. |
941 | 947 |
948 @findex c-electric-lt-gt | |
949 @findex electric-lt-gt (c-) | |
950 @kindex < | |
951 @kindex > | |
952 Less-than and greater-than signs (@code{c-electric-lt-gt}) are also | |
953 electric, but only in C++ mode. Hitting the second of two @kbd{<} or | |
954 @kbd{>} keys re-indents the line if it is a C++ style stream operator. | |
955 | |
942 | 956 |
943 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 957 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
944 @node Clean-ups, , Other electric commands, Auto-newline insertion | 958 @node Clean-ups, , Other electric commands, Auto-newline insertion |
945 @comment node-name, next, previous,up | 959 @comment node-name, next, previous,up |
946 | 960 |
970 There are currently only five specific constructs that @code{cc-mode} | 984 There are currently only five specific constructs that @code{cc-mode} |
971 can clean up, as indicated by these symbols: | 985 can clean up, as indicated by these symbols: |
972 | 986 |
973 @itemize @bullet | 987 @itemize @bullet |
974 @item | 988 @item |
975 @code{brace-else-brace} -- cleans up @samp{@} else @{} constructs by | 989 @code{brace-else-brace} --- cleans up @samp{@} else @{} constructs by |
976 placing the entire construct on a single line. Clean-up occurs when the | 990 placing the entire construct on a single line. Clean-up occurs when the |
977 open brace after the @samp{else} is typed. So for example, this: | 991 open brace after the @samp{else} is typed. So for example, this: |
978 @example | 992 @example |
979 @group | 993 @group |
980 | 994 |
1002 | 1016 |
1003 @end group | 1017 @end group |
1004 @end example | 1018 @end example |
1005 | 1019 |
1006 @item | 1020 @item |
1007 @code{empty-defun-braces} -- cleans up braces following a top-level | 1021 @code{empty-defun-braces} --- cleans up braces following a top-level |
1008 function or class definition that contains no body. Clean up occurs | 1022 function or class definition that contains no body. Clean up occurs |
1009 when the closing brace is typed. Thus the following: | 1023 when the closing brace is typed. Thus the following: |
1010 @example | 1024 @example |
1011 @group | 1025 @group |
1012 | 1026 |
1026 | 1040 |
1027 @end group | 1041 @end group |
1028 @end example | 1042 @end example |
1029 | 1043 |
1030 @item | 1044 @item |
1031 @code{defun-close-semi} -- cleans up the terminating semi-colon on | 1045 @code{defun-close-semi} --- cleans up the terminating semi-colon on |
1032 top-level function or class definitions when they follow a close | 1046 top-level function or class definitions when they follow a close |
1033 brace. Clean up occurs when the semi-colon is typed. | 1047 brace. Clean up occurs when the semi-colon is typed. |
1034 So for example, the following: | 1048 So for example, the following: |
1035 @example | 1049 @example |
1036 @group | 1050 @group |
1054 | 1068 |
1055 @end group | 1069 @end group |
1056 @end example | 1070 @end example |
1057 | 1071 |
1058 @item | 1072 @item |
1059 @code{list-close-comma} -- cleans up commas following braces in array | 1073 @code{list-close-comma} --- cleans up commas following braces in array |
1060 and aggregate initializers. Clean up occurs when the comma is typed. | 1074 and aggregate initializers. Clean up occurs when the comma is typed. |
1061 | 1075 |
1062 @item | 1076 @item |
1063 @code{scope-operator} -- cleans up double colons which may designate a | 1077 @code{scope-operator} --- cleans up double colons which may designate a |
1064 C++ scope operator split across multiple lines@footnote{Certain C++ | 1078 C++ scope operator split across multiple lines@footnote{Certain C++ |
1065 constructs introduce ambiguous situations, so @code{scope-operator} | 1079 constructs introduce ambiguous situations, so @code{scope-operator} |
1066 clean-ups may not always be correct. This usually only occurs when | 1080 clean-ups may not always be correct. This usually only occurs when |
1067 scoped identifiers appear in switch label tags.}. Clean up occurs when | 1081 scoped identifiers appear in switch label tags.}. Clean up occurs when |
1068 the second colon is typed. You will always want @code{scope-operator} | 1082 the second colon is typed. You will always want @code{scope-operator} |
1106 @code{c-electric-delete} is not electric, which is typical of all the | 1120 @code{c-electric-delete} is not electric, which is typical of all the |
1107 so-called electric commands. | 1121 so-called electric commands. |
1108 | 1122 |
1109 | 1123 |
1110 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 1124 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
1111 @node Indentation Commands, Customizing Indentation, Minor Modes, Top | 1125 @node Commands, Customizing Indentation, Minor Modes, Top |
1112 @comment node-name, next, previous,up | 1126 @comment node-name, next, previous,up |
1113 | 1127 |
1114 @chapter Indentation Commands | 1128 @chapter Commands |
1129 @cindex Commands | |
1130 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
1131 | |
1132 @menu | |
1133 * Indentation Commands:: | |
1134 * Other Commands:: | |
1135 @end menu | |
1136 | |
1137 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
1138 @node Indentation Commands, Other Commands, , Commands | |
1139 @comment node-name, next, previous,up | |
1140 | |
1141 @section Indentation Commands | |
1115 @cindex Indentation Commands | 1142 @cindex Indentation Commands |
1116 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 1143 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
1117 | 1144 |
1118 @findex c-set-style | 1145 @findex c-set-style |
1119 @findex set-style (c-) | 1146 @findex set-style (c-) |
1120 Various commands are provided which allow you to conveniently re-indent | 1147 Various commands are provided which allow you to conveniently re-indent |
1121 C constructs, and these are outlined below. There are several things to | 1148 C constructs. There are several things to |
1122 note about these indentation commands. First, when you | 1149 note about these indentation commands. First, when you |
1123 change your programming style, either though @code{c-set-style} or some | 1150 change your programming style, either interactively or through some |
1124 other means, your file does @emph{not} automatically get re-indented. | 1151 other means, your file does @emph{not} automatically get re-indented. |
1125 When you change style parameters, you will typically need to reformat | 1152 When you change style parameters, you will typically need to reformat |
1126 the line, expression, or buffer to see the effects of your changes. | 1153 the line, expression, or buffer to see the effects of your changes. |
1127 | 1154 |
1128 @cindex c-hanging- functions | 1155 @cindex c-hanging- functions |
1129 @findex c-hanging-braces-alist | 1156 @findex c-hanging-braces-alist |
1130 @findex hanging-braces-alist (c-) | 1157 @findex hanging-braces-alist (c-) |
1131 Second, changing some variables have no effect on existing code, even | 1158 Second, changing some variables have no effect on existing code, even |
1132 when you do re-indent. For example, the @code{c-hanging-*} variables and | 1159 when you do re-indent. For example, the @code{c-hanging-*} variables |
1133 @code{c-cleanup-list} only affect newly entered code. So for example, | 1160 and @code{c-cleanup-list} only affect new code as it is typed in. So |
1134 changing @code{c-hanging-braces-alist} and re-indenting the buffer will | 1161 for example, changing @code{c-hanging-braces-alist} and re-indenting the |
1135 not adjust placement of braces already in the file. | 1162 buffer will not adjust placement of braces already in the file. |
1136 | 1163 |
1137 @vindex c-progress-interval | 1164 @vindex c-progress-interval |
1138 @vindex progress-interval (c-) | 1165 @vindex progress-interval (c-) |
1139 Third, re-indenting large portions of code is currently rather | 1166 Third, re-indenting large portions of code is currently rather |
1140 inefficient. Improvements have been made since previous releases of | 1167 inefficient. Improvements have been made since previous releases of |
1141 @code{cc-mode}, and much more radical improvements will be made for the | 1168 @code{cc-mode}, and much more radical improvements are planned, but for |
1142 next release, but for now you need to be aware of this @footnote{In | 1169 now you need to be aware of this @footnote{In particular, I have had |
1143 particular, I have had people complain about the speed that | 1170 people complain about the speed that @code{cc-mode} re-indents |
1144 @code{cc-mode} re-indents @code{lex(1)} output. Lex, yacc, and other | 1171 @code{lex(1)} output. Lex, yacc, and other code generators usually |
1145 code generators usually output some pretty perverse code. @emph{Don't} | 1172 output some pretty perversely formatted code. @emph{Don't} try to |
1146 try to indent this stuff with @code{cc-mode}!}. Some provision has been | 1173 indent this stuff with @code{cc-mode}!}. Some provision has been made |
1147 made to at least inform you as to the progress of your large | 1174 to at least inform you as to the progress of the re-indentation. The |
1148 re-indentation command. The variable @code{c-progress-interval} | 1175 variable @code{c-progress-interval} controls how often a progress |
1149 controls how often a progress message is displayed. Set this variable | 1176 message is displayed. Set this variable to @code{nil} to inhibit |
1150 to @code{nil} to inhibit progress messages. Note that this feature only | 1177 progress messages. Note that this feature only works with Emacs 19. |
1151 works with Emacs 19. | |
1152 | 1178 |
1153 Also, except as noted below, re-indentation is always driven by the | 1179 Also, except as noted below, re-indentation is always driven by the |
1154 same mechanisms that control on-the-fly indentation of code. @xref{New | 1180 same mechanisms that control on-the-fly indentation of code. @xref{New |
1155 Indentation Engine} for details. | 1181 Indentation Engine} for details. |
1156 | 1182 |
1158 @findex indent-command (c-) | 1184 @findex indent-command (c-) |
1159 @vindex c-tab-always-indent | 1185 @vindex c-tab-always-indent |
1160 @vindex tab-always-indent (c-) | 1186 @vindex tab-always-indent (c-) |
1161 @kindex TAB | 1187 @kindex TAB |
1162 @cindex literal | 1188 @cindex literal |
1189 @vindex indent-tabs-mode | |
1190 @vindex c-insert-tab-function | |
1191 @vindex insert-tab-function (c-) | |
1192 @findex tab-to-tab-stop | |
1163 To indent a single line of code, use @kbd{TAB} | 1193 To indent a single line of code, use @kbd{TAB} |
1164 (@code{c-indent-command}). The behavior of this command is controlled | 1194 (@code{c-indent-command}). The behavior of this command is controlled |
1165 by the variable @code{c-tab-always-indent}. When this variable is | 1195 by the variable @code{c-tab-always-indent}. When this variable is |
1166 @code{t}, @kbd{TAB} always just indents the current line. When | 1196 @code{t}, @kbd{TAB} always just indents the current line. When |
1167 @code{nil}, the line is indented only if point is at the left | 1197 @code{nil}, the line is indented only if Point is at the left margin, or |
1168 margin, or on or before the first non-whitespace character on the line, | 1198 on or before the first non-whitespace character on the line, otherwise |
1169 otherwise a real tab character is inserted. If this variable's value is | 1199 @emph{something else happens}@footnote{Actually what happens is that the |
1170 something other that @code{t} or @code{nil} (e.g. @code{'other}), then a | 1200 function stored in the variable @code{c-insert-tab-function} is called. |
1171 real tab character is inserted only when point is inside a | 1201 Normally this just inserts a real tab character, or the equivalent |
1172 literal (see @ref{Auto-newline insertion}), otherwise the line is | 1202 number of spaces, depending on the setting of the variable |
1173 indented. | 1203 @code{indent-tabs-mode}. If you preferred, you could set |
1204 @code{c-insert-tab-function} to @code{tab-to-tab-stop} for example.}. | |
1205 If the value of @code{c-tab-always-indent} is something other than | |
1206 @code{t} or @code{nil} (e.g. @code{'other}), then a real tab | |
1207 character@footnote{The caveat about @code{indent-tabs-mode} in the | |
1208 previous footnote also applies here.} is inserted only when Point is | |
1209 inside a literal (see @ref{Auto-newline insertion}), otherwise the line | |
1210 is indented. | |
1174 | 1211 |
1175 @kindex M-C-q | 1212 @kindex M-C-q |
1176 @findex c-indent-exp | 1213 @findex c-indent-exp |
1177 @findex indent-exp (c-) | 1214 @findex indent-exp (c-) |
1178 To indent an entire balanced brace or parenthesis expression, use | 1215 To indent an entire balanced brace or parenthesis expression, use |
1179 @kbd{M-C-q} (@code{c-indent-exp}). Note that point should be on | 1216 @kbd{M-C-q} (@code{c-indent-exp}). Note that Point should be on |
1180 the opening brace or parenthesis of the expression you want to indent. | 1217 the opening brace or parenthesis of the expression you want to indent. |
1181 | 1218 |
1182 @kindex C-c C-q | 1219 @kindex C-c C-q |
1183 @findex c-indent-defun | 1220 @findex c-indent-defun |
1184 @findex indent-defun (c-) | 1221 @findex indent-defun (c-) |
1185 Another very convenient keystroke is @kbd{C-c C-q} | 1222 Another very convenient keystroke is @kbd{C-c C-q} |
1186 (@code{c-indent-defun}) when re-indents the entire top-level function or | 1223 (@code{c-indent-defun}) when re-indents the entire top-level function or |
1187 class definition that encompases point. It leaves point at the | 1224 class definition that encompases Point. It leaves Point at the |
1188 same position within the buffer. | 1225 same position within the buffer. |
1189 | 1226 |
1190 @kindex M-C-\ | 1227 @kindex M-C-\ |
1191 @findex indent-region | 1228 @findex indent-region |
1192 To indent any arbitrary region of code, use @kbd{M-C-\} | 1229 To indent any arbitrary region of code, use @kbd{M-C-\} |
1193 (@code{indent-region}). This is a standard Emacs command, specially | 1230 (@code{indent-region}). This is a standard Emacs command, specially |
1194 tailored for C code in a @code{cc-mode} buffer. Note that of course, | 1231 tailored for C code in a @code{cc-mode} buffer. Note that of course, |
1195 point and mark must delineate the region you | 1232 Point and Mark must delineate the region you |
1196 want to indent. | 1233 want to indent. |
1197 | 1234 |
1198 @kindex M-C-h | 1235 @kindex M-C-h |
1199 @findex c-mark-function | 1236 @findex c-mark-function |
1200 @findex mark-function (c-) | 1237 @findex mark-function (c-) |
1201 While not strictly an indentation function, @kbd{M-C-h} | 1238 While not strictly an indentation function, @kbd{M-C-h} |
1202 (@code{c-mark-function}) is useful for marking the current top-level | 1239 (@code{c-mark-function}) is useful for marking the current top-level |
1203 function or class definition as the current region. | 1240 function or class definition as the current region. |
1204 | 1241 |
1205 | 1242 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
1206 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 1243 @node Other Commands, , Indentation Commands, Commands |
1207 @node Customizing Indentation, Syntactic Symbols, Indentation Commands, Top | 1244 @comment node-name, next, previous,up |
1245 | |
1246 @section Other Commands | |
1247 @cindex Other Commands | |
1248 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
1249 | |
1250 @code{cc-mode} contains other useful command for moving around in C | |
1251 code. | |
1252 | |
1253 @table @code | |
1254 @item C-c C-u (c-up-conditional) | |
1255 @kindex C-c C-u | |
1256 @findex c-up-conditional | |
1257 @findex up-conditional (c-) | |
1258 Move Point back to the containing preprocessor conditional, leaving the | |
1259 Mark behind. A prefix argument acts as a repeat count. With a negative | |
1260 argument, move Point forward to the end of the containing | |
1261 preprocessor conditional. When going backwards, @code{#elif} is treated | |
1262 like @code{#else} followed by @code{#if}. When going forwards, | |
1263 @code{#elif} is ignored.@refill | |
1264 | |
1265 @item C-c C-p (c-backward-conditional) | |
1266 @kindex C-c C-p | |
1267 @findex c-backward-conditional | |
1268 @findex backward-conditional (c-) | |
1269 Move Point back over a preprocessor conditional, leaving Mark | |
1270 behind. A prefix argument acts as a repeat count. With a negative | |
1271 argument, move forward. | |
1272 | |
1273 @item C-c C-n (c-forward-conditional) | |
1274 @kindex C-c C-n | |
1275 @findex c-forward-conditional | |
1276 @findex forward-conditional (c-) | |
1277 Move Point forward across a preprocessor conditional, leaving Mark | |
1278 behind. A prefix argument acts as a repeat count. With a negative | |
1279 argument, move backward. | |
1280 | |
1281 @item M-a (c-beginning-of-statement) | |
1282 @kindex ESC a | |
1283 @findex c-beginning-of-statement | |
1284 @findex beginning-of-statement (c-) | |
1285 Move Point to the beginning of the innermost C statement. If Point is | |
1286 already at the beginning of a statement, it moves to the beginning of | |
1287 the preceding statement. With prefix argument @var{n}, move back | |
1288 @var{n} @minus{} 1 statements. | |
1289 | |
1290 If Point is within a string or comment, or next to a comment (only | |
1291 whitespace between them), this command moves by sentences instead of | |
1292 statements. | |
1293 | |
1294 When called from a program, this function takes two optional arguments: | |
1295 the numeric prefix argument, and a buffer position limit (don't move | |
1296 back before that place). | |
1297 | |
1298 @item M-e (c-end-of-statement) | |
1299 @kindex ESC e | |
1300 @findex c-end-of-statement | |
1301 @findex end-of-statement (c-) | |
1302 Move Point to the end of the innermost C statement. If Point is at the | |
1303 end of a statement, move to the end of the next statement. With prefix | |
1304 argument @var{n}, move forward @var{n} @minus{} 1 statements. | |
1305 | |
1306 If Point is within a string or comment, or next to a comment (only | |
1307 whitespace between them), this command moves by sentences instead of | |
1308 statements. | |
1309 | |
1310 When called from a program, this function takes two optional arguments: | |
1311 the numeric prefix argument, and a buffer position limit (don't move | |
1312 past that place). | |
1313 | |
1314 @item M-x c-forward-into-nomenclature | |
1315 @findex c-forward-into-nomenclature | |
1316 @findex forward-into-nomenclature (c-) | |
1317 A popular programming style, especially for object-oriented languages | |
1318 such as C++ is to write symbols in a mixed case format, where the first | |
1319 letter of each word is capitalized, and not separated by underscores. | |
1320 E.g. @samp{SymbolsWithMixedCaseAndNoUnderlines}. | |
1321 | |
1322 This command moves Point forward to end of a C++ nomenclature | |
1323 section or word. With prefix argument @var{n}, move @var{n} times. | |
1324 | |
1325 @item M-x c-backward-into-nomenclature | |
1326 @findex c-backward-into-nomenclature | |
1327 @findex backward-into-nomenclature (c-) | |
1328 Move Point backward to beginning of a C++ nomenclature | |
1329 section or word. With prefix argument @var{n}, move @var{n} times. If | |
1330 @var{n} is negative, move forward. | |
1331 | |
1332 @kindex C-c : | |
1333 @findex c-scope-operator | |
1334 @findex scope-operator (c-) | |
1335 @item C-c : (c-scope-operator) | |
1336 In C++, it is also sometimes desirable to insert the double-colon scope | |
1337 operator without performing the electric behavior of colon insertion. | |
1338 @kbd{C-c :} does just this. | |
1339 | |
1340 @end table | |
1341 | |
1342 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
1343 @node Customizing Indentation, Syntactic Symbols, Commands, Top | |
1208 @comment node-name, next, previous,up | 1344 @comment node-name, next, previous,up |
1209 | 1345 |
1210 @chapter Customizing Indentation | 1346 @chapter Customizing Indentation |
1211 @cindex Customizing Indentation | 1347 @cindex Customizing Indentation |
1212 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 1348 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
1224 @xref{Styles} for an explanation of how to set up named styles. | 1360 @xref{Styles} for an explanation of how to set up named styles. |
1225 | 1361 |
1226 @cindex c-basic-offset | 1362 @cindex c-basic-offset |
1227 @cindex basic-offset (c-) | 1363 @cindex basic-offset (c-) |
1228 As mentioned previously, the variable @code{c-offsets-alist} is an | 1364 As mentioned previously, the variable @code{c-offsets-alist} is an |
1229 association list between syntactic symbols and the offsets to be applied | 1365 association list of syntactic symbols and the offsets to be applied for |
1230 for those symbols. In fact, these offset values can be an integer, a | 1366 those symbols. In fact, these offset values can be any of an integer, |
1231 function or variable name, or one of the following symbols: @code{+}, | 1367 a function or variable name, or one of the following symbols: @code{+}, |
1232 @code{-}, @code{++}, @code{--}, @code{*}, or @code{/}. These symbols | 1368 @code{-}, @code{++}, @code{--}, @code{*}, or @code{/}. These symbols |
1233 describe offset in multiples of the value of the variable | 1369 describe offset in multiples of the value of the variable |
1234 @code{c-basic-offset}. By defining a style's indentation in terms of | 1370 @code{c-basic-offset}. By defining a style's indentation in terms of |
1235 this fundamental variable, you can change the amount of whitespace given | 1371 this fundamental variable, you can change the amount of whitespace given |
1236 to an indentation level while leaving the same relationship between | 1372 to an indentation level while leaving the same relationship between |
1237 levels. Here are multiples of @code{c-basic-offset} that the special | 1373 levels. Here are the values that the special |
1238 symbols correspond to: | 1374 symbols correspond to: |
1239 | 1375 |
1240 @itemize @bullet | 1376 @table @code |
1241 | 1377 |
1242 @item | 1378 @item + |
1243 @code{+ } = @code{c-basic-offset} times 1 | 1379 @code{c-basic-offset} times 1 |
1244 @item | 1380 @item - |
1245 @code{- } = @code{c-basic-offset} times -1 | 1381 @code{c-basic-offset} times -1 |
1246 @item | 1382 @item ++ |
1247 @code{++} = @code{c-basic-offset} times 2 | 1383 @code{c-basic-offset} times 2 |
1248 @item | 1384 @item -- |
1249 @code{--} = @code{c-basic-offset} times -2 | 1385 @code{c-basic-offset} times -2 |
1250 @item | 1386 @item * |
1251 @code{* } = @code{c-basic-offset} times 0.5 | 1387 @code{c-basic-offset} times 0.5 |
1252 @item | 1388 @item / |
1253 @code{/ } = @code{c-basic-offset} times -0.5 | 1389 @code{c-basic-offset} times -0.5 |
1254 | 1390 |
1255 @end itemize | 1391 @end table |
1256 | 1392 |
1257 @noindent | 1393 @noindent |
1258 So, for example, because most of the default offsets are defined in | 1394 So, for example, because most of the default offsets are defined in |
1259 terms of @code{+}, @code{-}, and @code{0}, if you like the general | 1395 terms of @code{+}, @code{-}, and @code{0}, if you like the general |
1260 indentation style, but you use 4 spaces instead of 2 spaces per level, | 1396 indentation style, but you use 4 spaces instead of 2 spaces per level, |
1276 @example | 1412 @example |
1277 @group | 1413 @group |
1278 | 1414 |
1279 int add( int val, int incr, int doit ) | 1415 int add( int val, int incr, int doit ) |
1280 @{ | 1416 @{ |
1417 if( doit ) | |
1418 @{ | |
1419 return( val + incr ); | |
1420 @} | |
1421 return( val ); | |
1422 @} | |
1423 | |
1424 @end group | |
1425 @end example | |
1426 @noindent | |
1427 to | |
1428 @example | |
1429 @group | |
1430 | |
1431 int add( int val, int incr, int doit ) | |
1432 @{ | |
1281 if( doit ) | 1433 if( doit ) |
1282 @{ | 1434 @{ |
1283 return( val + incr ); | 1435 return( val + incr ); |
1284 @} | 1436 @} |
1285 return( val ); | 1437 return( val ); |
1286 @} | 1438 @} |
1287 | 1439 |
1288 @end group | 1440 @end group |
1289 @end example | 1441 @end example |
1290 | 1442 |
1291 @noindent | |
1292 to | |
1293 @example | |
1294 @group | |
1295 | |
1296 int add( int val, int incr, int doit ) | |
1297 @{ | |
1298 if( doit ) | |
1299 @{ | |
1300 return( val + incr ); | |
1301 @} | |
1302 return( val ); | |
1303 @} | |
1304 | |
1305 @end group | |
1306 @end example | |
1307 | 1443 |
1308 To change indentation styles more radically, you will want to change the | 1444 To change indentation styles more radically, you will want to change the |
1309 value associated with the syntactic symbols in the | 1445 value associated with the syntactic symbols in the |
1310 @code{c-offsets-alist} variable. First, I'll show you how to do that | 1446 @code{c-offsets-alist} variable. First, I'll show you how to do that |
1311 interactively, then I'll describe how to make changes to your | 1447 interactively, then I'll describe how to make changes to your |
1325 @section Interactive Customization | 1461 @section Interactive Customization |
1326 @cindex Interactive Customization | 1462 @cindex Interactive Customization |
1327 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 1463 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
1328 | 1464 |
1329 As an example of how to customize indentation, let's change the | 1465 As an example of how to customize indentation, let's change the |
1330 style of example 2 above from: | 1466 style of this example@footnote{In this an subsequent examples, the |
1467 original code is formatted using the @samp{gnu} style unless otherwise | |
1468 indicated. @xref{Styles}.}: | |
1331 @example | 1469 @example |
1332 @group | 1470 @group |
1333 | 1471 |
1334 1: int add( int val, int incr, int doit ) | 1472 1: int add( int val, int incr, int doit ) |
1335 2: @{ | 1473 2: @{ |
1336 3: if( doit ) | 1474 3: if( doit ) |
1337 4: @{ | 1475 4: @{ |
1338 5: return( val + incr ); | 1476 5: return( val + incr ); |
1339 6: @} | 1477 6: @} |
1340 7: return( val ); | 1478 7: return( val ); |
1341 8: @} | 1479 8: @} |
1342 | 1480 |
1343 @end group | 1481 @end group |
1344 @end example | 1482 @end example |
1345 @noindent | 1483 @noindent |
1347 @example | 1485 @example |
1348 @group | 1486 @group |
1349 | 1487 |
1350 1: int add( int val, int incr, int doit ) | 1488 1: int add( int val, int incr, int doit ) |
1351 2: @{ | 1489 2: @{ |
1352 3: if( doit ) | 1490 3: if( doit ) |
1353 4: @{ | 1491 4: @{ |
1354 5: return( val + incr ); | 1492 5: return( val + incr ); |
1355 6: @} | 1493 6: @} |
1356 7: return( val ); | 1494 7: return( val ); |
1357 8: @} | 1495 8: @} |
1358 | 1496 |
1359 @end group | 1497 @end group |
1360 @end example | 1498 @end example |
1361 | 1499 |
1362 In other words, we want to change the indentation of braces that open a | 1500 In other words, we want to change the indentation of braces that open a |
1363 block following a condition so that the braces line up under the | 1501 block following a condition so that the braces line up under the |
1364 conditional, instead of being indented. Notice that the construct we | 1502 conditional, instead of being indented. Notice that the construct we |
1365 want to change starts on line 4. To change the indentation of a line, | 1503 want to change starts on line 4. To change the indentation of a line, |
1366 we need to see which syntactic component affect the offset calculations | 1504 we need to see which syntactic components affect the offset calculations |
1367 for that line. Hitting @kbd{C-c C-s} on line 4 yields: | 1505 for that line. Hitting @kbd{C-c C-s} on line 4 yields: |
1368 @example | 1506 @example |
1369 | 1507 |
1370 ((substatement-open . 46)) | 1508 ((substatement-open . 44)) |
1371 | 1509 |
1372 @end example | 1510 @end example |
1373 | 1511 |
1374 @findex c-set-offset | 1512 @findex c-set-offset |
1375 @findex set-offset (c-) | 1513 @findex set-offset (c-) |
1383 @code{substatement-open}, which is just the syntactic symbol we want to | 1521 @code{substatement-open}, which is just the syntactic symbol we want to |
1384 change! | 1522 change! |
1385 | 1523 |
1386 After you hit return, @code{cc-mode} will then prompt you for the new | 1524 After you hit return, @code{cc-mode} will then prompt you for the new |
1387 offset value, with the old value as the default. The default in this | 1525 offset value, with the old value as the default. The default in this |
1388 case is @samp{+}, so hit backspace to delete the @samp{+}, then hit | 1526 case is @samp{+}, but we want no extra indentation so enter |
1389 @samp{0} and @kbd{RET}. This will associate the offset 0 with the | 1527 @samp{0} and @kbd{RET}. This will associate the offset 0 with the |
1390 syntactic symbol @code{substatement-open} in the @code{c-offsets-alist} | 1528 syntactic symbol @code{substatement-open} in the @code{c-offsets-alist} |
1391 variable. | 1529 variable. |
1392 | 1530 |
1393 @findex c-indent-defun | 1531 @findex c-indent-defun |
1399 @example | 1537 @example |
1400 @group | 1538 @group |
1401 | 1539 |
1402 1: int add( int val, int incr, int doit ) | 1540 1: int add( int val, int incr, int doit ) |
1403 2: @{ | 1541 2: @{ |
1404 3: if( doit ) | 1542 3: if( doit ) |
1405 4: @{ | 1543 4: @{ |
1406 5: return( val + incr ); | 1544 5: return( val + incr ); |
1407 6: @} | 1545 6: @} |
1408 7: return( val ); | 1546 7: return( val ); |
1409 8: @} | 1547 8: @} |
1410 | 1548 |
1411 @end group | 1549 @end group |
1412 @end example | 1550 @end example |
1413 | 1551 |
1432 @vindex c++-mode-hook | 1570 @vindex c++-mode-hook |
1433 @vindex objc-mode-hook | 1571 @vindex objc-mode-hook |
1434 @vindex java-mode-hook | 1572 @vindex java-mode-hook |
1435 @cindex hooks | 1573 @cindex hooks |
1436 To make this change permanent, you need to add some lisp code to your | 1574 To make this change permanent, you need to add some lisp code to your |
1437 @file{.emacs} file. @code{cc-mode} provides four hooks that you can use | 1575 @file{.emacs} file. @code{cc-mode} provides several hooks that you can |
1438 to customize your language editing styles. Four language specific hooks | 1576 use to customize the mode according to your coding style. Each language |
1439 are provided, according to Emacs major mode conventions: | 1577 mode has its own hook, adhering to standard to Emacs major mode |
1440 @code{c-mode-hook}, @code{c++-mode-hook}, @code{objc-mode-hook}, and | 1578 conventions. There is also one general hook: |
1441 @code{java-mode-hook}. These get run as the last thing when you enter | 1579 |
1442 @code{c-mode}, @code{c++-mode}, @code{objc-mode}, or | 1580 @itemize @bullet |
1443 @code{java-mode-hook} respectively. @code{cc-mode} also provides a hook | 1581 |
1444 called @code{c-mode-common-hook} which is run by all three modes | 1582 @item |
1445 @emph{before} the language specific hook. Thus, to make changes | 1583 @code{c-mode-hook} --- for C buffers only |
1446 consistently across all supported @code{cc-mode} modes, use | 1584 @item |
1447 @code{c-mode-common-hook}. Most of the examples in this section will | 1585 @code{c++-mode-hook} --- for C++ buffers only |
1448 assume you are using the common hook. | 1586 @item |
1587 @code{objc-mode-hook} --- for Objective-C buffers only | |
1588 @item | |
1589 @code{java-mode-hook} --- for Java buffers only | |
1590 @item | |
1591 @code{c-mode-common-hook} --- common across all languages | |
1592 | |
1593 @end itemize | |
1594 | |
1595 The language hooks get run as the last thing when you enter that | |
1596 language-specific mode. The @code{c-mode-common-hook} is run by all | |
1597 supported modes @emph{before} the language specific hook, and thus can | |
1598 contain customizations that are common across all languages. Most of | |
1599 the examples in this section will assume you are using the common | |
1600 hook@footnote{The interaction between @code{java-mode} and the hook | |
1601 variables is slightly different than for the other modes. | |
1602 @code{java-mode} sets the style (see @ref{Styles}) of the buffer to | |
1603 @samp{java} @emph{before} running the @code{c-mode-common-hook} or | |
1604 @code{java-mode-hook}. You need to be aware of this so any style | |
1605 settings in @code{c-mode-common-hook} doesn't clobber your Java style.}. | |
1449 | 1606 |
1450 Here's a simplified example of what you can add to your @file{.emacs} | 1607 Here's a simplified example of what you can add to your @file{.emacs} |
1451 file to make the changes described in the previous section | 1608 file to make the changes described in the previous section |
1452 (@ref{Interactive Customization}) more permanent. See the Emacs | 1609 (@ref{Interactive Customization}) more permanent. See the Emacs |
1453 manuals for more information on customizing Emacs via hooks. | 1610 manuals for more information on customizing Emacs via hooks. |
1468 @end example | 1625 @end example |
1469 | 1626 |
1470 For complex customizations, you will probably want to set up a | 1627 For complex customizations, you will probably want to set up a |
1471 @emph{style} that groups all your customizations under a single | 1628 @emph{style} that groups all your customizations under a single |
1472 name. | 1629 name. |
1473 | |
1474 The offset value can also be a function, and this is how power users | |
1475 gain enormous flexibility in customizing indentation. @xref{Advanced | |
1476 Customizations} for details. | |
1477 | 1630 |
1478 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 1631 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
1479 @node Styles, Advanced Customizations, Permanent Customization, Customizing Indentation | 1632 @node Styles, Advanced Customizations, Permanent Customization, Customizing Indentation |
1480 @comment node-name, next, previous,up | 1633 @comment node-name, next, previous,up |
1481 | 1634 |
1490 C code. Some shops are more lenient, allowing some variety of coding | 1643 C code. Some shops are more lenient, allowing some variety of coding |
1491 styles, and as programmers come and go, there could be a number of | 1644 styles, and as programmers come and go, there could be a number of |
1492 styles in use. For this reason, @code{cc-mode} makes it convenient for | 1645 styles in use. For this reason, @code{cc-mode} makes it convenient for |
1493 you to set up logical groupings of customizations called @dfn{styles}, | 1646 you to set up logical groupings of customizations called @dfn{styles}, |
1494 associate a single name for any particular style, and pretty easily | 1647 associate a single name for any particular style, and pretty easily |
1495 start editing new or existing code using these styles. This chapter | 1648 start editing new or existing code using these styles. This section |
1496 describes how to set up styles and how to edit your C code using styles. | 1649 describes how to set up styles and how to edit your C code using styles. |
1497 | 1650 |
1498 @menu | 1651 @menu |
1499 * Built-in Styles:: | 1652 * Built-in Styles:: |
1500 * Adding Styles:: | 1653 * Adding Styles:: |
1515 already built-in. These include: | 1668 already built-in. These include: |
1516 | 1669 |
1517 @itemize @bullet | 1670 @itemize @bullet |
1518 @item | 1671 @item |
1519 @cindex GNU style | 1672 @cindex GNU style |
1520 @code{gnu} -- coding style blessed by the Free Software Foundation | 1673 @code{gnu} --- coding style blessed by the Free Software Foundation |
1521 for C code in GNU programs. | 1674 for C code in GNU programs. |
1522 | 1675 |
1523 @item | 1676 @item |
1524 @cindex K&R style | 1677 @cindex K&R style |
1525 @code{k&r} -- The classic Kernighan and Ritchie style for C code. | 1678 @code{k&r} --- The classic Kernighan and Ritchie style for C code. |
1526 | 1679 |
1527 @item | 1680 @item |
1528 @cindex BSD style | 1681 @cindex BSD style |
1529 @code{bsd} -- @strong{<TBD> Anybody know anything about the history of | 1682 @code{bsd} --- Also known as ``Allman style'' after Eric Allman. |
1530 this style?} | 1683 |
1684 @item | |
1685 @cindex Whitesmith style | |
1686 @code{whitesmith} --- Popularized by the examples that came with | |
1687 Whitesmiths C, an early commercial C compiler. | |
1531 | 1688 |
1532 @item | 1689 @item |
1533 @cindex Stroustrup style | 1690 @cindex Stroustrup style |
1534 @code{stroustrup} -- The classic Stroustrup style for C++ code. | 1691 @code{stroustrup} --- The classic Stroustrup style for C++ code. |
1535 | |
1536 @item | |
1537 @cindex Whitesmith style | |
1538 @code{whitesmith} -- @strong{<TBD> Anybody know anything about the history of | |
1539 this style?} | |
1540 | 1692 |
1541 @item | 1693 @item |
1542 @cindex Ellemtel style | 1694 @cindex Ellemtel style |
1543 @code{ellemtel} -- Popular C++ coding standards as defined by | 1695 @code{ellemtel} --- Popular C++ coding standards as defined by |
1544 ``Programming in C++, Rules and Recommendations'', Erik Nyquist and Mats | 1696 ``Programming in C++, Rules and Recommendations'', Erik Nyquist and Mats |
1545 Henricson, Ellemtel @footnote{This document is ftp'able from | 1697 Henricson, Ellemtel @footnote{This document is ftp'able from |
1546 @code{euagate.eua.ericsson.se}}. | 1698 @code{euagate.eua.ericsson.se}}. |
1547 | 1699 |
1548 @item | 1700 @item |
1549 @cindex Java style | 1701 @cindex Java style |
1550 @cindex java-mode | 1702 @cindex java-mode |
1551 @code{java} -- The style for editing Java code. Note that this style is | 1703 @code{java} --- The style for editing Java code. Note that this style is |
1552 automatically installed when you enter @code{java-mode}. | 1704 automatically installed when you enter @code{java-mode}. |
1553 | |
1554 @item | |
1555 @cindex CC-MODE style | |
1556 @code{CC-MODE} -- Style that encapsulates the default values of the | |
1557 @code{cc-mode} variables. See below for details. | |
1558 | 1705 |
1559 @end itemize | 1706 @end itemize |
1560 | 1707 |
1561 @findex c-set-style | 1708 @findex c-set-style |
1562 @findex set-style (c-) | 1709 @findex set-style (c-) |
1572 @noindent | 1719 @noindent |
1573 Note that all style names are case insensitive, even the ones you define. | 1720 Note that all style names are case insensitive, even the ones you define. |
1574 | 1721 |
1575 Setting a style in this way does @emph{not} automatically re-indent your | 1722 Setting a style in this way does @emph{not} automatically re-indent your |
1576 file. For commands that you can use to view the effect of your changes, | 1723 file. For commands that you can use to view the effect of your changes, |
1577 see @ref{Indentation Commands}. | 1724 see @ref{Commands}. |
1578 | 1725 |
1579 Once you find a built-in style you like, you can make the change | 1726 Once you find a built-in style you like, you can make the change |
1580 permanent by adding a call to your @file{.emacs} file. Let's say for | 1727 permanent by adding a call to your @file{.emacs} file. Let's say for |
1581 example that you want to use the @code{ellemtel} style in all your | 1728 example that you want to use the @samp{ellemtel} style in all your |
1582 files. You would add this: | 1729 files. You would add this: |
1583 @example | 1730 @example |
1584 @group | 1731 @group |
1585 | 1732 |
1586 (defun my-c-mode-common-hook () | 1733 (defun my-c-mode-common-hook () |
1587 ;; use Ellemtel style for all C, C++, and Objective-C code | 1734 ;; use Ellemtel style for all C like languages |
1588 (c-set-style "ellemtel") | 1735 (c-set-style "ellemtel") |
1589 ;; other customizations can go here | 1736 ;; other customizations can go here |
1590 ) | 1737 ) |
1591 (add-hook 'c-mode-common-hook 'my-c-mode-common-hook) | 1738 (add-hook 'c-mode-common-hook 'my-c-mode-common-hook) |
1592 | 1739 |
1593 @end group | 1740 @end group |
1594 @end example | 1741 @end example |
1595 | 1742 |
1596 There is one other special style you can use, called @code{CC-MODE}. | 1743 There is one other special style you can use, called @samp{cc-mode} |
1597 This is a style that is calculated by @code{cc-mode} when it starts up. | 1744 style. This style is special because all other styles implicitly |
1598 The @code{CC-MODE} style is also special because all other styles | 1745 inherit from it; in other words, whenever you set a style, |
1599 implicitly inherit from it; in other words, whenever you set a style, | 1746 @samp{cc-mode} is applied before the one you selected. This means |
1600 @code{cc-mode} first re-instates the @code{CC-MODE} style, then applies | 1747 your style need only define the differences between it and |
1601 your new style configurations. | 1748 @samp{cc-mode} style. |
1602 | 1749 |
1603 The @code{CC-MODE} style exists because once @code{cc-mode} initializes, | 1750 Note that for BOCM compatibility, @samp{gnu} is the default |
1604 it institutes the @code{gnu} style for compatibility with BOCM's | 1751 style, and any non-style based customizations you make (i.e. in |
1605 defaults. Any customizations you make in mode hooks will be based on | 1752 @code{c-mode-common-hook} in your |
1606 the @code{gnu} style, unless you first do a @code{c-set-style} to | 1753 @file{.emacs} file) will be based on @samp{gnu} style unless you do |
1607 @code{CC-MODE} or some other built-in style. | 1754 a @code{c-set-style} as the first thing in your hook. |
1608 | 1755 |
1609 | 1756 |
1610 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 1757 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
1611 @node Adding Styles, File Styles, Built-in Styles, Styles | 1758 @node Adding Styles, File Styles, Built-in Styles, Styles |
1612 @comment node-name, next, previous,up | 1759 @comment node-name, next, previous,up |
1618 @vindex c-style-alist | 1765 @vindex c-style-alist |
1619 @vindex style-alist (c-) | 1766 @vindex style-alist (c-) |
1620 @findex c-add-style | 1767 @findex c-add-style |
1621 @findex add-style (c-) | 1768 @findex add-style (c-) |
1622 If none of the built-in styles is appropriate, you'll probably want to | 1769 If none of the built-in styles is appropriate, you'll probably want to |
1623 add a new style definition. Styles are kept in the @code{c-style-alist} | 1770 add a new @dfn{style definition}. Styles are kept in the |
1624 variable, but you probably won't want to modify this variable directly. | 1771 @code{c-style-alist} variable, but you should never modify this variable |
1625 @code{cc-mode} provides a function, called @code{c-add-style}, that you | 1772 directly. Instead, @code{cc-mode} provides the function |
1626 can use to easily add new styles or update existing styles. This | 1773 @code{c-add-style} that you can use to easily add new styles or change |
1627 function takes two arguments, a @var{stylename} string, and an | 1774 existing styles. This function takes two arguments, a @var{stylename} |
1628 association list @var{description} of style customizations. If | 1775 string, and an association list @var{description} of style |
1629 @var{stylename} is not already in @code{c-style-alist}, the new style is | 1776 customizations. If @var{stylename} is not already in |
1630 added, otherwise the style already associated with @var{stylename} is | 1777 @code{c-style-alist}, the new style is added, otherwise the style is |
1631 changed to the new @var{description}. This function also takes an | 1778 changed to the new @var{description}. |
1632 optional third argument, which if non-@code{nil}, automatically | 1779 This function also takes an optional third argument, which if |
1633 institutes the new style in the current buffer. | 1780 non-@code{nil}, automatically applies the new style to the current |
1781 buffer. | |
1634 | 1782 |
1635 The sample @file{.emacs} file provides a concrete example of how a new | 1783 The sample @file{.emacs} file provides a concrete example of how a new |
1636 style can be added and automatically set. @xref{Sample .emacs File}. | 1784 style can be added and automatically set. @xref{Sample .emacs File}. |
1637 | 1785 |
1638 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 1786 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
1654 @vindex c-file-style | 1802 @vindex c-file-style |
1655 @vindex file-style (c-) | 1803 @vindex file-style (c-) |
1656 @vindex c-file-offsets | 1804 @vindex c-file-offsets |
1657 @vindex file-offsets (c-) | 1805 @vindex file-offsets (c-) |
1658 | 1806 |
1659 The variable @code{c-file-style} can be set to a style name string as | 1807 The variable @code{c-file-style} can be set to a style name string. |
1660 described in @ref{Built-in Styles}. When the file is visited, | 1808 When the file is visited, @code{cc-mode} will automatically set the |
1661 @code{cc-mode} will automatically set the file's style to this style | 1809 file's style to this style using @code{c-set-style}. |
1662 using @code{c-set-style}. | |
1663 | 1810 |
1664 @vindex c-offsets-alist | 1811 @vindex c-offsets-alist |
1665 @vindex offsets-alist (c-) | 1812 @vindex offsets-alist (c-) |
1666 @findex c-set-offset | 1813 @findex c-set-offset |
1667 @findex set-offset (c-) | 1814 @findex set-offset (c-) |
1669 similar to what is allowed in @code{c-offsets-alist}. When the file is | 1816 similar to what is allowed in @code{c-offsets-alist}. When the file is |
1670 visited, @code{cc-mode} will automatically institute these offets using | 1817 visited, @code{cc-mode} will automatically institute these offets using |
1671 @code{c-set-offset}. | 1818 @code{c-set-offset}. |
1672 | 1819 |
1673 Note that file style settings (i.e. @code{c-file-style}) are applied | 1820 Note that file style settings (i.e. @code{c-file-style}) are applied |
1674 before file offset settings (i.e. @code{c-file-offsets}). | 1821 before file offset settings (i.e. @code{c-file-offsets})@footnote{File |
1822 styles are only supported since XEmacs 19.12 and Emacs 19.29. They work | |
1823 via the standard Emacs hook variable @code{hack-local-variables-hook}.}. | |
1675 | 1824 |
1676 | 1825 |
1677 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 1826 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
1678 @node Advanced Customizations, , Styles, Customizing Indentation | 1827 @node Advanced Customizations, , Styles, Customizing Indentation |
1679 @comment node-name, next, previous,up | 1828 @comment node-name, next, previous,up |
1685 @vindex c-style-alist | 1834 @vindex c-style-alist |
1686 @vindex style-alist (c-) | 1835 @vindex style-alist (c-) |
1687 @vindex c-basic-offset | 1836 @vindex c-basic-offset |
1688 @vindex basic-offset (c-) | 1837 @vindex basic-offset (c-) |
1689 For most users, @code{cc-mode} will support their coding styles with | 1838 For most users, @code{cc-mode} will support their coding styles with |
1690 very little need for customizations. Usually, one of the standard | 1839 very little need for more advanced customizations. Usually, one of the |
1691 styles defined in @code{c-style-alist} will do the trick. At most, | 1840 standard styles defined in @code{c-style-alist} will do the trick. At |
1692 perhaps one of the syntactic symbol offsets will need to be tweaked | 1841 most, perhaps one of the syntactic symbol offsets will need to be |
1693 slightly, or maybe @code{c-basic-offset} will need to be changed. | 1842 tweaked slightly, or maybe @code{c-basic-offset} will need to be |
1694 However, some styles require a more advanced ability for customization, | 1843 changed. However, some styles require a more flexible framework for |
1695 and one of the real strengths of @code{cc-mode} is that the syntactic | 1844 customization, and one of the real strengths of @code{cc-mode} is that |
1696 analysis model provides a very flexible framework for customizing | 1845 the syntactic analysis model provides just such a framework. This allows |
1697 indentation. This allows you to perform special indentation calculations | 1846 you to implement special indentation calculations for situations not |
1698 for situations not handled by the mode directly. | 1847 handled by the mode directly. |
1699 | 1848 |
1700 @menu | 1849 @menu |
1701 * Custom Indentation Functions:: | 1850 * Custom Indentation Functions:: |
1702 * Custom Brace and Colon Hanging:: | 1851 * Custom Brace and Colon Hanging:: |
1703 * Customizing Semi-colons and Commas:: | 1852 * Customizing Semi-colons and Commas:: |
1731 | 1880 |
1732 @end group | 1881 @end group |
1733 @end example | 1882 @end example |
1734 | 1883 |
1735 In this example, lines 4 through 6 are assigned the @code{stream-op} | 1884 In this example, lines 4 through 6 are assigned the @code{stream-op} |
1736 syntactic symbol. If @code{stream-op} had an offset of @code{+}, and | 1885 syntactic symbol. Here, @code{stream-op} has an offset of @code{+}, and |
1737 @code{c-basic-offset} was 2, lines 4 through 6 would simply be indented | 1886 with a @code{c-basic-offset} of 2, you can see that lines 4 through 6 |
1738 two spaces to the right of line 3. But perhaps we'd like @code{cc-mode} | 1887 are simply indented two spaces to the right of line 3. But perhaps we'd |
1739 to be a little more intelligent so that it offsets the stream operators | 1888 like @code{cc-mode} to be a little more intelligent so that it lines up |
1740 under the operator in line 3. To do this, we have to write a custom | 1889 all the @samp{<<} symbols in lines 3 through 6. To do this, we have |
1741 indentation function which finds the column of first stream operator on | 1890 to write a custom indentation function which finds the column of first |
1742 the first line of the statement. Here is the lisp code (from the | 1891 stream operator on the first line of the statement. Here is the lisp |
1743 @file{cc-mode.el} source file) that implements this: | 1892 code (from the @file{cc-mode.el} source file) that implements this: |
1744 @example | 1893 @example |
1745 @group | 1894 @group |
1746 | 1895 |
1747 (defun c-lineup-streamop (langelem) | 1896 (defun c-lineup-streamop (langelem) |
1748 ;; lineup stream operators | 1897 ;; lineup stream operators |
1758 @end example | 1907 @end example |
1759 @noindent | 1908 @noindent |
1760 Custom indent functions take a single argument, which is a syntactic | 1909 Custom indent functions take a single argument, which is a syntactic |
1761 component cons cell (see @ref{Syntactic Analysis}). The | 1910 component cons cell (see @ref{Syntactic Analysis}). The |
1762 function returns an integer offset value that will be added to the | 1911 function returns an integer offset value that will be added to the |
1763 running total indentation for the lne. Note that what actually gets | 1912 running total indentation for the line. Note that what actually gets |
1764 returned is the difference between the column that the first stream | 1913 returned is the difference between the column that the first stream |
1765 operator is on, and the column of the buffer relative position passed in | 1914 operator is on, and the column of the buffer relative position passed in |
1766 the function's argument. Remember that @code{cc-mode} automatically | 1915 the function's argument. Remember that @code{cc-mode} automatically |
1767 adds in the column of the component's relative buffer position and we | 1916 adds in the column of the component's relative buffer position and we |
1768 don't want that value added into the final total twice. | 1917 don't want that value added into the final total twice. |
1800 | 1949 |
1801 @vindex c-offsets-alist | 1950 @vindex c-offsets-alist |
1802 @vindex offsets-alist (c-) | 1951 @vindex offsets-alist (c-) |
1803 Custom indentation functions can be as simple or as complex as you like, | 1952 Custom indentation functions can be as simple or as complex as you like, |
1804 and any syntactic symbol that appears in @code{c-offsets-alist} can have | 1953 and any syntactic symbol that appears in @code{c-offsets-alist} can have |
1805 a custom indentation function associated with it. | 1954 a custom indentation function associated with it. @code{cc-mode} comes |
1955 with several standard custom indentation functions, not all of which are | |
1956 used by the default styles. | |
1957 | |
1958 @itemize @bullet | |
1959 @item | |
1960 @findex c-lineup-arglist | |
1961 @findex lineup-arglist (c-) | |
1962 @code{c-lineup-arglist} --- lines up function argument lines under the | |
1963 argument on the previous line. | |
1964 | |
1965 @item | |
1966 @findex c-lineup-arglist-intro-after-paren | |
1967 @findex lineup-arglist-intro-after-paren (c-) | |
1968 @code{c-lineup-arglist-intro-after-paren} --- similar to | |
1969 @code{c-lineup-arglist}, but works for argument lists that begin with an | |
1970 open parenthesis followed by a newline. | |
1971 | |
1972 @item | |
1973 @findex c-lineup-arglist-close-under-paren | |
1974 @findex lineup-arglist-close-under-paren (c-) | |
1975 @code{c-lineup-arglist-close-under-paren} --- set your | |
1976 @code{arglist-close} syntactic symbol to this line-up function so that | |
1977 parentheses that close argument lists will line up under the parenthesis | |
1978 that opened the argument list. | |
1979 | |
1980 @item | |
1981 @findex c-lineup-streamop | |
1982 @findex lineup-streamop (c-) | |
1983 @code{c-lineup-streamop} --- lines up C++ stream operators | |
1984 (e.g. @samp{<<} and @samp{>>}). | |
1985 | |
1986 @item | |
1987 @findex c-lineup-multi-inher | |
1988 @findex lineup-multi-inher (c-) | |
1989 @code{c-lineup-multi-inher} --- lines up multiple inheritance lines. | |
1990 | |
1991 @item | |
1992 @findex c-lineup-C-comments | |
1993 @findex lineup-C-comments (c-) | |
1994 @code{c-lineup-C-comments} --- lines up C block comment continuation | |
1995 lines. | |
1996 | |
1997 @item | |
1998 @findex c-lineup-comment | |
1999 @findex lineup-comment (c-) | |
2000 @vindex c-comment-only-line-offset | |
2001 @vindex comment-only-line-offset (c-) | |
2002 @code{c-lineup-comment} --- implements the old comment line up behavior | |
2003 specified by the variable @code{c-comment-only-line-offset}. | |
2004 | |
2005 @item | |
2006 @findex c-lineup-runin-statements | |
2007 @findex lineup-runin-statements (c-) | |
2008 @code{c-lineup-runin-statements} --- lines up @code{statement}s for coding | |
2009 standards which place the first statement in a block on the same line as | |
2010 the block opening brace. | |
2011 | |
2012 @item | |
2013 @findex c-lineup-math | |
2014 @findex lineup-math (c-) | |
2015 @code{c-lineup-math} --- lines up math @code{statement-cont} lines under | |
2016 the previous line after the equals sign. | |
2017 | |
2018 @item | |
2019 @findex c-lineup-ObjC-method-call | |
2020 @findex lineup-ObjC-method-call (c-) | |
2021 @code{c-lineup-ObjC-method-call} --- for Objective-C code, lines up | |
2022 selector arguments just after the message receiver. | |
2023 | |
2024 @item | |
2025 @findex c-lineup-ObjC-method-args | |
2026 @findex lineup-ObjC-method-args (c-) | |
2027 @code{c-lineup-ObjC-method-args} --- for Objective-C code, lines up the | |
2028 colons that separate arguments by aligning colons vertically. | |
2029 | |
2030 @item | |
2031 @findex c-lineup-ObjC-method-args-2 | |
2032 @findex lineup-ObjC-method-args-2 (c-) | |
2033 @code{c-lineup-ObjC-method-args-2} --- similar to | |
2034 @code{c-lineup-ObjC-method-args} but lines up the colon on the current | |
2035 line with the colon on the previous line. | |
2036 | |
2037 @end itemize | |
1806 | 2038 |
1807 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 2039 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
1808 @node Custom Brace and Colon Hanging, Customizing Semi-colons and Commas, Custom Indentation Functions, Advanced Customizations | 2040 @node Custom Brace and Colon Hanging, Customizing Semi-colons and Commas, Custom Indentation Functions, Advanced Customizations |
1809 @comment node-name, next, previous,up | 2041 @comment node-name, next, previous,up |
1810 | 2042 |
1814 | 2046 |
1815 @vindex c-hanging-braces-alist | 2047 @vindex c-hanging-braces-alist |
1816 @vindex hanging-braces-alist (c-) | 2048 @vindex hanging-braces-alist (c-) |
1817 Syntactic symbols aren't the only place where you can customize | 2049 Syntactic symbols aren't the only place where you can customize |
1818 @code{cc-mode} with the lisp equivalent of callback functions. Brace | 2050 @code{cc-mode} with the lisp equivalent of callback functions. Brace |
1819 hanginess can also be determined by custom functions associated with | 2051 ``hanginess'' can also be determined by custom functions associated with |
1820 syntactic symbols on the @code{c-hanging-braces-alist} variable. | 2052 syntactic symbols on the @code{c-hanging-braces-alist} variable. |
1821 Remember that @var{ACTION}'s are typically a list containing some | 2053 Remember that @var{ACTION}'s are typically a list containing some |
1822 combination of the symbols @code{before} and @code{after} (see | 2054 combination of the symbols @code{before} and @code{after} (see |
1823 @ref{Hanging Braces}). However, an @var{ACTION} can also be a function | 2055 @ref{Hanging Braces}). However, an @var{ACTION} can also be a function |
1824 symbol which gets called when a brace matching that syntactic symbol is | 2056 symbol which gets called when a brace matching that syntactic symbol is |
1828 These @var{ACTION} functions are called with two arguments: the | 2060 These @var{ACTION} functions are called with two arguments: the |
1829 syntactic symbol for the brace, and the buffer position at which the | 2061 syntactic symbol for the brace, and the buffer position at which the |
1830 brace was inserted. The @var{ACTION} function is expected to return a | 2062 brace was inserted. The @var{ACTION} function is expected to return a |
1831 list containing some combination of @code{before} and @code{after}. The | 2063 list containing some combination of @code{before} and @code{after}. The |
1832 function can also return @code{nil}. This return value has the normal | 2064 function can also return @code{nil}. This return value has the normal |
1833 brace hanging semantics described in @ref{Hanging Braces}. | 2065 brace hanging semantics. |
1834 | 2066 |
1835 As an example, @code{cc-mode} itself uses this feature to dynamically | 2067 As an example, @code{cc-mode} itself uses this feature to dynamically |
1836 determine the hanginess of braces which close @samp{do-while} | 2068 determine the hanginess of braces which close ``do-while'' |
1837 constructs: | 2069 constructs: |
1838 @example | 2070 @example |
1839 @group | 2071 @group |
1840 | 2072 |
1841 void do_list( int count, char** atleast_one_string ) | 2073 void do_list( int count, char** atleast_one_string ) |
1842 @{ | 2074 @{ |
1843 int i=0; | 2075 int i=0; |
1844 do @{ | 2076 do @{ |
1845 handle_string( atleast_one_string( i )); | 2077 handle_string( atleast_one_string[i] ); |
1846 i++; | 2078 i++; |
1847 @} while( i < count ); | 2079 @} while( i < count ); |
1848 @} | 2080 @} |
1849 | 2081 |
1850 @end group | 2082 @end group |
1853 @findex c-snug-do-while | 2085 @findex c-snug-do-while |
1854 @findex snug-do-while (c-) | 2086 @findex snug-do-while (c-) |
1855 @code{cc-mode} assigns the @code{block-close} syntactic symbol to the | 2087 @code{cc-mode} assigns the @code{block-close} syntactic symbol to the |
1856 brace that closes the @code{do} construct, and normally we'd like the | 2088 brace that closes the @code{do} construct, and normally we'd like the |
1857 line that follows a @code{block-close} brace to begin on a separate | 2089 line that follows a @code{block-close} brace to begin on a separate |
1858 line. However, with @samp{do-while} constructs, we want the | 2090 line. However, with ``do-while'' constructs, we want the |
1859 @code{while} clause to follow the closing brace. To do this, we | 2091 @code{while} clause to follow the closing brace. To do this, we |
1860 associate the @code{block-close} symbol with the @var{ACTION} function | 2092 associate the @code{block-close} symbol with the @var{ACTION} function |
1861 @code{c-snug-do-while}: | 2093 @code{c-snug-do-while}: |
1862 @example | 2094 @example |
1863 | 2095 |
1879 '(before) | 2111 '(before) |
1880 '(before after))))) | 2112 '(before after))))) |
1881 | 2113 |
1882 @end example | 2114 @end example |
1883 | 2115 |
1884 This function simply looks to see if the brace closes a @samp{do-while} | 2116 This function simply looks to see if the brace closes a ``do-while'' |
1885 clause and if so, returns the list @samp{@code{(before)}} indicating | 2117 clause and if so, returns the list @samp{(before)} indicating |
1886 that a newline should be inserted before the brace, but not after it. | 2118 that a newline should be inserted before the brace, but not after it. |
1887 In all other cases, it returns the list @samp{@code{(before after)}} so | 2119 In all other cases, it returns the list @samp{(before after)} so |
1888 that the brace appears on a line by itself. | 2120 that the brace appears on a line by itself. |
1889 | 2121 |
1890 @vindex c-syntactic-context | 2122 @vindex c-syntactic-context |
1891 @vindex syntactic-context (c-) | 2123 @vindex syntactic-context (c-) |
1892 During the call to the brace hanging @var{ACTION} function, the variable | 2124 During the call to the brace hanging @var{ACTION} function, the variable |
1918 that are called in the order they appear. Each function is called with | 2150 that are called in the order they appear. Each function is called with |
1919 zero arguments, and is expected to return one of the following values: | 2151 zero arguments, and is expected to return one of the following values: |
1920 | 2152 |
1921 @itemize @bullet | 2153 @itemize @bullet |
1922 @item | 2154 @item |
1923 non-@code{nil} -- A newline is inserted, and no more functions from the | 2155 non-@code{nil} --- A newline is inserted, and no more functions from the |
1924 list are called. | 2156 list are called. |
1925 | 2157 |
1926 @item | 2158 @item |
1927 @code{stop} -- No more functions from the list are called, but no | 2159 @code{stop} --- No more functions from the list are called, but no |
1928 newline is inserted. | 2160 newline is inserted. |
1929 | 2161 |
1930 @item | 2162 @item |
1931 @code{nil} -- No determination is made, and the next function in the | 2163 @code{nil} --- No determination is made, and the next function in the |
1932 list is called. | 2164 list is called. |
1933 | 2165 |
1934 @end itemize | 2166 @end itemize |
1935 | 2167 |
1936 If every function in the list is called without a determination being | 2168 If every function in the list is called without a determination being |
1937 made, then no newline is added. The default value for this variable is a | 2169 made, then no newline is added. The default value for this variable is a |
1938 list containing a single function which inserts newlines only after | 2170 list containing a single function which inserts newlines only after |
1939 semi-colons which do not appear inside parenthesis lists (i.e. those | 2171 semi-colons which do not appear inside parenthesis lists (i.e. those |
1940 that separate @code{for}-clause statements). | 2172 that separate @code{for}-clause statements). |
1941 | 2173 |
2174 Here's an example of a criteria function that will prevent newlines from | |
2175 being inserted after semicolons when there is a non-blank following | |
2176 line. Otherwise, it makes no determination: | |
2177 | |
2178 @example | |
2179 @group | |
2180 | |
2181 (defun my-semicolon-criteria () | |
2182 (save-excursion | |
2183 (if (and (= last-command-char ?\;) | |
2184 (zerop (forward-line 1)) | |
2185 (not (looking-at "^[ \t]*$"))) | |
2186 'stop | |
2187 nil))) | |
2188 | |
2189 @end group | |
2190 @end example | |
2191 | |
2192 | |
1942 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 2193 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
1943 @node Other Special Indentations, , Customizing Semi-colons and Commas, Advanced Customizations | 2194 @node Other Special Indentations, , Customizing Semi-colons and Commas, Advanced Customizations |
1944 @comment node-name, next, previous,up | 2195 @comment node-name, next, previous,up |
1945 | 2196 |
1946 @subsection Other Special Indentations | 2197 @subsection Other Special Indentations |
1947 @cindex Customizing Semi-colons and Commas | 2198 @cindex Customizing Semi-colons and Commas |
1948 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 2199 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2200 | |
2201 @vindex c-label-minimum-indentation | |
2202 @vindex label-minimum-indentation (c-) | |
2203 In @samp{gnu} style (see @ref{Built-in Styles}), a minimum indentation | |
2204 is imposed on lines with @code{label} or @code{case-label} syntax. This | |
2205 minimum indentation is controlled by the variable | |
2206 @code{c-label-minimum-indentation}. The default value for this variable | |
2207 is 1. | |
1949 | 2208 |
1950 @vindex c-special-indent-hook | 2209 @vindex c-special-indent-hook |
1951 @vindex special-indent-hook (c-) | 2210 @vindex special-indent-hook (c-) |
1952 One other customization variable is available in @code{cc-mode}: | 2211 One other customization variable is available in @code{cc-mode}: |
1953 @code{c-special-indent-hook}. This is a standard hook variable that is | 2212 @code{c-special-indent-hook}. This is a standard hook variable that is |
1954 called after every line is indented by @code{cc-mode}. You can use it | 2213 called after every line is indented by @code{cc-mode}. You can use it |
1955 to do any special indentation or line adjustments your style dictates, | 2214 to do any special indentation or line adjustments your style dictates, |
1956 such as adding extra indentation to constructors or destructor | 2215 such as adding extra indentation to constructors or destructor |
1957 declarations in a class definition, etc. Note however, that you should | 2216 declarations in a class definition, etc. Note however, that you should |
1958 not change point or mark inside your @code{c-special-indent-hook} | 2217 not change Point or Mark inside your @code{c-special-indent-hook} |
1959 functions (i.e. you'll probably want to wrap your function in a | 2218 functions (i.e. you'll probably want to wrap your function in a |
1960 @code{save-excursion}). | 2219 @code{save-excursion}). |
1961 | 2220 |
2221 Setting @code{c-special-indent-hook} in your style definition is handled | |
2222 slightly differently than other variables. In your style definition, | |
2223 you should set the value for | |
2224 @code{c-special-indent-hook} to a function or list of functions, which | |
2225 will be appended to @code{c-special-indent-hook} using @code{add-hook}. | |
2226 That way, the current setting for the buffer local value of | |
2227 @code{c-special-indent-hook} won't be overridden. | |
2228 | |
1962 | 2229 |
1963 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 2230 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
1964 @node Syntactic Symbols, Performance Issues, Customizing Indentation, Top | 2231 @node Syntactic Symbols, Performance Issues, Customizing Indentation, Top |
1965 @comment node-name, next, previous,up | 2232 @comment node-name, next, previous,up |
1966 | 2233 |
1968 @cindex Syntactic Symbols | 2235 @cindex Syntactic Symbols |
1969 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 2236 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
1970 | 2237 |
1971 @vindex c-offsets-alist | 2238 @vindex c-offsets-alist |
1972 @vindex offsets-alist (c-) | 2239 @vindex offsets-alist (c-) |
1973 The complete list of recognized syntactic symbols is described in the | 2240 |
1974 @code{c-offsets-alist} variable. This chapter will provide some | 2241 Here is a complete list of the recognized syntactic symbols as described |
1975 examples to help clarify these symbols. | 2242 in the @code{c-offsets-alist} variable, along with a brief description. |
2243 More detailed descriptions follow below. | |
2244 | |
2245 @itemize @bullet | |
2246 @item | |
2247 @code{string} --- inside multi-line string | |
2248 @item | |
2249 @code{c} --- inside a multi-line C style block comment | |
2250 @item | |
2251 @code{defun-open} --- brace that opens a function definition | |
2252 @item | |
2253 @code{defun-close} --- brace that closes a function definition | |
2254 @item | |
2255 @code{defun-block-intro} --- the first line in a top-level defun | |
2256 @item | |
2257 @code{class-open} --- brace that opens a class definition | |
2258 @item | |
2259 @code{class-close} --- brace that closes a class definition | |
2260 @item | |
2261 @code{inline-open} --- brace that opens an in-class inline method | |
2262 @item | |
2263 @code{inline-close} --- brace that closes an in-class inline method | |
2264 @item | |
2265 @code{ansi-funcdecl-cont} --- the nether region between an ANSI function | |
2266 declaration and the defun opening brace | |
2267 @item | |
2268 @code{knr-argdecl-intro} --- first line of a K&R C argument declaration | |
2269 @item | |
2270 @code{knr-argdecl} --- subsequent lines in a K&R C argument declaration | |
2271 @item | |
2272 @code{topmost-intro} --- the first line in a topmost construct definition | |
2273 @item | |
2274 @code{topmost-intro-cont} --- topmost definition continuation lines | |
2275 @item | |
2276 @code{member-init-intro} --- first line in a member initialization list | |
2277 @item | |
2278 @code{member-init-cont} --- subsequent member initialization list lines | |
2279 @item | |
2280 @code{inher-intro} --- first line of a multiple inheritance list | |
2281 @item | |
2282 @code{inher-cont} --- subsequent multiple inheritance lines | |
2283 @item | |
2284 @code{block-open} --- statement block open brace | |
2285 @item | |
2286 @code{block-close} --- statement block close brace | |
2287 @item | |
2288 @code{brace-list-open} --- open brace of an enum or static array list | |
2289 @item | |
2290 @code{brace-list-close} --- close brace of an enum or static array list | |
2291 @item | |
2292 @code{brace-list-intro} --- first line in an enum or static array list | |
2293 @item | |
2294 @code{brace-list-entry} --- subsequent lines in an enum or static array list | |
2295 @item | |
2296 @code{statement} --- a C (or like) statement | |
2297 @item | |
2298 @code{statement-cont} --- a continuation of a C (or like) statement | |
2299 @item | |
2300 @code{statement-block-intro} --- the first line in a new statement block | |
2301 @item | |
2302 @code{statement-case-intro} --- the first line in a case `block' | |
2303 @item | |
2304 @code{statement-case-open} --- the first line in a case block starting | |
2305 with brace | |
2306 @item | |
2307 @code{substatement} --- the first line after an if/while/for/do/else | |
2308 @item | |
2309 @code{substatement-open} --- the brace that opens a substatement block | |
2310 @item | |
2311 @code{case-label} --- a case or default label | |
2312 @item | |
2313 @code{access-label} --- C++ private/protected/public access label | |
2314 @item | |
2315 @code{label} --- any non-special C (or like) label | |
2316 @item | |
2317 @code{do-while-closure} --- the `while' that ends a do/while construct | |
2318 @item | |
2319 @code{else-clause} --- the `else' of an if/else construct | |
2320 @item | |
2321 @code{comment-intro} --- a line containing only a comment introduction | |
2322 @item | |
2323 @code{arglist-intro} --- the first line in an argument list | |
2324 @item | |
2325 @code{arglist-cont} --- subsequent argument list lines when no arguments | |
2326 follow on the same line as the the arglist opening paren | |
2327 @item | |
2328 @code{arglist-cont-nonempty} --- subsequent argument list lines when at | |
2329 least one argument follows on the same line as the arglist opening paren | |
2330 @item | |
2331 @code{arglist-close} --- the solo close paren of an argument list | |
2332 @item | |
2333 @code{stream-op} --- lines continuing a stream operator construct | |
2334 @item | |
2335 @code{inclass} --- the construct is nested inside a class definition | |
2336 @item | |
2337 @code{cpp-macro} --- the start of a cpp macro | |
2338 @item | |
2339 @code{friend} --- a C++ friend declaration | |
2340 @item | |
2341 @code{objc-method-intro} --- the first line of an Objective-C method definition | |
2342 @item | |
2343 @code{objc-method-args-cont} --- lines continuing an Objective-C method | |
2344 definition | |
2345 @item | |
2346 @code{objc-method-call-cont} --- lines continuing an Objective-C method call | |
2347 @item | |
2348 @code{extern-lang-open} --- brace that opens an external language block | |
2349 @item | |
2350 @code{extern-lang-close} --- brace that closes an external language block | |
2351 @item | |
2352 @code{inextern-lang} --- analogous to `inclass' syntactic symbol | |
2353 @end itemize | |
1976 | 2354 |
1977 @cindex -open syntactic symbols | 2355 @cindex -open syntactic symbols |
1978 @cindex -close syntactic symbols | 2356 @cindex -close syntactic symbols |
1979 Most syntactic symbol names follow a general naming convention. When a | 2357 Most syntactic symbol names follow a general naming convention. When a |
1980 line begins with an open or close brace, the syntactic symbol will | 2358 line begins with an open or close brace, the syntactic symbol will |
2007 9: @} | 2385 9: @} |
2008 | 2386 |
2009 @end group | 2387 @end group |
2010 @end example | 2388 @end example |
2011 | 2389 |
2390 @cindex topmost-intro syntactic symbol | |
2391 @cindex topmost-intro-cont syntactic symbol | |
2392 @cindex defun-open syntactic symbol | |
2393 @cindex defun-close syntactic symbol | |
2394 @cindex defun-block-intro syntactic symbol | |
2012 Line 1 shows a @code{topmost-intro} since it is the first line that | 2395 Line 1 shows a @code{topmost-intro} since it is the first line that |
2013 introduces a top-level construct. Line 2 is a continuation of the | 2396 introduces a top-level construct. Line 2 is a continuation of the |
2014 top-level construct introduction so it has the syntax | 2397 top-level construct introduction so it has the syntax |
2015 @code{topmost-intro-cont}. Line 3 shows a @code{defun-open} since it is | 2398 @code{topmost-intro-cont}. Line 3 shows a @code{defun-open} since it is |
2016 the brace that opens a top-level function definition. Line 9 is a | 2399 the brace that opens a top-level function definition. Line 9 is a |
2017 @code{defun-close} since it contains the brace that closes the top-level | 2400 @code{defun-close} since it contains the brace that closes the top-level |
2018 function definition. Line 4 is a @code{defun-block-intro}, i.e. it is | 2401 function definition. Line 4 is a @code{defun-block-intro}, i.e. it is |
2019 the first line of a brace-block, which happens to be enclosed in a | 2402 the first line of a brace-block, which happens to be enclosed in a |
2020 top-level function definition. | 2403 top-level function definition. |
2021 | 2404 |
2405 @cindex statement syntactic symbol | |
2406 @cindex statement-cont syntactic symbol | |
2022 Lines 5, 6, and 7 are all given @code{statement} syntax since there | 2407 Lines 5, 6, and 7 are all given @code{statement} syntax since there |
2023 isn't much special about them. Note however that line 8 is given | 2408 isn't much special about them. Note however that line 8 is given |
2024 @code{statement-cont} syntax since it continues the statement begun | 2409 @code{statement-cont} syntax since it continues the statement begun |
2025 on the previous line. | 2410 on the previous line. |
2026 | 2411 |
2043 12: eString.tune( 'E' ); | 2428 12: eString.tune( 'E' ); |
2044 13: aString.tune( 'A' ); | 2429 13: aString.tune( 'A' ); |
2045 14: dString.tune( 'D' ); | 2430 14: dString.tune( 'D' ); |
2046 15: gString.tune( 'G' ); | 2431 15: gString.tune( 'G' ); |
2047 16: @} | 2432 16: @} |
2048 17: @} | 2433 17: friend class Luthier; |
2049 | 2434 18: @} |
2050 @end group | 2435 |
2051 @end example | 2436 @end group |
2052 | 2437 @end example |
2438 | |
2439 @cindex class-open syntactic symbol | |
2440 @cindex class-close syntactic symbol | |
2053 As in the previous example, line 1 has the @code{topmost-intro} syntax. | 2441 As in the previous example, line 1 has the @code{topmost-intro} syntax. |
2054 Here however, the brace that opens a C++ class definition on line 4 is | 2442 Here however, the brace that opens a C++ class definition on line 4 is |
2055 assigned the @code{class-open} syntax. Note that in C++, structs and | 2443 assigned the @code{class-open} syntax. Note that in C++, classes, |
2056 unions are essentially equivalent syntactically (and are very similar | 2444 structs, and unions are essentially equivalent syntactically (and are |
2057 semantically), so replacing the @code{class} keyword in the example | 2445 very similar semantically), so replacing the @code{class} keyword in the |
2058 above with @code{struct} or @code{union} would still result in a syntax | 2446 example above with @code{struct} or @code{union} would still result in a |
2059 of @code{class-open} for line 4 @footnote{This is the case even for C | 2447 syntax of @code{class-open} for line 4 @footnote{This is the case even |
2060 and Objective-C. For consistency, structs in all three languages are | 2448 for C and Objective-C. For consistency, structs in all supported |
2061 syntactically equivalent to classes. Note however that the keyword | 2449 languages are syntactically equivalent to classes. Note however that |
2062 @code{class} is meaningless in C and Objective-C.}. Similarly, line 17 | 2450 the keyword @code{class} is meaningless in C and Objective-C.}. |
2063 is assigned @code{class-close} syntax. | 2451 Similarly, line 18 is assigned @code{class-close} syntax. |
2064 | 2452 |
2453 @cindex inher-intro syntactic symbol | |
2454 @cindex inher-cont syntactic symbol | |
2065 Line 2 introduces the inheritance list for the class so it is assigned | 2455 Line 2 introduces the inheritance list for the class so it is assigned |
2066 the @code{inher-intro} syntax, and line 3, which continues the | 2456 the @code{inher-intro} syntax, and line 3, which continues the |
2067 inheritance list is given @code{inher-cont} syntax. | 2457 inheritance list is given @code{inher-cont} syntax. |
2068 | 2458 |
2069 Things get interesting at line 5. The primary syntactic symbol for this | 2459 @cindex access-label syntactic symbol |
2070 line is @code{access-label} since this a label keyword that specifies | 2460 @cindex inclass syntactic symbol |
2071 access protection in C++. However, this line actually shows two | 2461 Hitting @kbd{C-c C-s} on line 5 shows the following analysis: |
2072 syntactic symbols when you hit @kbd{C-c C-s}. This is because it is | 2462 |
2073 also a top-level construct inside a class definition. Thus the other | 2463 @example |
2074 syntactic symbol assigned to this line is @code{inclass}. Similarly, | 2464 @group |
2075 line 6 is given both @code{inclass} and @code{topmost-intro} syntax. | 2465 |
2076 | 2466 @code{((inclass . 1) (access-label . 67))} |
2467 | |
2468 @end group | |
2469 @end example | |
2470 | |
2471 @noindent | |
2472 The primary syntactic symbol for this line is @code{access-label} as | |
2473 this a label keyword that specifies access protection in C++. However, | |
2474 because this line is also a top-level construct inside a class | |
2475 definition, the analysis actually shows two syntactic symbols. The | |
2476 other syntactic symbol assigned to this line is @code{inclass}. | |
2477 Similarly, line 6 is given both @code{inclass} and @code{topmost-intro} | |
2478 syntax: | |
2479 | |
2480 @example | |
2481 @group | |
2482 | |
2483 @code{((inclass . 58) (topmost-intro . 60))} | |
2484 | |
2485 @end group | |
2486 @end example | |
2487 | |
2488 @cindex member-init-intro syntactic symbol | |
2489 @cindex member-init-cont syntactic symbol | |
2077 Line 7 introduces a C++ member initialization list and as such is given | 2490 Line 7 introduces a C++ member initialization list and as such is given |
2078 @code{member-init-intro} syntax. Note that in this case it is | 2491 @code{member-init-intro} syntax. Note that in this case it is |
2079 @emph{not} assigned @code{inclass} since this is not considered a | 2492 @emph{not} assigned @code{inclass} since this is not considered a |
2080 top-level construct. Lines 8 through 10 are all assigned | 2493 top-level construct. Lines 8 through 10 are all assigned |
2081 @code{member-init-cont} since they continue the member initialization | 2494 @code{member-init-cont} since they continue the member initialization |
2082 list started on line 7. | 2495 list started on line 7. |
2083 | 2496 |
2084 @cindex in-class inline methods | 2497 @cindex in-class inline methods |
2085 Line 11 is assigned @code{inline-open} because it opens an | 2498 @cindex inline-open syntactic symbol |
2086 @dfn{in-class} C++ inline method definition. This is distinct from, but | 2499 @cindex inline-close syntactic symbol |
2087 related to, the C++ notion of an inline function in that its definition | 2500 But the line 11's analysis is a bit more complicated: |
2088 occurs inside an enclosing class definition, which in C++ implies that | 2501 |
2089 the function should be inlined. For example, if the definition of the | 2502 @example |
2090 @code{Bass} constructor appeared outside the class definition, line 11 | 2503 @group |
2091 would be given the @code{defun-open} syntax, even if the keyword | 2504 |
2092 @code{inline} appeared before the method name, as in: | 2505 @code{((inclass . 1) (inline-open))} |
2506 | |
2507 @end group | |
2508 @end example | |
2509 | |
2510 This line is assigned a syntax of both @code{inline-open} and | |
2511 @code{inclass} because it opens an @dfn{in-class} C++ inline method | |
2512 definition. This is distinct from, but related to, the C++ notion of an | |
2513 inline function in that its definition occurs inside an enclosing class | |
2514 definition, which in C++ implies that the function should be inlined. | |
2515 For example, if the definition of the @code{Bass} constructor appeared | |
2516 outside the class definition, line 11 would be given the | |
2517 @code{defun-open} syntax, even if the keyword @code{inline} appeared | |
2518 before the method name, as in: | |
2093 @example | 2519 @example |
2094 @group | 2520 @group |
2095 | 2521 |
2096 class Bass | 2522 class Bass |
2097 : public Guitar, | 2523 : public Guitar, |
2115 @} | 2541 @} |
2116 | 2542 |
2117 @end group | 2543 @end group |
2118 @end example | 2544 @end example |
2119 | 2545 |
2120 @noindent | 2546 @cindex friend syntactic symbol |
2121 Similarly, line 16 is given @code{inline-close} syntax. | 2547 Returning to the previous example, line 16 is given @code{inline-close} |
2122 | 2548 syntax, while line 12 is given @code{defun-block-open} syntax, and lines |
2123 As in the first example above, line 12 is given @code{defun-block-open} | 2549 13 through 15 are all given @code{statement} syntax. Line 17 is |
2124 syntax and lines 13 through 15 are all given @code{statement} syntax. | 2550 interesting in that it's syntactic analysis list contains three |
2551 elements: | |
2552 | |
2553 @example | |
2554 | |
2555 @code{((friend) (inclass . 58) (topmost-intro . 380))} | |
2556 | |
2557 @end example | |
2558 | |
2559 The @code{friend} syntactic symbol is a modifier that typically does not | |
2560 have a relative buffer position. | |
2125 | 2561 |
2126 Here is another (totally contrived) example which illustrates how syntax | 2562 Here is another (totally contrived) example which illustrates how syntax |
2127 is assigned to various conditional constructs: | 2563 is assigned to various conditional constructs: |
2128 @example | 2564 @example |
2129 @group | 2565 @group |
2150 @end example | 2586 @end example |
2151 | 2587 |
2152 @noindent | 2588 @noindent |
2153 Only the lines that illustrate new syntactic symbols will be discussed. | 2589 Only the lines that illustrate new syntactic symbols will be discussed. |
2154 | 2590 |
2591 @cindex substatement-open syntactic symbol | |
2592 @cindex substatement-block-intro syntactic symbol | |
2593 @cindex block-close syntactic symbol | |
2155 Line 4 has a brace which opens a conditional's substatement block. It | 2594 Line 4 has a brace which opens a conditional's substatement block. It |
2156 is thus assigned @code{substatement-open} syntax, and since line 5 is | 2595 is thus assigned @code{substatement-open} syntax, and since line 5 is |
2157 the first line in the substatement block, it is assigned | 2596 the first line in the substatement block, it is assigned |
2158 @code{substatement-block-intro} syntax. Lines 6 and 7 are assigned | 2597 @code{substatement-block-intro} syntax. Lines 6 and 7 are assigned |
2159 similar syntax. Line 8 contains the brace that closes the inner | 2598 similar syntax. Line 8 contains the brace that closes the inner |
2160 substatement block. It is given the generic syntax @code{block-close}, | 2599 substatement block. It is given the syntax @code{block-close}, |
2161 as are lines 11 and 14. | 2600 as are lines 11 and 14. |
2162 | 2601 |
2163 Line 9 is a little different -- since it contains the keyword | 2602 @cindex else-clause syntactic symbol |
2164 @code{else} matching the @code{if} statement introduced on line 5; it is | 2603 @cindex substatement syntactic symbol |
2604 Line 9 is a little different --- since it contains the keyword | |
2605 @code{else} matching the @code{if} statement introduced on line 5, it is | |
2165 given the @code{else-clause} syntax. Note also that line 10 is slightly | 2606 given the @code{else-clause} syntax. Note also that line 10 is slightly |
2166 different too. Because @code{else} is considered a conditional | 2607 different too. Because @code{else} is considered a conditional |
2167 introducing keyword @footnote{The list of conditional keywords are (in | 2608 introducing keyword @footnote{The list of conditional keywords are (in |
2168 C, Objective-C and C++): @code{for}, @code{if}, @code{do}, @code{else}, | 2609 C, C++, Objective-C, and Java): @code{for}, @code{if}, @code{do}, |
2169 @code{while}, and @code{switch}. C++ has two additional conditional | 2610 @code{else}, @code{while}, and @code{switch}. C++ and Java have two |
2170 keywords: @code{try} and @code{catch}.}, and because the following | 2611 additional conditional keywords: @code{try} and @code{catch}. Java also |
2171 substatement is not a brace block, line 10 is assigned the | 2612 has the @code{finally} and @code{synchronized} keywords.}, and because |
2613 the following substatement is not a brace block, line 10 is assigned the | |
2172 @code{substatement} syntax. | 2614 @code{substatement} syntax. |
2173 | 2615 |
2616 @cindex do-while-closure syntactic symbol | |
2174 One other difference is seen on line 15. The @code{while} construct | 2617 One other difference is seen on line 15. The @code{while} construct |
2175 that closes a @code{do} conditional is given the special syntax | 2618 that closes a @code{do} conditional is given the special syntax |
2176 @code{do-while-closure} if it appears on a line by itself. Note that if | 2619 @code{do-while-closure} if it appears on a line by itself. Note that if |
2177 the @code{while} appeared on the same line as the preceding close brace, | 2620 the @code{while} appeared on the same line as the preceding close brace, |
2178 that line would have been assigned @code{block-close} syntax instead. | 2621 that line would have been assigned @code{block-close} syntax instead. |
2200 14: @} | 2643 14: @} |
2201 | 2644 |
2202 @end group | 2645 @end group |
2203 @end example | 2646 @end example |
2204 | 2647 |
2648 @cindex case-label syntactic symbol | |
2649 @cindex statement-case-intro syntactic symbol | |
2650 @cindex statement-case-open syntactic symbol | |
2205 Here, lines 4, 7, and 10 are all assigned @code{case-label} syntax, | 2651 Here, lines 4, 7, and 10 are all assigned @code{case-label} syntax, |
2206 while lines 5 and 8 are assigned @code{statement-case-intro}. Line 11 | 2652 while lines 5 and 8 are assigned @code{statement-case-intro}. Line 11 |
2207 is treated slightly differently since it contains a brace that opens a | 2653 is treated slightly differently since it contains a brace that opens a |
2208 block -- it is given @code{statement-case-open} syntax. | 2654 block --- it is given @code{statement-case-open} syntax. |
2209 | 2655 |
2210 @cindex brace lists | 2656 @cindex brace lists |
2211 There are a set of syntactic symbols that are used to recognize | 2657 There are a set of syntactic symbols that are used to recognize |
2212 constructs inside of brace lists. A brace list is defined as an | 2658 constructs inside of brace lists. A brace list is defined as an |
2213 @code{enum} or aggregate initializer list, such as might statically | 2659 @code{enum} or aggregate initializer list, such as might statically |
2223 6: @} | 2669 6: @} |
2224 | 2670 |
2225 @end group | 2671 @end group |
2226 @end example | 2672 @end example |
2227 | 2673 |
2674 @cindex brace-list-open syntactic symbol | |
2675 @cindex brace-list-intro syntactic symbol | |
2676 @cindex brace-list-close syntactic symbol | |
2677 @cindex brace-list-entry syntactic symbol | |
2228 Following convention, line 2 in this example is assigned | 2678 Following convention, line 2 in this example is assigned |
2229 @code{brace-list-open} syntax, and line 3 is assigned | 2679 @code{brace-list-open} syntax, and line 3 is assigned |
2230 @code{brace-list-intro} syntax. Likewise, line 6 is assigned | 2680 @code{brace-list-intro} syntax. Likewise, line 6 is assigned |
2231 @code{brace-list-close} syntax. Lines 4 and 5 however, are assigned | 2681 @code{brace-list-close} syntax. Lines 4 and 5 however, are assigned |
2232 @code{brace-list-entry} syntax, as would all subsequent lines in this | 2682 @code{brace-list-entry} syntax, as would all subsequent lines in this |
2233 initializer list. | 2683 initializer list. |
2684 | |
2685 External language definition blocks also have their own syntactic | |
2686 symbols. In this example: | |
2687 @example | |
2688 @group | |
2689 | |
2690 1: extern "C" | |
2691 2: @{ | |
2692 3: int thing_one( int ); | |
2693 4: int thing_two( double ); | |
2694 5: @} | |
2695 | |
2696 @end group | |
2697 @end example | |
2698 | |
2699 @cindex extern-lang-open syntactic symbol | |
2700 @cindex extern-lang-close syntactic symbol | |
2701 @cindex inextern-lang syntactic symbol | |
2702 @cindex inclass syntactic symbol | |
2703 @noindent | |
2704 line 2 is given the @code{extern-lang-open} syntax while line 5 is given | |
2705 the @code{extern-lang-close} syntax. The analysis for line 3 yields: | |
2706 @code{((inextern-lang) (topmost-intro . 14))}, where | |
2707 @code{inextern-lang} is a modifier similar in purpose to @code{inclass}. | |
2234 | 2708 |
2235 A number of syntactic symbols are associated with parenthesis lists, | 2709 A number of syntactic symbols are associated with parenthesis lists, |
2236 a.k.a argument lists, as found in function declarations and function | 2710 a.k.a argument lists, as found in function declarations and function |
2237 calls. This example illustrates these: | 2711 calls. This example illustrates these: |
2238 @example | 2712 @example |
2258 18: @} | 2732 18: @} |
2259 | 2733 |
2260 @end group | 2734 @end group |
2261 @end example | 2735 @end example |
2262 | 2736 |
2737 @cindex arglist-intro syntactic symbol | |
2738 @cindex arglist-close syntactic symbol | |
2263 Lines 5 and 12 are assigned @code{arglist-intro} syntax since they are | 2739 Lines 5 and 12 are assigned @code{arglist-intro} syntax since they are |
2264 the first line following the open parenthesis, and lines 7 and 14 are | 2740 the first line following the open parenthesis, and lines 7 and 14 are |
2265 assigned @code{arglist-close} syntax since they contain the parenthesis | 2741 assigned @code{arglist-close} syntax since they contain the parenthesis |
2266 that closes the argument list. | 2742 that closes the argument list. |
2267 | 2743 |
2268 The other lines with relevant syntactic symbols include lines 2 and 17 | 2744 @cindex arglist-cont-nonempty syntactic symbol |
2269 which are assigned @code{arglist-cont-nonempty} syntax. What this means | 2745 @cindex arglist-cont syntactic symbol |
2746 Lines that continue argument lists can be assigned one of two syntactic | |
2747 symbols. For example, Lines 2 and 17 | |
2748 are assigned @code{arglist-cont-nonempty} syntax. What this means | |
2270 is that they continue an argument list, but that the line containing the | 2749 is that they continue an argument list, but that the line containing the |
2271 parenthesis that opens the list is @emph{non-empty} following the open | 2750 parenthesis that opens the list is @emph{not empty} following the open |
2272 parenthesis. Contrast this against lines 6 and 13 which are assigned | 2751 parenthesis. Contrast this against lines 6 and 13 which are assigned |
2273 @code{arglist-cont} syntax. This is because the parenthesis that opens | 2752 @code{arglist-cont} syntax. This is because the parenthesis that opens |
2274 their argument lists is the last character on that line @footnote{The | 2753 their argument lists is the last character on that line @footnote{The |
2275 need for this somewhat confusing arrangement is that the typical | 2754 need for this somewhat confusing arrangement is that the typical |
2276 indentation desired for these lines is calculated very differently. | 2755 indentation desired for these lines is calculated differently. |
2277 This should be simplified in version 5 of @code{cc-mode}, along with the | 2756 This should be simplified in version 5 of @code{cc-mode}, along with the |
2278 added distinction between argument lists in function declarations, and | 2757 added distinction between argument lists in function declarations, and |
2279 argument lists in function calls.}. | 2758 argument lists in function calls.}. |
2280 | 2759 |
2281 Note that there is no @code{arglist-open} syntax. This is because any | 2760 Note that there is no @code{arglist-open} syntax. This is because any |
2313 @cindex modifier syntactic symbol | 2792 @cindex modifier syntactic symbol |
2314 The lines to note in this example include: | 2793 The lines to note in this example include: |
2315 | 2794 |
2316 @itemize @bullet | 2795 @itemize @bullet |
2317 | 2796 |
2318 @item | 2797 @cindex ansi-funcdecl-cont syntactic symbol |
2319 line 2 which is assigned the @code{ansi-funcdecl-cont} syntax; | 2798 @item |
2320 | 2799 line 2, assigned the @code{ansi-funcdecl-cont} syntax; |
2321 @item | 2800 |
2322 line 4 which is assigned both @code{defun-block-intro} @emph{and} | 2801 @cindex comment-intro syntactic symbol |
2802 @item | |
2803 line 4, assigned both @code{defun-block-intro} @emph{and} | |
2323 @code{comment-intro} syntax @footnote{The @code{comment-intro} syntactic | 2804 @code{comment-intro} syntax @footnote{The @code{comment-intro} syntactic |
2324 symbol is known generically as a @dfn{modifier} since it always appears | 2805 symbol is is another example of a @dfn{modifier} since it always appears |
2325 on a syntactic analysis list with other symbols, and never has a | 2806 on a syntactic analysis list with other symbols, and rarely has an |
2326 relative buffer position.}; | 2807 associated relative buffer position.}; |
2327 | 2808 |
2328 @item | 2809 @cindex c syntactic symbol |
2329 line 5 which is assigned @code{c} syntax; | 2810 @item |
2811 line 5, assigned @code{c} syntax; | |
2330 | 2812 |
2331 @item | 2813 @item |
2332 @cindex syntactic whitespace | 2814 @cindex syntactic whitespace |
2333 line 6 which, even though it contains nothing but whitespace, is | 2815 line 6 which, even though it contains nothing but whitespace, is |
2334 assigned @code{defun-block-intro}. Note that the appearance of the | 2816 assigned @code{defun-block-intro}. Note that the appearance of the |
2335 comment on lines 4 and 5 do not cause line 6 to be assigned | 2817 comment on lines 4 and 5 do not cause line 6 to be assigned |
2336 @code{statement} syntax because comments are considered to be | 2818 @code{statement} syntax because comments are considered to be |
2337 @dfn{syntactic whitespace}, which are essentially ignored when analyzing | 2819 @dfn{syntactic whitespace}, which are ignored when analyzing |
2338 code; | 2820 code; |
2339 | 2821 |
2340 @item | 2822 @cindex string syntactic symbol |
2341 line 8 which is assigned @code{string} syntax; | 2823 @item |
2342 | 2824 line 8, assigned @code{string} syntax; |
2343 @item | 2825 |
2344 line 10 which is assigned @code{label} syntax; | 2826 @cindex label syntactic symbol |
2345 | 2827 @item |
2346 @item | 2828 line 10, assigned @code{label} syntax; |
2347 line 11 which is assigned @code{block-open} syntax; | 2829 |
2348 | 2830 @cindex block-open syntactic symbol |
2349 @item | 2831 @item |
2350 lines 12 and 14 which are assigned @code{cpp-macro} syntax; | 2832 line 11, assigned @code{block-open} syntax; |
2351 | 2833 |
2352 @item | 2834 @cindex cpp-macro syntactic symbol |
2353 line 17 which is assigned @code{stream-op} syntax @footnote{In C++ only.}. | 2835 @item |
2836 lines 12 and 14, assigned @code{cpp-macro} syntax; | |
2837 | |
2838 @cindex stream-op syntactic symbol | |
2839 @item | |
2840 line 17, assigned @code{stream-op} syntax @footnote{In C++ only.}. | |
2354 | 2841 |
2355 @end itemize | 2842 @end itemize |
2356 | 2843 |
2357 In Objective-C buffers, there are three additional syntactic symbols | 2844 In Objective-C buffers, there are three additional syntactic symbols |
2358 assigned to various message calling constructs. Here's an example | 2845 assigned to various message calling constructs. Here's an example |
2369 7: @} | 2856 7: @} |
2370 | 2857 |
2371 @end group | 2858 @end group |
2372 @end example | 2859 @end example |
2373 | 2860 |
2861 @cindex objc-method-intro syntactic symbol | |
2862 @cindex objc-method-args-cont syntactic symbol | |
2863 @cindex objc-method-call-cont syntactic symbol | |
2374 Here, line 1 is assigned @code{objc-method-intro} syntax, and line 2 is | 2864 Here, line 1 is assigned @code{objc-method-intro} syntax, and line 2 is |
2375 assigned @code{objc-method-args-cont} syntax. Lines 5 and 6 are both | 2865 assigned @code{objc-method-args-cont} syntax. Lines 5 and 6 are both |
2376 assigned @code{objc-method-call-cont} syntax. | 2866 assigned @code{objc-method-call-cont} syntax. |
2377 | 2867 |
2378 Other syntactic symbols may be recognized by @code{cc-mode}, but these | 2868 @cindex knr-argdecl-intro |
2379 are more obscure and so I haven't included examples of them. These | 2869 @cindex knr-argdecl |
2380 include: @code{knr-argdecl-intro}, @code{knr-argdecl}, and the | 2870 Two other syntactic symbols can appear in old style, non-prototyped C |
2381 @code{friend} modifier. | 2871 code @footnote{a.k.a. K&R C, or Kernighan & Ritchie C}: |
2872 @example | |
2873 @group | |
2874 | |
2875 1: int add_three_integers(a, b, c) | |
2876 2: int a; | |
2877 3: int b; | |
2878 4: int c; | |
2879 5: @{ | |
2880 6: return a + b + c; | |
2881 7: @} | |
2882 | |
2883 @end group | |
2884 @end example | |
2885 | |
2886 Here, line 2 is the first line in an argument declaration list and so is | |
2887 given the @code{knr-argdecl-intro} syntactic symbol. Subsequent lines | |
2888 (i.e. lines 3 and 4 in this example), are given @code{knr-argdecl} | |
2889 syntax. | |
2382 | 2890 |
2383 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 2891 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2384 @node Performance Issues, Frequently Asked Questions, Syntactic Symbols, Top | 2892 @node Performance Issues, Frequently Asked Questions, Syntactic Symbols, Top |
2385 @comment node-name, next, previous,up | 2893 @comment node-name, next, previous,up |
2386 | 2894 |
2388 @cindex Performance Issues | 2896 @cindex Performance Issues |
2389 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 2897 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2390 | 2898 |
2391 C and it's derivative languages are highly complex creatures. Often, | 2899 C and it's derivative languages are highly complex creatures. Often, |
2392 ambiguous code situations arise that require @code{cc-mode} to scan | 2900 ambiguous code situations arise that require @code{cc-mode} to scan |
2393 large portions of the buffer to determine syntactic context. Some | 2901 large portions of the buffer to determine syntactic context. Such |
2394 pathological code can cause @code{cc-mode} to slow down considerably. | 2902 pathological code@footnote{such as the output of @code{lex(1)}!} |
2903 can cause @code{cc-mode} to perform fairly badly. | |
2395 This section identifies some of the coding styles to watch out for, and | 2904 This section identifies some of the coding styles to watch out for, and |
2396 suggests some workarounds that you can use to improve performance. | 2905 suggests some workarounds that you can use to improve performance. |
2397 | 2906 |
2398 Note that this is an area that will get a lot of attention in | 2907 Note that this is an area that will get a lot of attention in |
2399 @code{cc-mode} version 5. The mode should end up being much faster, at | 2908 @code{cc-mode} version 5. The mode should end up being much faster, at |
2400 the expense of dropping Emacs 18 support, owing to the implementation of | 2909 the expense of dropping Emacs 18 support, owing to the implementation of |
2401 syntactic analysis caching. This is the last release of @code{cc-mode} | 2910 syntactic analysis caching. |
2402 that will be compatible with Emacs 18. | |
2403 | 2911 |
2404 Because @code{cc-mode} has to scan the buffer backwards from the current | 2912 Because @code{cc-mode} has to scan the buffer backwards from the current |
2405 insertion point, and because C's syntax is fairly difficult to parse in | 2913 insertion point, and because C's syntax is fairly difficult to parse in |
2406 the backwards direction, @code{cc-mode} often tries to find the nearest | 2914 the backwards direction, @code{cc-mode} often tries to find the nearest |
2407 position higher up in the buffer from which to begin a forward scan. | 2915 position higher up in the buffer from which to begin a forward scan. |
2420 @code{defun-prompt-regexp} to something reasonable @footnote{Note that | 2928 @code{defun-prompt-regexp} to something reasonable @footnote{Note that |
2421 this variable is only defined in Emacs 19.}, however that ``something | 2929 this variable is only defined in Emacs 19.}, however that ``something |
2422 reasonable'' is difficult to define, so @code{cc-mode} doesn't do it | 2930 reasonable'' is difficult to define, so @code{cc-mode} doesn't do it |
2423 for you. | 2931 for you. |
2424 | 2932 |
2425 @cindex @file{cc-lobotomy.el} file | |
2426 You will probably notice pathological behavior from @code{cc-mode} when | 2933 You will probably notice pathological behavior from @code{cc-mode} when |
2427 working in files containing large amounts of cpp macros. This is | 2934 working in files containing large amounts of cpp macros. This is |
2428 because @code{cc-mode} cannot quickly skip backwards over these lines, | 2935 because @code{cc-mode} cannot quickly skip backwards over these lines. |
2429 which do not contribute to the syntactic calculations. You'll probably | |
2430 also have problems if you are editing ``K&R'' C code, i.e. C code that | |
2431 does not use function prototypes. This is because there are ambiguities | |
2432 in the C syntax when K&R style argument lists are used, and | |
2433 @code{cc-mode} has to use a slower scan to determine what it's looking | |
2434 at. | |
2435 | 2936 |
2436 @vindex c-recognize-knr-p | 2937 @vindex c-recognize-knr-p |
2437 @vindex recognize-knr-p (c-) | 2938 @vindex recognize-knr-p (c-) |
2438 For the latter problem, I would suggest converting to ANSI style | 2939 Previous versions of @code{cc-mode} had potential performance problems |
2439 protocols, and turning the variable @code{c-recognize-knr-p} to | 2940 when recognizing ``K&R'' style function argument declarations. This was |
2440 @code{nil} (this is it's default value for all modes). | 2941 because there are ambiguities in the C syntax when K&R style argument |
2441 | 2942 lists are used (it is hard to distinguish them from top-level |
2943 declarations). @code{cc-mode} has adopted BOCM's convention for | |
2944 limiting the search: it assumes that argdecls are indented at least one | |
2945 space, and that the function headers are not indented at all. With | |
2946 current versions of @code{cc-mode}, | |
2947 @code{c-recognize-knr-p} is deprecated. | |
2948 | |
2949 @cindex @file{cc-lobotomy.el} file | |
2442 @vindex cc-lobotomy-pith-list | 2950 @vindex cc-lobotomy-pith-list |
2443 For the former problem, you might want to investigate some of the | 2951 You might want to investigate some of the |
2444 speed-ups provided for you in the file @file{cc-lobotomy.el}, which | 2952 speed-ups contained in the file @file{cc-lobotomy.el}, which |
2445 is part of the canonical @code{cc-mode} distribution. As mentioned | 2953 is part of the canonical @code{cc-mode} distribution. As mentioned |
2446 previous, @code{cc-mode} always trades accuracy for speed, however it is | 2954 previous, @code{cc-mode} always trades accuracy for speed, however it is |
2447 recognized that sometimes you need speed and can sacrifice some accuracy | 2955 recognized that sometimes you need speed and can sacrifice some accuracy |
2448 in indentation. The file @file{cc-lobotomy.el} contains hacks that | 2956 in indentation. The file @file{cc-lobotomy.el} contains hacks that |
2449 will ``dumb down'' @code{cc-mode} in some specific ways, making that | 2957 will ``dumb down'' @code{cc-mode} in some specific ways, making that |
2456 @node Frequently Asked Questions, Getting the latest cc-mode release, Performance Issues, Top | 2964 @node Frequently Asked Questions, Getting the latest cc-mode release, Performance Issues, Top |
2457 @comment node-name, next, previous,up | 2965 @comment node-name, next, previous,up |
2458 | 2966 |
2459 @chapter Frequently Asked Questions | 2967 @chapter Frequently Asked Questions |
2460 @cindex Frequently Asked Questions | 2968 @cindex Frequently Asked Questions |
2969 @comment FAQ | |
2461 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 2970 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2462 | 2971 |
2463 @kindex C-x h | 2972 @kindex C-x h |
2464 @kindex ESC C-\ | 2973 @kindex ESC C-\ |
2465 @kindex ESC C-x | 2974 @kindex ESC C-x |
2473 | 2982 |
2474 @strong{Q.} @emph{How do I re-indent the whole file?} | 2983 @strong{Q.} @emph{How do I re-indent the whole file?} |
2475 | 2984 |
2476 @strong{A.} Visit the file and hit @kbd{C-x h} to mark the whole | 2985 @strong{A.} Visit the file and hit @kbd{C-x h} to mark the whole |
2477 buffer. Then hit @kbd{@key{ESC} C-\}. | 2986 buffer. Then hit @kbd{@key{ESC} C-\}. |
2478 @sp 2 | 2987 @sp 1 |
2479 | 2988 |
2480 @strong{Q.} @emph{How do I re-indent the entire function? | 2989 @strong{Q.} @emph{How do I re-indent the entire function? |
2481 @kbd{@key{ESC} C-x} doesn't work.} | 2990 @kbd{@key{ESC} C-x} doesn't work.} |
2482 | 2991 |
2483 @strong{A.} @kbd{@key{ESC} C-x} is reserved for future Emacs use. | 2992 @strong{A.} @kbd{@key{ESC} C-x} is reserved for future Emacs use. |
2484 To re-indent the entire function hit @kbd{C-c C-q}. | 2993 To re-indent the entire function hit @kbd{C-c C-q}. |
2485 @sp 2 | 2994 @sp 1 |
2486 | 2995 |
2487 @strong{Q.} @emph{How do I re-indent the current block?} | 2996 @strong{Q.} @emph{How do I re-indent the current block?} |
2488 | 2997 |
2489 @strong{A.} First move to the brace which opens the block with | 2998 @strong{A.} First move to the brace which opens the block with |
2490 @kbd{@key{ESC} C-u}, then re-indent that expression with | 2999 @kbd{@key{ESC} C-u}, then re-indent that expression with |
2491 @kbd{@key{ESC} C-q}. | 3000 @kbd{@key{ESC} C-q}. |
2492 @sp 2 | 3001 @sp 1 |
2493 | 3002 |
2494 @strong{Q.} @emph{Why doesn't the @key{RET} key indent the line to | 3003 @strong{Q.} @emph{Why doesn't the @key{RET} key indent the line to |
2495 where the new text should go after inserting the newline?} | 3004 where the new text should go after inserting the newline?} |
2496 | 3005 |
2497 @strong{A.} Emacs' convention is that @key{RET} just adds a newline, | 3006 @strong{A.} Emacs' convention is that @key{RET} just adds a newline, |
2505 | 3014 |
2506 @end example | 3015 @end example |
2507 | 3016 |
2508 This is a very common question. @code{:-)} If you want this to be the | 3017 This is a very common question. @code{:-)} If you want this to be the |
2509 default behavior, don't lobby me, lobby RMS! | 3018 default behavior, don't lobby me, lobby RMS! |
2510 @sp 2 | 3019 @sp 1 |
2511 | 3020 |
2512 @strong{Q.} @emph{I put @code{(c-set-offset 'substatement-open 0)} | 3021 @strong{Q.} @emph{I put @code{(c-set-offset 'substatement-open 0)} |
2513 in my @file{.emacs} file but I get an error saying that | 3022 in my @file{.emacs} file but I get an error saying that |
2514 @code{c-set-offset}'s function definition is void.} | 3023 @code{c-set-offset}'s function definition is void.} |
2515 | 3024 |
2526 @end example | 3035 @end example |
2527 | 3036 |
2528 See the sample @file{.emacs} file @ref{Sample .emacs File} for | 3037 See the sample @file{.emacs} file @ref{Sample .emacs File} for |
2529 details. | 3038 details. |
2530 | 3039 |
3040 @sp 1 | |
2531 @strong{Q.} @emph{How do I make strings, comments, keywords, and other | 3041 @strong{Q.} @emph{How do I make strings, comments, keywords, and other |
2532 constructs appear in different colors, or in bold face, etc.?} | 3042 constructs appear in different colors, or in bold face, etc.?} |
2533 | 3043 |
2534 @strong{A.} ``Syntax Colorization'' is an Emacs 19 feature, controlled | 3044 @strong{A.} ``Syntax Colorization'' is an Emacs 19 feature, controlled |
2535 by @code{font-lock-mode}. It is not part of @code{cc-mode}. | 3045 by @code{font-lock-mode}. It is not part of @code{cc-mode}. |
2536 | 3046 |
3047 @sp 1 | |
3048 @strong{Q.} @emph{I @code{setq} @code{c-basic-offset} to 4 in my | |
3049 @file{.emacs} file, but why does everything still get indented with only | |
3050 2 spaces?} | |
3051 | |
3052 @strong{A.} It's because @code{c-basic-offset} is now a ``buffer local | |
3053 variable'', meaning its value is unique to each buffer. The prefered | |
3054 way to customize this is to change its value in a ``mode hook'' (most | |
3055 likely @code{c-mode-common-hook}. Alternatively you can use | |
3056 @code{setq-default} to change its value globally. | |
3057 | |
2537 @end quotation | 3058 @end quotation |
2538 | 3059 |
2539 | 3060 |
2540 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 3061 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2541 @node Getting the latest cc-mode release, Sample .emacs File, Frequently Asked Questions, Top | 3062 @node Getting the latest cc-mode release, Sample .emacs File, Frequently Asked Questions, Top |
2545 @cindex Getting the latest @code{cc-mode} release | 3066 @cindex Getting the latest @code{cc-mode} release |
2546 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 3067 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2547 | 3068 |
2548 @code{cc-mode} is now distributed with both Emacs 19 and XEmacs 19, so | 3069 @code{cc-mode} is now distributed with both Emacs 19 and XEmacs 19, so |
2549 you would typically just use the version that comes with your Emacs. | 3070 you would typically just use the version that comes with your Emacs. |
2550 Users of older versions of Emacs can get the latest release from this | 3071 These may be slightly out of date due to release schedule skew, so you |
2551 URL: | 3072 should always check the canonical site for the latest version. |
2552 | 3073 |
2553 @example | 3074 @example |
2554 | 3075 @group |
2555 @code{ftp://ftp.python.org/pub/emacs/cc-mode.tar.gz} | 3076 |
2556 | 3077 World Wide Web: |
2557 @end example | 3078 |
2558 | 3079 @code{http://www.python.org/ftp/emacs/} |
2559 Note that this is a ``gzipped'' tar file. | 3080 |
3081 Anonymous FTP: | |
3082 | |
3083 @code{ftp://ftp.python.org/pub/emacs/} | |
3084 | |
3085 @end group | |
3086 @end example | |
3087 | |
3088 There are many files under these directories; you can pick up the entire | |
3089 distribution (named @code{cc-mode.tar.gz}; a gzip'd tar file), or any of | |
3090 the individual files, including PostScript documentation. | |
2560 | 3091 |
2561 If you do not have anonymous ftp access, you can get the distribution | 3092 If you do not have anonymous ftp access, you can get the distribution |
2562 through an anonymous ftp-to-mail gateway, such as the one run by DEC at | 3093 through an anonymous ftp-to-mail gateway, such as the one run by DEC at |
2563 @code{ftpmail@@decwrl.dec.com}. To get @code{cc-mode} via email, send | 3094 @code{ftpmail@@decwrl.dec.com}. To get @code{cc-mode} via email, send |
2564 the following message in the body of your mail to that address: | 3095 the following message in the body of your mail to that address: |
2572 get cc-mode.tar.gz | 3103 get cc-mode.tar.gz |
2573 | 3104 |
2574 @end example | 3105 @end example |
2575 @noindent | 3106 @noindent |
2576 or just send the message "help" for more information on ftpmail. | 3107 or just send the message "help" for more information on ftpmail. |
2577 Response times will vary with the number of requests in the queue. | 3108 Response times will vary with the number of requests in the queue. I am |
2578 | 3109 in no way connected to this service, so I make no claims or guarantees |
2579 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 3110 about its availability! |
2580 @node Sample .emacs File, Requirements, Getting the latest cc-mode release, Top | 3111 |
3112 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
3113 @node Sample .emacs File, Limitations and Known Bugs, Getting the latest cc-mode release, Top | |
2581 @comment node-name, next, previous,up | 3114 @comment node-name, next, previous,up |
2582 | 3115 |
2583 @chapter Sample @file{.emacs} file | 3116 @chapter Sample @file{.emacs} file |
2584 @cindex Sample @file{.emacs} file | 3117 @cindex Sample @file{.emacs} file |
2585 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 3118 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2621 (setq tab-width 8 | 3154 (setq tab-width 8 |
2622 ;; this will make sure spaces are used instead of tabs | 3155 ;; this will make sure spaces are used instead of tabs |
2623 indent-tabs-mode nil) | 3156 indent-tabs-mode nil) |
2624 ;; we like auto-newline and hungry-delete | 3157 ;; we like auto-newline and hungry-delete |
2625 (c-toggle-auto-hungry-state 1) | 3158 (c-toggle-auto-hungry-state 1) |
2626 ;; keybindings for C, C++, and Objective-C. We can put these in | 3159 ;; keybindings for all supported languages. We can put these in |
2627 ;; c-mode-map because c++-mode-map and objc-mode-map inherit it | 3160 ;; c-mode-map because c++-mode-map, objc-mode-map, and java-mode-map |
3161 ;; inherit from it. | |
2628 (define-key c-mode-map "\C-m" 'newline-and-indent) | 3162 (define-key c-mode-map "\C-m" 'newline-and-indent) |
2629 ) | 3163 ) |
2630 | 3164 |
2631 ;; the following only works in Emacs 19 | 3165 ;; the following only works in Emacs 19 |
2632 ;; Emacs 18ers can use (setq c-mode-common-hook 'my-c-mode-common-hook) | 3166 ;; Emacs 18ers can use (setq c-mode-common-hook 'my-c-mode-common-hook) |
2633 (add-hook 'c-mode-common-hook 'my-c-mode-common-hook) | 3167 (add-hook 'c-mode-common-hook 'my-c-mode-common-hook) |
2634 @end example | 3168 @end example |
2635 | 3169 |
2636 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 3170 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2637 @node Requirements, Limitations and Known Bugs, Sample .emacs File, Top | 3171 @node Limitations and Known Bugs, Mailing Lists and Submitting Bug Reports, Sample .emacs File, Top |
2638 @comment node-name, next, previous,up | |
2639 @chapter Requirements | |
2640 @cindex Requirements | |
2641 @comment * Requirements | |
2642 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
2643 | |
2644 @cindex reporter.el | |
2645 @file{cc-mode.el} requires @file{reporter.el} for submission of bug | |
2646 reports. @file{reporter.el} is distributed with the latest Emacs 19s. | |
2647 Here is the Emacs Lisp Archive anonymous ftp'ing record for those of you | |
2648 who are using older Emacsen. | |
2649 | |
2650 @comment * Here's the Emacs Lisp Archive information for @file{reporter.el}: | |
2651 @example | |
2652 | |
2653 GNU Emacs Lisp Code Directory Apropos -- "reporter" | |
2654 "~/" refers to archive.cis.ohio-state.edu:/pub/gnu/emacs/elisp-archive/ | |
2655 | |
2656 reporter (2.12) 06-Jul-1994 | |
2657 Barry A. Warsaw, <bwarsaw@@cnri.reston.va.us> | |
2658 ~/misc/reporter.el.Z | |
2659 Customizable bug reporting of lisp programs. | |
2660 | |
2661 @end example | |
2662 | |
2663 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
2664 @node Limitations and Known Bugs, Mailing Lists and Submitting Bug Reports, Requirements, Top | |
2665 @comment node-name, next, previous,up | 3172 @comment node-name, next, previous,up |
2666 @chapter Limitations and Known Bugs | 3173 @chapter Limitations and Known Bugs |
2667 @cindex Limitations and Known Bugs | 3174 @cindex Limitations and Known Bugs |
2668 @comment * Limitations and Known Bugs | 3175 @comment * Limitations and Known Bugs |
2669 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 3176 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2679 Use with Emacs 18 can be slow and annoying. You should seriously | 3186 Use with Emacs 18 can be slow and annoying. You should seriously |
2680 consider upgrading to Emacs 19. | 3187 consider upgrading to Emacs 19. |
2681 | 3188 |
2682 @item | 3189 @item |
2683 There is still some weird behavior when filling C block comments. | 3190 There is still some weird behavior when filling C block comments. |
2684 My suggestion is to check out add-on fill packages such as | 3191 My suggestion is to check out separate fill packages such as |
2685 @code{filladapt}, available at the elisp archive. | 3192 @code{filladapt} or @code{adaptive-fill-mode}. These can do a much |
2686 | 3193 better job of filling comment regions. |
2687 @cindex inline-close | 3194 |
2688 @kindex TAB | 3195 @cindex c-indent-exp |
2689 @item | 3196 @cindex indent-exp (c-) |
2690 Lines following @code{inline-close} braces which hang ``after'' do not | 3197 @item |
2691 line up correctly. Hit @kbd{TAB} to reindent the line. | 3198 @code{c-indent-exp} has not been fully optimized. It essentially |
3199 equivalent to hitting @kbd{TAB} (@code{c-indent-command}) on every | |
3200 line. Some information is cached from line to line, but such caching | |
3201 invariable causes inaccuracies in analysis in some bizarre situations. | |
2692 | 3202 |
2693 @end itemize | 3203 @end itemize |
2694 | 3204 |
2695 @c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 3205 @c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2696 @node Mailing Lists and Submitting Bug Reports, Concept Index, Limitations and Known Bugs, Top | 3206 @node Mailing Lists and Submitting Bug Reports, Concept Index, Limitations and Known Bugs, Top |
2708 command. This provides vital information I need to reproduce your | 3218 command. This provides vital information I need to reproduce your |
2709 problem. Make sure you include a concise, but complete code example. | 3219 problem. Make sure you include a concise, but complete code example. |
2710 Please try to boil your example down to just the essential code needed | 3220 Please try to boil your example down to just the essential code needed |
2711 to reproduce the problem, and include an exact recipe of steps needed to | 3221 to reproduce the problem, and include an exact recipe of steps needed to |
2712 expose the bug. Be especially sure to include any code that appears | 3222 expose the bug. Be especially sure to include any code that appears |
2713 @emph{before} your bug example. | 3223 @emph{before} your bug example, if you think it might affect my ability |
2714 | 3224 to reproduce it. |
2715 Bug reports are now to be sent to @code{bug-gnu-emacs@@prep.ai.mit.edu} | 3225 |
2716 which is mirrored on the Usenet newsgroup @code{gnu.emacs.bug}. Other | 3226 Bug reports are now sent to the following email addresses: |
2717 questions and suggestions should be mailed to | 3227 @code{cc-mode-help@@python.org} and |
2718 @code{help-gnu-emacs@@prep.ai.mit.edu} which is mirrored on | 3228 @code{bug-gnu-emacs@@prep.ai.mit.edu}; the latter is mirrored on the Usenet |
3229 newsgroup @code{gnu.emacs.bug}. Other questions and suggestions should | |
3230 be mailed to @code{help-gnu-emacs@@prep.ai.mit.edu} which is mirrored on | |
2719 @code{gnu.emacs.help}. | 3231 @code{gnu.emacs.help}. |
2720 | 3232 |
2721 Note that the @code{cc-mode} Majordomo mailing lists have been | |
2722 disbanded! With the inclusion of @code{cc-mode} in both of the latest | |
2723 flavors of Emacs 19, the need for them has ended. | |
2724 | 3233 |
2725 @c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 3234 @c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2726 @node Concept Index, Command Index, Mailing Lists and Submitting Bug Reports, Top | 3235 @node Concept Index, Command Index, Mailing Lists and Submitting Bug Reports, Top |
2727 @comment node-name, next, previous, up | 3236 @comment node-name, next, previous, up |
2728 @unnumbered Concept Index | 3237 @unnumbered Concept Index |
2739 | 3248 |
2740 @ifinfo | 3249 @ifinfo |
2741 | 3250 |
2742 @end ifinfo | 3251 @end ifinfo |
2743 Since all @code{cc-mode} commands are prepended with the string | 3252 Since all @code{cc-mode} commands are prepended with the string |
2744 @samp{c-}, each appears under its @code{c-<thing>} name and its | 3253 @samp{c-}, each appears under its @code{c-@var{<thing>}} name and its |
2745 @code{<thing> (c-)} name. | 3254 @code{@var{<thing>} (c-)} name. |
2746 @iftex | 3255 @iftex |
2747 @sp 2 | 3256 @sp 2 |
2748 @end iftex | 3257 @end iftex |
2749 @printindex fn | 3258 @printindex fn |
2750 | 3259 |
2766 | 3275 |
2767 @ifinfo | 3276 @ifinfo |
2768 | 3277 |
2769 @end ifinfo | 3278 @end ifinfo |
2770 Since all @code{cc-mode} variables are prepended with the string | 3279 Since all @code{cc-mode} variables are prepended with the string |
2771 @samp{c-}, each appears under its @code{c-<thing>} name and its | 3280 @samp{c-}, each appears under its @code{c-@var{<thing>}} name and its |
2772 @code{<thing> (c-)} name. | 3281 @code{@var{<thing>} (c-)} name. |
2773 @iftex | 3282 @iftex |
2774 @sp 2 | 3283 @sp 2 |
2775 @end iftex | 3284 @end iftex |
2776 @printindex vr | 3285 @printindex vr |
2777 @summarycontents | 3286 @summarycontents |