110
|
1 \input texinfo
|
0
|
2
|
|
3 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
4 @comment %**start of header (This is for running Texinfo on a region)
|
|
5 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
6
|
32
|
7 @setfilename cc-mode.info
|
165
|
8 @settitle CC MODE Version 5 Documentation
|
0
|
9 @footnotestyle end
|
|
10
|
|
11 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
12 @comment @setchapternewpage odd !! we don't want blank pages !!
|
|
13 @comment %**end of header (This is for running Texinfo on a region)
|
|
14 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
15
|
|
16
|
|
17 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
18 @comment
|
171
|
19 @comment Texinfo manual for CC Mode
|
165
|
20 @comment Generated from the original README file by Krishna Padmasola
|
0
|
21 @comment <krishna@earth-gw.njit.edu>
|
|
22 @comment
|
165
|
23 @comment Maintained by Barry A. Warsaw <cc-mode-help@python.org>
|
0
|
24 @comment
|
|
25 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
26
|
|
27
|
|
28 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
29 @comment The following line inserts the copyright notice
|
|
30 @comment into the Info file.
|
|
31 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
32
|
|
33 @ifinfo
|
2
|
34 Copyright @copyright{} 1995, 1996 Free Software Foundation, Inc.
|
0
|
35 @end ifinfo
|
|
36
|
|
37 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
38 @comment !!!The titlepage section does not appear in the Info file.!!!
|
|
39 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
40
|
|
41 @titlepage
|
|
42 @sp 10
|
|
43
|
|
44
|
|
45 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
46 @comment The title is printed in a large font.
|
|
47 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
48
|
177
|
49 @center @titlefont{CC Mode 5.14}
|
0
|
50 @sp 2
|
177
|
51 @center @subtitlefont{A GNU Emacs mode for editing C and C-like languages}
|
0
|
52 @sp 2
|
|
53 @center Barry A. Warsaw
|
|
54
|
|
55
|
|
56 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
57 @comment The following two commands start the copyright page
|
|
58 @comment for the printed manual. This will not appear in the Info file.
|
|
59 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
60
|
|
61 @page
|
|
62 @vskip 0pt plus 1filll
|
|
63 Copyright @copyright{} 1995 Free Software Foundation, Inc.
|
|
64 @end titlepage
|
|
65
|
|
66
|
|
67 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
68 @comment The Top node contains the master menu for the Info file.
|
|
69 @comment This appears only in the Info file, not the printed manual.
|
|
70 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
71
|
|
72 @node Top, Introduction, (dir), (dir)
|
|
73 @comment node-name, next, previous, up
|
|
74
|
|
75
|
|
76 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
77 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
78
|
|
79 @menu
|
|
80 * Introduction::
|
|
81 * Getting Connected::
|
|
82 * New Indentation Engine::
|
|
83 * Minor Modes::
|
2
|
84 * Commands::
|
0
|
85 * Customizing Indentation::
|
|
86 * Syntactic Symbols::
|
|
87 * Performance Issues::
|
|
88 * Frequently Asked Questions::
|
110
|
89 * Getting the latest CC Mode release::
|
0
|
90 * Sample .emacs File::
|
|
91 * Limitations and Known Bugs::
|
|
92 * Mailing Lists and Submitting Bug Reports::
|
|
93 * Concept Index::
|
|
94 * Command Index:: Command Index
|
|
95 * Key Index:: Key Index
|
|
96 * Variable Index:: Variable Index
|
|
97 @end menu
|
|
98
|
|
99 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
100 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
101
|
|
102 @node Introduction, Getting Connected, Top, Top
|
|
103 @comment node-name, next, previous, up
|
|
104 @chapter Introduction
|
|
105 @cindex Introduction
|
|
106
|
110
|
107 @macro ccmode
|
|
108 CC Mode
|
|
109 @end macro
|
|
110
|
0
|
111 @cindex BOCM
|
165
|
112
|
|
113 Welcome to @ccmode{}. This is a GNU Emacs mode for editing files
|
177
|
114 containing C, C++, Objective-C, Java, and IDL code. This incarnation of
|
|
115 the mode is descendant from @file{c-mode.el} (also called "Boring Old C
|
165
|
116 Mode" or BOCM @code{:-)}, and @file{c++-mode.el} version 2, which I have
|
|
117 been maintaining since 1992. @ccmode{} represents a significant
|
|
118 milestone in the mode's life. It has been fully merged back with Emacs
|
|
119 19's @file{c-mode.el}. Also a new, more intuitive and flexible mechanism
|
|
120 for controlling indentation has been developed.
|
|
121
|
|
122 @ccmode{} supports the editing of K&R and ANSI C, @dfn{ARM}
|
110
|
123 @footnote{``The Annotated C++ Reference Manual'', by Ellis and
|
177
|
124 Stroustrup.} C++, Objective-C, Java and IDL@footnote{CORBA's Interface
|
|
125 Definition Language} files. In this way, you can
|
110
|
126 easily set up consistent coding styles for use in editing all C, C++,
|
177
|
127 Objective-C, Java and IDL programs. @ccmode{} does @emph{not} handle
|
110
|
128 font-locking (a.k.a. syntax coloring, keyword highlighting) or anything
|
177
|
129 of that nature, for any of these modes. Font-locking is handled by other
|
110
|
130 Emacs packages.
|
0
|
131
|
|
132 This manual will describe the following:
|
|
133
|
|
134 @itemize @bullet
|
|
135 @item
|
110
|
136 How to get started using @ccmode{}.
|
0
|
137
|
|
138 @item
|
|
139 How the new indentation engine works.
|
|
140
|
|
141 @item
|
|
142 How to customize the new indentation engine.
|
|
143
|
|
144 @end itemize
|
|
145
|
177
|
146 @findex c-mode
|
|
147 @findex c++-mode
|
|
148 @findex objc-mode
|
|
149 @findex java-mode
|
|
150 @findex idl-mode
|
|
151 Note that the name of this package is ``@ccmode{}'', but there is no top
|
|
152 level @code{cc-mode} entry point. All of the variables, commands, and
|
|
153 functions in @ccmode{} are prefixed with @code{c-@var{<thing>}}, and
|
|
154 @code{c-mode}, @code{c++-mode}, @code{objc-mode}, @code{java-mode}, and
|
|
155 @code{idl-mode} entry points are provided. This file is intended to be
|
|
156 a replacement for @file{c-mode.el} and @file{c++-mode.el}.
|
0
|
157
|
|
158 @cindex @file{cc-compat.el} file
|
177
|
159 This distribution also contains a file
|
|
160 called @file{cc-compat.el} which should ease your transition from BOCM
|
|
161 to @ccmode{}. If you have a BOCM configuration you are really happy
|
|
162 with, and want to postpone learning how to configure @ccmode{}, take a
|
|
163 look at that file. It maps BOCM configuration variables to @ccmode{}'s
|
|
164 new indentation model. It is not actively supported so for the long
|
|
165 run, you should learn how to customize @ccmode{} to support your coding
|
|
166 style.
|
0
|
167
|
|
168 A special word of thanks goes to Krishna Padmasola for his work in
|
177
|
169 converting the original @file{README} file to Texinfo format. I'd also
|
|
170 like to thank all the @ccmode{} victims who help enormously during the
|
|
171 early beta stages of @ccmode{}'s development.
|
0
|
172
|
|
173
|
|
174 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
175
|
|
176 @node Getting Connected, New Indentation Engine, Introduction, Top
|
|
177 @comment node-name, next, previous, up
|
|
178 @chapter Getting Connected
|
|
179 @cindex Getting Connected
|
|
180
|
|
181 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
182
|
165
|
183 If you got this version of @ccmode{} with Emacs, it should work just
|
|
184 fine right out of the box, and you can safely skip to the next chapter.
|
|
185 Note however that you may not have the latest @ccmode{} release and may
|
|
186 want to upgrade your copy. See the @file{README} file, or the @ccmode{}
|
|
187 Web pages latest information on Emacs version compatibility,
|
|
188 @ref{Getting the latest CC Mode release}.
|
0
|
189
|
|
190 @cindex @file{cc-mode-18.el} file
|
165
|
191 @emph{@ccmode{} no longer works with Emacs 18!} The
|
|
192 @file{cc-mode-18.el} file is no longer distributed with @ccmode{}. If
|
|
193 you haven't upgraded from Emacs 18 by now, you are out of luck. The
|
|
194 rest of these installation instructions assume you are using one of the
|
|
195 new Emacs or XEmacs releases, that already come with @ccmode{}. These
|
|
196 instructions explain how to upgrade to use the latest @ccmode{}
|
|
197 release.
|
0
|
198
|
110
|
199 @cindex .emacs file
|
165
|
200
|
|
201 The first thing you will want to do is put the @ccmode{} source files in
|
|
202 a subdirectory somewhere on your @code{load-path} so Emacs can find it.
|
177
|
203 The distribution tarball unpacks into its own subdirectory,
|
|
204 e.g. @file{cc-mode/}. Assuming you unpacked the distribution in your
|
|
205 home directory, you should add the following to your @file{.emacs} file
|
|
206 in order to pick up the latest version of @ccmode{} over the one
|
|
207 distributed with your Emacs:
|
165
|
208
|
0
|
209 @example
|
165
|
210
|
177
|
211 (setq load-path (cons "~/cc-mode" load-path))
|
0
|
212
|
|
213 @end example
|
|
214
|
|
215 @cindex byte compile
|
165
|
216
|
|
217 Next you want to @dfn{byte compile} all the @ccmode{} source files.
|
|
218 @ccmode{} uses a lot of macros so if you don't byte compile it,
|
|
219 things will be unbearably slow. @emph{You can ignore all byte-compiler
|
|
220 warnings!} They are the result of the supporting different versions of
|
|
221 Emacs, and none of the warnings have any effect on operation. Let me say
|
|
222 this again: @strong{You really can ignore all byte-compiler warnings!}
|
|
223
|
177
|
224 To byte-compile the source files, first @code{cd} to the directory you
|
|
225 unpacked the tarball into. Then run the following command at your shell
|
|
226 prompt:
|
165
|
227
|
0
|
228 @example
|
|
229
|
177
|
230 % $EMACS -batch -no-site-file -q -l cc-make.el cc-*.el
|
0
|
231
|
|
232 @end example
|
|
233
|
177
|
234 @noindent
|
|
235 where $EMACS is either @code{emacs} or @code{xemacs} depending on the
|
|
236 version you use.
|
0
|
237
|
165
|
238 Next time you start up Emacs you should be using the latest @ccmode{}.
|
|
239 You can test this by visiting a C file and hitting @kbd{M-x c-version
|
|
240 RET}; you should see this message in the echo area:
|
0
|
241 @example
|
165
|
242
|
177
|
243 Using CC Mode version 5.XX
|
0
|
244
|
|
245 @end example
|
|
246
|
|
247 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
248 @node New Indentation Engine, Minor Modes, Getting Connected, Top
|
110
|
249 @comment node-name, next, previous, up
|
0
|
250
|
|
251 @chapter New Indentation Engine
|
|
252 @cindex New Indentation Engine
|
|
253 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
254
|
110
|
255 @ccmode{} has a new indentation engine, providing a simplified, yet
|
|
256 flexible and general mechanism for customizing indentation. It separates
|
|
257 indentation calculation into two steps: first, @ccmode{} analyzes the
|
|
258 line of code being indented to determine the kind of language construct
|
|
259 it's looking at, then it applies user defined offsets to the current
|
|
260 line based on this analysis.
|
0
|
261
|
|
262 This section will briefly cover how indentation is calculated in
|
110
|
263 @ccmode{}. It is important to understand the indentation model
|
|
264 being used so that you will know how to customize @ccmode{} for
|
0
|
265 your personal coding style.
|
|
266
|
|
267 @menu
|
|
268 * Syntactic Analysis::
|
|
269 * Indentation Calculation::
|
|
270 @end menu
|
2
|
271
|
0
|
272
|
|
273 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
274 @node Syntactic Analysis, Indentation Calculation, , New Indentation Engine
|
|
275 @comment node-name, next, previous,up
|
|
276 @section Syntactic Analysis
|
|
277 @cindex Syntactic Analysis
|
|
278 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
279
|
|
280 @vindex c-offsets-alist
|
|
281 @vindex offsets-alist (c-)
|
|
282 @cindex relative buffer position
|
|
283 @cindex syntactic symbol
|
|
284 @cindex syntactic component
|
|
285 @cindex syntactic component list
|
|
286 @cindex relative buffer position
|
110
|
287 The first thing @ccmode{} does when indenting a line of code, is to
|
0
|
288 analyze the line, determining the @dfn{syntactic component list} of the
|
177
|
289 construct on that line. A syntactic component consists of a pair
|
0
|
290 of information (in lisp parlance, a @emph{cons cell}), where the first
|
|
291 part is a @dfn{syntactic symbol}, and the second part is a @dfn{relative
|
|
292 buffer position}. Syntactic symbols describe elements of C code
|
177
|
293 @footnote{or C++, Objective-C, Java or IDL code. In general, for the rest
|
0
|
294 of this manual I'll use the term ``C code'' to refer to all the C-like
|
|
295 dialects, unless otherwise noted.}, e.g. @code{statement},
|
|
296 @code{substatement}, @code{class-open}, @code{class-close}, etc.
|
|
297 @xref{Syntactic Symbols}, for a complete list of currently recognized
|
|
298 syntactic symbols and their semantics. The variable
|
|
299 @code{c-offsets-alist} also contains the list of currently supported
|
|
300 syntactic symbols.
|
|
301
|
|
302 Conceptually, a line of C code is always indented relative to the
|
|
303 indentation of some line higher up in the buffer. This is represented
|
|
304 by the relative buffer position in the syntactic component.
|
|
305
|
110
|
306 Here is an example. Suppose we had the following code as the only thing
|
|
307 in a @code{c++-mode} buffer @footnote{The line numbers in this and
|
|
308 future examples don't actually appear in the buffer, of course!}:
|
0
|
309 @example
|
|
310 @group
|
|
311
|
|
312 1: void swap( int& a, int& b )
|
|
313 2: @{
|
|
314 3: int tmp = a;
|
|
315 4: a = b;
|
|
316 5: b = tmp;
|
|
317 6: @}
|
|
318
|
|
319 @end group
|
|
320 @end example
|
|
321
|
|
322 @kindex C-c C-s
|
|
323 @findex c-show-syntactic-information
|
|
324 @findex show-syntactic-information (c-)
|
|
325 We can use the command @kbd{C-c C-s}
|
|
326 (@code{c-show-syntactic-information}) to simply report what the
|
|
327 syntactic analysis is for the current line. Running this command on
|
177
|
328 line 4 of this example, we'd see in the echo area@footnote{With a universal
|
2
|
329 argument (i.e. @kbd{C-u C-c C-s}) the analysis is inserted into the
|
|
330 buffer as a comment
|
|
331 on the current line.}:
|
0
|
332 @example
|
|
333
|
|
334 ((statement . 35))
|
|
335
|
|
336 @end example
|
|
337
|
|
338 This tells us that the line is a statement and it is indented relative
|
|
339 to buffer position 35, which happens to be the @samp{i} in @code{int} on
|
110
|
340 line 3. If you were to move point to line 3 and hit @kbd{C-c C-s}, you
|
0
|
341 would see:
|
|
342 @example
|
|
343
|
|
344 ((defun-block-intro . 29))
|
|
345
|
|
346 @end example
|
|
347
|
|
348 This indicates that the @samp{int} line is the first statement in a top
|
|
349 level function block, and is indented relative to buffer position 29,
|
|
350 which is the brace just after the function header.
|
|
351
|
|
352 Here's another example:
|
|
353 @example
|
|
354 @group
|
|
355
|
|
356 1: int add( int val, int incr, int doit )
|
|
357 2: @{
|
|
358 3: if( doit )
|
|
359 4: @{
|
|
360 5: return( val + incr );
|
|
361 6: @}
|
|
362 7: return( val );
|
|
363 8: @}
|
|
364
|
|
365 @end group
|
|
366 @end example
|
|
367
|
|
368 @noindent
|
|
369 Hitting @kbd{C-c C-s} on line 4 gives us:
|
|
370 @example
|
|
371
|
|
372 ((substatement-open . 46))
|
|
373
|
|
374 @end example
|
|
375
|
|
376 @cindex substatement
|
|
377 @cindex substatment block
|
|
378 @noindent
|
|
379 which tells us that this is a brace that @emph{opens} a substatement
|
110
|
380 block. @footnote{A @dfn{substatement} indicates the line after a
|
|
381 conditional statement, such as @code{if}, @code{else}, @code{while},
|
|
382 @code{do}, @code{switch}, or @code{for} in C. A @dfn{substatement
|
|
383 block} is a brace block following one of those conditionals.}
|
0
|
384
|
|
385 @cindex comment only line
|
|
386 Syntactic component lists can contain more than one component, and
|
|
387 individual syntactic components need not have relative buffer positions.
|
|
388 The most common example of this is a line that contains a @dfn{comment
|
|
389 only line}.
|
|
390 @example
|
|
391 @group
|
|
392
|
|
393 1: void draw_list( List<Drawables>& drawables )
|
|
394 2: @{
|
|
395 3: // call the virtual draw() method on each element in list
|
|
396 4: for( int i=0; i < drawables.count(), ++i )
|
|
397 5: @{
|
|
398 6: drawables[i].draw();
|
|
399 7: @}
|
|
400 8: @}
|
|
401
|
|
402 @end group
|
|
403 @end example
|
|
404
|
|
405 @noindent
|
2
|
406 Hitting @kbd{C-c C-s} on line 3 of this example gives:
|
0
|
407 @example
|
|
408
|
|
409 ((comment-intro) (defun-block-intro . 46))
|
|
410
|
|
411 @end example
|
|
412
|
|
413 @noindent
|
2
|
414 and you can see that the syntactic component list contains two syntactic
|
0
|
415 components. Also notice that the first component,
|
|
416 @samp{(comment-intro)} has no relative buffer position.
|
|
417
|
|
418
|
|
419 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
420 @node Indentation Calculation, , Syntactic Analysis, New Indentation Engine
|
|
421 @comment node-name, next, previous,up
|
|
422 @section Indentation Calculation
|
|
423 @cindex Indentation Calculation
|
|
424 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
425
|
|
426 @vindex c-offsets-alist
|
|
427 @vindex offsets-alist (c-)
|
|
428 Indentation for the current line is calculated using the syntactic
|
|
429 component list derived in step 1 above (see @ref{Syntactic Analysis}).
|
|
430 Each component contributes to the final total indentation of the line in
|
|
431 two ways.
|
|
432
|
|
433 First, the syntactic symbols are looked up in the @code{c-offsets-alist}
|
|
434 variable, which is an association list of syntactic symbols and the
|
2
|
435 offsets to apply for those symbols. These offsets are added to a
|
0
|
436 running total.
|
|
437
|
110
|
438 Second, if the component has a relative buffer position, @ccmode{}
|
0
|
439 adds the column number of that position to the running total. By adding
|
|
440 up the offsets and columns for every syntactic component on the list,
|
|
441 the final total indentation for the current line is computed.
|
|
442
|
|
443 Let's use our two code examples above to see how this works. Here is
|
|
444 our first example again:
|
|
445 @example
|
|
446 @group
|
|
447
|
|
448 1: void swap( int& a, int& b )
|
|
449 2: @{
|
|
450 3: int tmp = a;
|
|
451 4: a = b;
|
|
452 5: b = tmp;
|
|
453 6: @}
|
|
454
|
|
455 @end group
|
|
456 @end example
|
|
457
|
|
458 @kindex TAB
|
110
|
459 Let's say point is on line 3 and we hit the @key{TAB} key to re-indent
|
0
|
460 the line. Remember that the syntactic component list for that
|
|
461 line is:
|
|
462 @example
|
|
463
|
|
464 ((defun-block-intro . 29))
|
|
465
|
|
466 @end example
|
|
467
|
|
468 @noindent
|
110
|
469 @ccmode{} looks up @code{defun-block-intro} in the
|
0
|
470 @code{c-offsets-alist} variable. Let's say it finds the value @samp{4};
|
|
471 it adds this to the running total (initialized to zero), yielding a
|
|
472 running total indentation of 4 spaces.
|
|
473
|
110
|
474 Next @ccmode{} goes to buffer position 29 and asks for the current
|
|
475 column. This brace is in column zero, so @ccmode{}
|
0
|
476 adds @samp{0} to the running total. Since there is only one syntactic
|
|
477 component on the list for this line, indentation calculation is
|
|
478 complete, and the total indentation for the line
|
|
479 is 4 spaces.
|
|
480
|
|
481 Here's another example:
|
|
482 @example
|
|
483 @group
|
|
484
|
|
485 1: int add( int val, int incr, int doit )
|
|
486 2: @{
|
|
487 3: if( doit )
|
|
488 4: @{
|
|
489 5: return( val + incr );
|
|
490 6: @}
|
|
491 7: return( val );
|
|
492 8: @}
|
|
493
|
|
494 @end group
|
|
495 @end example
|
|
496
|
|
497 If we were to hit @kbd{TAB} on line 4 in the above example, the same
|
|
498 basic process is performed, despite the differences in the syntactic
|
|
499 component list. Remember that the list for this line is:
|
|
500 @example
|
|
501
|
|
502 ((substatement-open . 46))
|
|
503
|
|
504 @end example
|
|
505
|
110
|
506 Here, @ccmode{} first looks up the @code{substatement-open} symbol
|
0
|
507 in @code{c-offsets-alist}. Let's say it finds the value @samp{4}. This
|
110
|
508 yields a running total of 4. @ccmode{} then goes to
|
0
|
509 buffer position 46, which is the @samp{i} in @code{if} on line 3. This
|
|
510 character is in the fourth column on that line so adding this to the
|
|
511 running total yields an indentation for the line of 8 spaces.
|
|
512
|
|
513 Simple, huh?
|
|
514
|
|
515 Actually, the mode usually just does The Right Thing without you having
|
|
516 to think about it in this much detail. But when customizing
|
|
517 indentation, it's helpful to understand the general indentation model
|
|
518 being used.
|
|
519
|
|
520 @vindex c-echo-syntactic-information-p
|
|
521 @vindex echo-syntactic-information-p (c-)
|
|
522 @cindex TAB
|
110
|
523 As you configure @ccmode{}, you might want to set the variable
|
0
|
524 @code{c-echo-syntactic-information-p} to non-@code{nil} so that the
|
|
525 syntactic component list and calculated offset will always be echoed in
|
|
526 the minibuffer when you hit @kbd{TAB}.
|
|
527
|
|
528
|
|
529 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
2
|
530 @node Minor Modes, Commands, New Indentation Engine, Top
|
0
|
531 @comment node-name, next, previous,up
|
|
532
|
|
533 @chapter Minor Modes
|
|
534 @cindex Minor Modes
|
|
535 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
536
|
110
|
537 @ccmode{} contains two minor-mode-like features that you should
|
0
|
538 find useful while you enter new C code. The first is called
|
|
539 @dfn{auto-newline} mode, and the second is called @dfn{hungry-delete}
|
|
540 mode. These minor modes can be toggled on and off independently, and
|
110
|
541 @ccmode{} can be configured so that it starts up with any
|
0
|
542 combination of these minor modes. By default, both of these minor modes
|
|
543 are turned off.
|
|
544
|
|
545 The state of the minor modes is always reflected in the minor mode list
|
110
|
546 on the modeline of the @ccmode{} buffer. When auto-newline mode is
|
0
|
547 enabled, you will see @samp{C/a} on the mode line @footnote{Remember
|
177
|
548 that the @samp{C} could be replaced with @samp{C++}, @samp{ObjC},
|
|
549 @samp{Java} or @samp{IDL}.}. When hungry delete mode is enabled you
|
|
550 would see @samp{C/h} and when both modes are enabled, you'd see
|
|
551 @samp{C/ah}.
|
0
|
552
|
|
553 @kindex C-c C-a
|
|
554 @kindex C-c C-d
|
|
555 @kindex C-c C-t
|
|
556 @findex c-toggle-hungry-state
|
|
557 @findex c-toggle-auto-state
|
|
558 @findex c-toggle-auto-hungry-state
|
|
559 @findex toggle-hungry-state (c-)
|
|
560 @findex toggle-auto-state (c-)
|
|
561 @findex toggle-auto-hungry-state (c-)
|
110
|
562 @ccmode{} provides keybindings which allow you to toggle the minor
|
2
|
563 modes on the fly while editing code. To toggle just the auto-newline
|
0
|
564 state, hit @kbd{C-c C-a} (@code{c-toggle-auto-state}). When you do
|
|
565 this, you should see the @samp{a} indicator either appear or disappear
|
|
566 on the modeline. Similarly, to toggle just the hungry-delete state, use
|
2
|
567 @kbd{C-c C-d} (@code{c-toggle-hungry-state}), and to toggle both states,
|
|
568 use @kbd{C-c C-t} (@code{c-toggle-auto-hungry-state}).
|
0
|
569
|
|
570 To set up the auto-newline and hungry-delete states to your preferred
|
|
571 values, you would need to add some lisp to your @file{.emacs} file that
|
|
572 called one of the @code{c-toggle-*-state} functions directly. When
|
|
573 called programmatically, each function takes a numeric value, where
|
|
574 a positive number enables the minor mode, a negative number disables the
|
|
575 mode, and zero toggles the current state of the mode.
|
|
576
|
|
577 So for example, if you wanted to enable both auto-newline and
|
|
578 hungry-delete for all your C file editing, you could add the following
|
|
579 to your @file{.emacs} file:
|
|
580 @example
|
|
581
|
110
|
582 (add-hook 'c-mode-common-hook
|
|
583 '(lambda () (c-toggle-auto-hungry-state 1)))
|
0
|
584
|
|
585 @end example
|
|
586
|
|
587
|
|
588 @cindex electric characters
|
|
589
|
|
590 @menu
|
|
591 * Auto-newline insertion::
|
|
592 * Hungry-deletion of whitespace::
|
|
593 @end menu
|
|
594
|
|
595 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
596 @node Auto-newline insertion, Hungry-deletion of whitespace, , Minor Modes
|
|
597 @comment node-name, next, previous,up
|
|
598
|
|
599 @section Auto-newline insertion
|
|
600 @cindex Auto-newline insertion
|
|
601 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
602
|
|
603 @cindex electric commands
|
|
604 Auto-newline minor mode works by enabling certain @dfn{electric
|
|
605 commands}. Electric commands are typically bound to special characters
|
|
606 such as the left and right braces, colons, semi-colons, etc., which when
|
|
607 typed, perform some magic formatting in addition to inserting the typed
|
|
608 character. As a general rule, electric commands are only electric when
|
|
609 the following conditions apply:
|
|
610
|
|
611 @itemize @bullet
|
|
612 @item
|
|
613 Auto-newline minor mode is enabled, as evidenced by a @samp{C/a} or
|
|
614 @samp{C/ah} indicator on the modeline.
|
|
615
|
|
616 @cindex literal
|
|
617 @cindex syntactic whitespace
|
|
618 @item
|
|
619 The character was not typed inside of a literal @footnote{A
|
110
|
620 @dfn{literal} is defined as any comment, string, or cpp macro
|
|
621 definition. These constructs are also known as @dfn{syntactic
|
|
622 whitespace} since they are usually ignored when scanning C code.}.
|
0
|
623
|
|
624 @item
|
|
625 @kindex C-u
|
|
626 No numeric argument was supplied to the command (i.e. it was typed as
|
|
627 normal, with no @kbd{C-u} prefix).
|
|
628
|
|
629 @end itemize
|
|
630
|
110
|
631 @findex c-enable-//-in-c-mode
|
|
632 @findex enable-//-in-c-mode (c-)
|
|
633 Some characters are electric in some languages, and not in others. For
|
0
|
634 example, the second slash (@kbd{/}) of a C++ style line comment is
|
177
|
635 electric in @code{c++-mode}, @code{objc-mode}, @code{java-mode}, and
|
|
636 @code{idl-mode}, but not in @code{c-mode}@footnote{Ordinarily, @samp{//}
|
|
637 does not introduce a comment in @code{c-mode}. However, if you call the
|
|
638 function @code{c-enable-//-in-c-mode}, @code{c-mode} will recognize C++
|
|
639 style line comments. Note however that this is a global change which
|
|
640 will affect all your @code{c-mode} buffers.}.
|
0
|
641
|
|
642
|
|
643 @menu
|
|
644 * Hanging Braces::
|
|
645 * Hanging Colons::
|
|
646 * Hanging Semi-colons and commas::
|
|
647 * Other electric commands::
|
|
648 * Clean-ups::
|
|
649 @end menu
|
|
650
|
|
651 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
652 @node Hanging Braces, Hanging Colons, , Auto-newline insertion
|
|
653 @comment node-name, next, previous,up
|
|
654
|
|
655 @subsection Hanging Braces
|
|
656 @cindex Hanging Braces
|
|
657 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
658
|
|
659 @findex c-electric-brace
|
|
660 @findex electric-brace (c-)
|
|
661 @vindex c-hanging-braces-alist
|
|
662 @vindex hanging-braces-alist (c-)
|
|
663 @vindex c-offsets-alist
|
|
664 @vindex offsets-alist (c-)
|
|
665 When you type either an open or close brace (i.e. @kbd{@{} or @kbd{@}}),
|
|
666 the electric command @code{c-electric-brace} gets run. This command has
|
|
667 two electric formatting behaviors. First, it will perform some
|
|
668 re-indentation of the line the brace was typed on, and second, it will
|
|
669 add various newlines before and/or after the typed brace.
|
|
670 Re-indentation occurs automatically whenever the electric behavior is
|
|
671 enabled. If the brace ends up on a line other than the one it was typed
|
2
|
672 on, then that line is also indented according to
|
0
|
673 @code{c-offsets-alist}.
|
|
674
|
|
675 @cindex class-open syntactic symbol
|
|
676 @cindex class-close syntactic symbol
|
|
677 @cindex defun-open syntactic symbol
|
|
678 @cindex defun-close syntactic symbol
|
|
679 @cindex inline-open syntactic symbol
|
|
680 @cindex inline-close syntactic symbol
|
|
681 @cindex brace-list-open syntactic symbol
|
|
682 @cindex brace-list-close syntactic symbol
|
|
683 @cindex brace-list-intro syntactic symbol
|
|
684 @cindex brace-list-entry syntactic symbol
|
|
685 @cindex block-open syntactic symbol
|
|
686 @cindex block-close syntactic symbol
|
|
687 @cindex substatement-open syntactic symbol
|
|
688 @cindex statement-case-open syntactic symbol
|
2
|
689 @cindex extern-lang-open syntactic symbol
|
|
690 @cindex extern-lang-close syntactic symbol
|
0
|
691
|
|
692 The insertion of newlines is controlled by the
|
|
693 @code{c-hanging-braces-alist} variable. This variable contains a
|
|
694 mapping between syntactic symbols related to braces, and a list of
|
|
695 places to insert a newline. The syntactic symbols that are useful for
|
|
696 this list are: @code{class-open}, @code{class-close}, @code{defun-open},
|
|
697 @code{defun-close}, @code{inline-open}, @code{inline-close},
|
|
698 @code{brace-list-open}, @code{brace-list-close},
|
|
699 @code{brace-list-intro}, @code{brace-list-entry}, @code{block-open},
|
2
|
700 @code{block-close}, @code{substatement-open},
|
|
701 @code{statement-case-open},
|
|
702 @code{extern-lang-open}, and @code{extern-lang-close}.
|
|
703 @xref{Syntactic Symbols} for a more
|
0
|
704 detailed description of these syntactic symbols.
|
|
705
|
|
706 @cindex custom indentation function
|
|
707 The value associated with each syntactic symbol in this association list
|
|
708 is called an @var{ACTION} which can be either a function or a list.
|
|
709 @xref{Custom Brace and Colon Hanging} for a more detailed discussion of
|
|
710 using a function as a brace hanging @var{ACTION}.
|
|
711
|
2
|
712 When the @var{ACTION} is a list, it can contain any combination of the
|
110
|
713 symbols @code{before} and @code{after}, directing @ccmode{} where to
|
0
|
714 put newlines in relationship to the brace being inserted. Thus, if the
|
|
715 list contains only the symbol @code{after}, then the brace is said to
|
|
716 @dfn{hang} on the right side of the line, as in:
|
|
717 @example
|
|
718 @group
|
|
719
|
|
720 // here, open braces always `hang'
|
|
721 void spam( int i ) @{
|
|
722 if( i == 7 ) @{
|
|
723 dosomething(i);
|
|
724 @}
|
|
725 @}
|
|
726
|
|
727
|
|
728 @end group
|
|
729 @end example
|
|
730
|
|
731 When the list contains both @code{after} and @code{before}, the braces
|
|
732 will appear on a line by themselves, as shown by the close braces in the
|
|
733 above example. The list can also be empty, in which case no newlines
|
|
734 are added either before or after the brace.
|
|
735
|
|
736 For example, the default value of @code{c-hanging-braces-alist} is:
|
|
737 @example
|
|
738 @group
|
|
739
|
|
740 (defvar c-hanging-braces-alist '((brace-list-open)
|
|
741 (substatement-open after)
|
2
|
742 (block-close . c-snug-do-while)
|
|
743 (extern-lang-open after)))
|
0
|
744
|
|
745 @end group
|
|
746 @end example
|
|
747
|
|
748 @noindent
|
|
749 which says that @code{brace-list-open} braces should both hang on the
|
|
750 right side, and allow subsequent text to follow on the same line as the
|
2
|
751 brace. Also, @code{substatement-open} and @code{extern-lang-open}
|
|
752 braces should hang on the right side, but subsequent text should follow
|
|
753 on the next line. Here, in the @code{block-close} entry, you also see
|
|
754 an example of using a function as an @var{ACTION}.
|
0
|
755
|
110
|
756 A word of caution: it is not a good idea to hang top-level construct
|
|
757 introducing braces, such as @code{class-open} or @code{defun-open}.
|
|
758 Emacs makes an assumption that such braces will always appear in column
|
|
759 zero, hanging such braces can introduce performance problems.
|
|
760 @xref{Performance Issues} for more information.
|
|
761
|
0
|
762
|
|
763 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
764 @node Hanging Colons, Hanging Semi-colons and commas, Hanging Braces, Auto-newline insertion
|
|
765 @comment node-name, next, previous,up
|
|
766
|
|
767 @subsection Hanging Colons
|
|
768 @cindex Hanging Colons
|
|
769 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
770
|
|
771 @vindex hanging-colons-alist (c-)
|
|
772 @vindex c-hanging-colons-alist
|
|
773 Using a mechanism similar to brace hanging (see @ref{Hanging Braces}),
|
|
774 colons can also be made to hang using the variable
|
|
775 @code{c-hanging-colons-alist}. The syntactic symbols appropriate for
|
|
776 this assocation list are: @code{case-label}, @code{label},
|
|
777 @code{access-label}, @code{member-init-intro}, and @code{inher-intro}.
|
177
|
778 Note however that for @code{c-hanging-colons-alist}, @var{ACTION}s as
|
2
|
779 functions are not supported. See also @ref{Custom Brace and Colon
|
|
780 Hanging} for details.
|
0
|
781
|
|
782 @cindex clean-ups
|
|
783 In C++, double-colons are used as a scope operator but because these
|
|
784 colons always appear right next to each other, newlines before and after
|
|
785 them are controlled by a different mechanism, called @dfn{clean-ups} in
|
110
|
786 @ccmode{}. @xref{Clean-ups} for details.
|
0
|
787
|
|
788
|
|
789 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
790 @node Hanging Semi-colons and commas, Other electric commands, Hanging Colons, Auto-newline insertion
|
|
791 @comment node-name, next, previous,up
|
|
792
|
|
793 @subsection Hanging Semi-colons and commas
|
|
794 @cindex Hanging Semi-colons and commas
|
|
795 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
796
|
110
|
797 Semicolons and commas are also electric in @ccmode{}, but since
|
0
|
798 these characters do not correspond directly to syntactic symbols, a
|
|
799 different mechanism is used to determine whether newlines should be
|
|
800 automatically inserted after these characters. @xref{Customizing
|
|
801 Semi-colons and Commas} for details.
|
|
802
|
|
803
|
|
804 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
805 @node Other electric commands, Clean-ups, Hanging Semi-colons and commas, Auto-newline insertion
|
|
806 @comment node-name, next, previous,up
|
|
807
|
|
808 @subsection Other electric commands
|
|
809 @cindex Other electric commands
|
|
810 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
811
|
|
812 @kindex #
|
|
813 @findex c-electric-pound
|
|
814 @vindex c-electric-pound-behavior
|
|
815 @findex electric-pound (c-)
|
|
816 @vindex electric-pound-behavior (c-)
|
|
817 @vindex c-offsets-alist
|
|
818 @vindex offsets-alist (c-)
|
2
|
819 A few other keys also provide electric behavior. For example
|
|
820 @kbd{#} (@code{c-electric-pound}) is electric when typed as
|
0
|
821 the first non-whitespace character on a line. In this case, the
|
|
822 variable @code{c-electric-pound-behavior} is consulted for the electric
|
|
823 behavior. This variable takes a list value, although the only element
|
|
824 currently defined is @code{alignleft}, which tells this command to force
|
|
825 the @samp{#} character into column zero. This is useful for entering
|
|
826 cpp macro definitions.
|
|
827
|
|
828 @findex c-electric-star
|
|
829 @findex c-electric-slash
|
|
830 @findex electric-star (c-)
|
|
831 @findex electric-slash (c-)
|
|
832 @cindex comment-only line
|
2
|
833 Stars and slashes (i.e. @kbd{*} and @kbd{/}, @code{c-electric-star} and
|
|
834 @code{c-electric-slash} respectively) are also electric under
|
0
|
835 certain circumstances. If a star is inserted as the second character of
|
|
836 a C style block comment on a @dfn{comment-only} line, then the comment
|
|
837 delimiter is indented as defined by @code{c-offsets-alist}. A
|
|
838 comment-only line is defined as a line which contains only a comment, as
|
|
839 in:
|
|
840 @example
|
|
841 @group
|
|
842
|
|
843 void spam( int i )
|
|
844 @{
|
|
845 // this is a comment-only line...
|
|
846 if( i == 7 ) // but this is not
|
|
847 @{
|
|
848 dosomething(i);
|
|
849 @}
|
|
850 @}
|
|
851
|
|
852 @end group
|
|
853 @end example
|
|
854
|
|
855 Likewise, if a slash is inserted as the second slash in a C++ style line
|
|
856 comment (also only on a comment-only line), then the line is indented as
|
|
857 defined by @code{c-offsets-alist}.
|
|
858
|
2
|
859 @findex c-electric-lt-gt
|
|
860 @findex electric-lt-gt (c-)
|
|
861 @kindex <
|
|
862 @kindex >
|
|
863 Less-than and greater-than signs (@code{c-electric-lt-gt}) are also
|
|
864 electric, but only in C++ mode. Hitting the second of two @kbd{<} or
|
|
865 @kbd{>} keys re-indents the line if it is a C++ style stream operator.
|
|
866
|
0
|
867
|
|
868 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
869 @node Clean-ups, , Other electric commands, Auto-newline insertion
|
|
870 @comment node-name, next, previous,up
|
|
871
|
|
872 @subsection Clean-ups
|
|
873 @cindex Clean-ups
|
|
874 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
875
|
|
876 @dfn{Clean-ups} are a mechanism complementary to colon and brace
|
|
877 hanging. On the surface, it would seem that clean-ups overlap the
|
|
878 functionality provided by the @code{c-hanging-*-alist} variables, and
|
|
879 similarly, clean-ups are only enabled when auto-newline minor mode is
|
|
880 enabled. Clean-ups are used however to adjust code ``after-the-fact'',
|
177
|
881 i.e. to eliminate some whitespace that is inserted by electric
|
0
|
882 commands, or whitespace that contains intervening constructs.
|
|
883
|
|
884 @cindex literal
|
110
|
885 You can configure @ccmode{}'s clean-ups by setting the variable
|
0
|
886 @code{c-cleanup-list}, which is a list of clean-up symbols. By default,
|
110
|
887 @ccmode{} cleans up only the @code{scope-operator} construct, which
|
0
|
888 is necessary for proper C++ support. Note that clean-ups are only
|
|
889 performed when the construct does not occur within a literal (see
|
|
890 @ref{Auto-newline insertion}), and when there is nothing but whitespace
|
|
891 appearing between the individual components of the construct.
|
|
892
|
|
893 @vindex c-cleanup-list
|
|
894 @vindex cleanup-list (c-)
|
110
|
895 There are currently only five specific constructs that @ccmode{}
|
0
|
896 can clean up, as indicated by these symbols:
|
|
897
|
|
898 @itemize @bullet
|
|
899 @item
|
2
|
900 @code{brace-else-brace} --- cleans up @samp{@} else @{} constructs by
|
0
|
901 placing the entire construct on a single line. Clean-up occurs when the
|
|
902 open brace after the @samp{else} is typed. So for example, this:
|
|
903 @example
|
|
904 @group
|
|
905
|
|
906 void spam(int i)
|
|
907 @{
|
|
908 if( i==7 )
|
|
909 @{
|
|
910 dosomething();
|
|
911 @}
|
|
912 else
|
|
913 @{
|
|
914
|
|
915 @end group
|
|
916 @end example
|
|
917 @noindent
|
|
918 appears like this after the open brace is typed:
|
|
919 @example
|
|
920 @group
|
|
921
|
|
922 void spam(int i)
|
|
923 @{
|
|
924 if( i==7 ) @{
|
|
925 dosomething();
|
|
926 @} else @{
|
|
927
|
|
928 @end group
|
|
929 @end example
|
|
930
|
|
931 @item
|
110
|
932 @code{brace-elseif-brace} --- similar to the @code{brace-else-brace}
|
|
933 clean-up, but cleans up @samp{@} else if (...)@{} constructs. For
|
|
934 example:
|
|
935 @example
|
|
936 @group
|
|
937
|
|
938 void spam(int i)
|
|
939 @{
|
|
940 if( i==7 )
|
|
941 @{
|
|
942 dosomething();
|
|
943 @}
|
|
944 else if( i==3 ) @{
|
|
945
|
|
946 @end group
|
|
947 @end example
|
|
948 @noindent
|
|
949 appears like this after the open brace is typed:
|
|
950 @example
|
|
951 @group
|
|
952
|
|
953 void spam(int i)
|
|
954 @{
|
|
955 if( i==7 ) @{
|
|
956 dosomething();
|
|
957 @} else if( i==3 ) @{
|
|
958
|
|
959 @end group
|
|
960 @end example
|
|
961
|
|
962 @item
|
2
|
963 @code{empty-defun-braces} --- cleans up braces following a top-level
|
0
|
964 function or class definition that contains no body. Clean up occurs
|
|
965 when the closing brace is typed. Thus the following:
|
|
966 @example
|
|
967 @group
|
|
968
|
|
969 class Spam
|
|
970 @{
|
|
971 @}
|
|
972
|
|
973 @end group
|
|
974 @end example
|
|
975 @noindent
|
|
976 is transformed into this when the close brace is typed:
|
|
977 @example
|
|
978 @group
|
|
979
|
|
980 class Spam
|
|
981 @{@}
|
|
982
|
|
983 @end group
|
|
984 @end example
|
|
985
|
|
986 @item
|
2
|
987 @code{defun-close-semi} --- cleans up the terminating semi-colon on
|
0
|
988 top-level function or class definitions when they follow a close
|
|
989 brace. Clean up occurs when the semi-colon is typed.
|
|
990 So for example, the following:
|
|
991 @example
|
|
992 @group
|
|
993
|
|
994 class Spam
|
|
995 @{
|
|
996 @}
|
|
997 ;
|
|
998
|
|
999 @end group
|
|
1000 @end example
|
|
1001 @noindent
|
|
1002 is transformed into this when the semi-colon is typed:
|
|
1003
|
|
1004 @example
|
|
1005 @group
|
|
1006
|
|
1007 class Spam
|
|
1008 @{
|
|
1009 @};
|
|
1010
|
|
1011 @end group
|
|
1012 @end example
|
|
1013
|
|
1014 @item
|
2
|
1015 @code{list-close-comma} --- cleans up commas following braces in array
|
0
|
1016 and aggregate initializers. Clean up occurs when the comma is typed.
|
|
1017
|
|
1018 @item
|
2
|
1019 @code{scope-operator} --- cleans up double colons which may designate a
|
0
|
1020 C++ scope operator split across multiple lines@footnote{Certain C++
|
|
1021 constructs introduce ambiguous situations, so @code{scope-operator}
|
|
1022 clean-ups may not always be correct. This usually only occurs when
|
|
1023 scoped identifiers appear in switch label tags.}. Clean up occurs when
|
|
1024 the second colon is typed. You will always want @code{scope-operator}
|
|
1025 in the @code{c-cleanup-list} when you are editing C++ code.
|
|
1026
|
|
1027 @end itemize
|
|
1028
|
|
1029
|
|
1030 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
1031 @node Hungry-deletion of whitespace, , Auto-newline insertion, Minor Modes
|
|
1032 @comment node-name, next, previous,up
|
|
1033
|
|
1034 @section Hungry-deletion of whitespace
|
|
1035 @cindex Hungry-deletion of whitespace
|
|
1036 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
1037
|
|
1038 Hungry deletion of whitespace, or as it more commonly called,
|
|
1039 @dfn{hungry-delete mode}, is a simple feature that some people find
|
|
1040 extremely useful. In fact, you might find yourself wanting
|
|
1041 hungry-delete in @strong{all} your editing modes!
|
|
1042
|
|
1043 @kindex DEL
|
165
|
1044 @kindex Backspace
|
|
1045 In a nutshell, when hungry-delete mode is enabled, hitting the
|
|
1046 @kbd{Backspace} key@footnote{I say ``hit the @kbd{Backspace} key'' but
|
|
1047 what I really mean is ``when Emacs receives the @code{BackSpace} keysym
|
|
1048 event''. The difference usually isn't significant to most users, but
|
|
1049 advanced users will realize that under window systems such as X, any
|
|
1050 physical key (keycap) on the keyboard can be configured to generate any
|
|
1051 keysym. Also, the use of Emacs on TTYs will affect which keycap
|
|
1052 generates which keysym. From a pedantic point of view, here we are only
|
|
1053 concerned with the keysym event that Emacs receives.} will consume all
|
|
1054 preceding whitespace, including newlines and tabs. This can really cut
|
|
1055 down on the number of @kbd{Backspace}'s you have to type if, for example
|
|
1056 you made a mistake on the preceding line.
|
|
1057
|
|
1058 @findex c-electric-backspace
|
|
1059 @findex electric-backspace (c-)
|
|
1060 @vindex c-backspace-function
|
|
1061 @vindex backspace-function (c-)
|
0
|
1062
|
|
1063 @findex c-electric-delete
|
|
1064 @findex electric-delete (c-)
|
|
1065 @vindex c-delete-function
|
|
1066 @vindex delete-function (c-)
|
|
1067 @cindex literal
|
165
|
1068
|
|
1069 @findex backward-delete-char-untabify
|
|
1070
|
|
1071 By default, when you hit the @kbd{Backspace} key
|
|
1072 @ccmode{} runs the command @code{c-electric-backspace}, which deletes
|
|
1073 text in the backwards direction. When deleting a single character, or
|
|
1074 when @kbd{Backspace} is hit in a literal
|
|
1075 (see @ref{Auto-newline insertion}),
|
|
1076 or when hungry-delete mode is disabled, the function
|
|
1077 contained in the @code{c-backspace-function} variable is called with one
|
|
1078 argument (the number of characters to delete). This variable is set to
|
|
1079 @code{backward-delete-char-untabify} by default.
|
|
1080
|
|
1081 @vindex delete-key-deletes-forward
|
|
1082 @findex delete-char
|
|
1083
|
|
1084 Similarly, hitting the @kbd{DEL} key runs the command
|
|
1085 @code{c-electric-delete}. Some versions of Emacs@footnote{As of this
|
177
|
1086 writing, 20-Jun-1997, only XEmacs 20.3 supports this.} support separation
|
165
|
1087 of the @kbd{Backspace} and @kbd{DEL} keys, so that @kbd{DEL} will delete
|
|
1088 in the forward direction when @code{delete-key-deletes-forward} is
|
|
1089 non-@code{nil}. If your Emacs supports this, and
|
|
1090 @code{delete-key-deletes-forward} is non-@code{nil}, and hungry-delete
|
|
1091 mode is enabled, then @kbd{DEL} will consume all whitespace following
|
|
1092 point. When deleting a single character, or when @kbd{DEL} is hit in a
|
|
1093 literal, or when hungry-delete mode is disabled, the function contained
|
|
1094 in the @code{c-delete-function} variable is called with one argument
|
|
1095 (the number of characters to delete). This variable is set to
|
|
1096 @code{delete-char} by default.
|
|
1097
|
|
1098 However, if @code{delete-key-deletes-forward} is @code{nil}, or your
|
|
1099 Emacs does not support separation of @kbd{Backspace} and @kbd{DEL}, then
|
|
1100 @code{c-electric-delete} simply calls @code{c-electric-backspace}.
|
0
|
1101
|
|
1102
|
|
1103 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
2
|
1104 @node Commands, Customizing Indentation, Minor Modes, Top
|
0
|
1105 @comment node-name, next, previous,up
|
|
1106
|
2
|
1107 @chapter Commands
|
|
1108 @cindex Commands
|
|
1109 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
1110
|
|
1111 @menu
|
|
1112 * Indentation Commands::
|
|
1113 * Other Commands::
|
|
1114 @end menu
|
|
1115
|
|
1116 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
1117 @node Indentation Commands, Other Commands, , Commands
|
|
1118 @comment node-name, next, previous,up
|
|
1119
|
|
1120 @section Indentation Commands
|
0
|
1121 @cindex Indentation Commands
|
|
1122 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
1123
|
|
1124 Various commands are provided which allow you to conveniently re-indent
|
2
|
1125 C constructs. There are several things to
|
0
|
1126 note about these indentation commands. First, when you
|
2
|
1127 change your programming style, either interactively or through some
|
0
|
1128 other means, your file does @emph{not} automatically get re-indented.
|
|
1129 When you change style parameters, you will typically need to reformat
|
|
1130 the line, expression, or buffer to see the effects of your changes.
|
|
1131
|
|
1132 @cindex c-hanging- functions
|
|
1133 @findex c-hanging-braces-alist
|
|
1134 @findex hanging-braces-alist (c-)
|
|
1135 Second, changing some variables have no effect on existing code, even
|
2
|
1136 when you do re-indent. For example, the @code{c-hanging-*} variables
|
110
|
1137 and @code{c-cleanup-list} only affect new code as it is typed in
|
|
1138 on-the-fly, so changing @code{c-hanging-braces-alist} and re-indenting
|
|
1139 the buffer will not adjust placement of braces already in the file.
|
0
|
1140
|
|
1141 @vindex c-progress-interval
|
|
1142 @vindex progress-interval (c-)
|
|
1143 Third, re-indenting large portions of code is currently rather
|
|
1144 inefficient. Improvements have been made since previous releases of
|
110
|
1145 @ccmode{}, and much more radical improvements are planned, but for now
|
|
1146 you need to be aware of this @footnote{In particular, I have had people
|
|
1147 complain about the speed with which @code{lex(1)} output is re-indented.
|
|
1148 Lex, yacc, and other code generators usually output some pretty
|
|
1149 perversely formatted code. @emph{Don't} try to indent this stuff!}.
|
|
1150 Some provision has been made to at least inform you as to the progress
|
|
1151 of the re-indentation. The variable @code{c-progress-interval} controls
|
|
1152 how often a progress message is displayed. Set this variable to
|
177
|
1153 @code{nil} to inhibit progress messages.
|
0
|
1154
|
|
1155 Also, except as noted below, re-indentation is always driven by the
|
|
1156 same mechanisms that control on-the-fly indentation of code. @xref{New
|
|
1157 Indentation Engine} for details.
|
|
1158
|
|
1159 @findex c-indent-command
|
|
1160 @findex indent-command (c-)
|
|
1161 @vindex c-tab-always-indent
|
|
1162 @vindex tab-always-indent (c-)
|
|
1163 @kindex TAB
|
|
1164 @cindex literal
|
2
|
1165 @vindex indent-tabs-mode
|
|
1166 @vindex c-insert-tab-function
|
|
1167 @vindex insert-tab-function (c-)
|
|
1168 @findex tab-to-tab-stop
|
0
|
1169 To indent a single line of code, use @kbd{TAB}
|
|
1170 (@code{c-indent-command}). The behavior of this command is controlled
|
|
1171 by the variable @code{c-tab-always-indent}. When this variable is
|
|
1172 @code{t}, @kbd{TAB} always just indents the current line. When
|
110
|
1173 @code{nil}, the line is indented only if point is at the left margin, or
|
2
|
1174 on or before the first non-whitespace character on the line, otherwise
|
|
1175 @emph{something else happens}@footnote{Actually what happens is that the
|
110
|
1176 function stored in @code{c-insert-tab-function} is called.
|
2
|
1177 Normally this just inserts a real tab character, or the equivalent
|
|
1178 number of spaces, depending on the setting of the variable
|
|
1179 @code{indent-tabs-mode}. If you preferred, you could set
|
|
1180 @code{c-insert-tab-function} to @code{tab-to-tab-stop} for example.}.
|
|
1181 If the value of @code{c-tab-always-indent} is something other than
|
|
1182 @code{t} or @code{nil} (e.g. @code{'other}), then a real tab
|
|
1183 character@footnote{The caveat about @code{indent-tabs-mode} in the
|
110
|
1184 previous footnote also applies here.} is inserted only when point is
|
2
|
1185 inside a literal (see @ref{Auto-newline insertion}), otherwise the line
|
|
1186 is indented.
|
0
|
1187
|
|
1188 @kindex M-C-q
|
|
1189 @findex c-indent-exp
|
|
1190 @findex indent-exp (c-)
|
|
1191 To indent an entire balanced brace or parenthesis expression, use
|
110
|
1192 @kbd{M-C-q} (@code{c-indent-exp}). Note that point should be on
|
0
|
1193 the opening brace or parenthesis of the expression you want to indent.
|
|
1194
|
|
1195 @kindex C-c C-q
|
|
1196 @findex c-indent-defun
|
|
1197 @findex indent-defun (c-)
|
|
1198 Another very convenient keystroke is @kbd{C-c C-q}
|
|
1199 (@code{c-indent-defun}) when re-indents the entire top-level function or
|
177
|
1200 class definition that encompasses point. It leaves point at the
|
0
|
1201 same position within the buffer.
|
|
1202
|
|
1203 @kindex M-C-\
|
|
1204 @findex indent-region
|
|
1205 To indent any arbitrary region of code, use @kbd{M-C-\}
|
|
1206 (@code{indent-region}). This is a standard Emacs command, specially
|
110
|
1207 tailored for C code in a @ccmode{} buffer. Note that of course,
|
|
1208 point and mark must delineate the region you
|
0
|
1209 want to indent.
|
|
1210
|
|
1211 @kindex M-C-h
|
|
1212 @findex c-mark-function
|
|
1213 @findex mark-function (c-)
|
|
1214 While not strictly an indentation function, @kbd{M-C-h}
|
|
1215 (@code{c-mark-function}) is useful for marking the current top-level
|
|
1216 function or class definition as the current region.
|
|
1217
|
2
|
1218 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
1219 @node Other Commands, , Indentation Commands, Commands
|
|
1220 @comment node-name, next, previous,up
|
|
1221
|
|
1222 @section Other Commands
|
|
1223 @cindex Other Commands
|
|
1224 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
1225
|
110
|
1226 @ccmode{} contains other useful command for moving around in C
|
2
|
1227 code.
|
|
1228
|
|
1229 @table @code
|
|
1230 @item C-c C-u (c-up-conditional)
|
|
1231 @kindex C-c C-u
|
|
1232 @findex c-up-conditional
|
|
1233 @findex up-conditional (c-)
|
110
|
1234 Move point back to the containing preprocessor conditional, leaving the
|
|
1235 mark behind. A prefix argument acts as a repeat count. With a negative
|
|
1236 argument, move point forward to the end of the containing
|
2
|
1237 preprocessor conditional. When going backwards, @code{#elif} is treated
|
|
1238 like @code{#else} followed by @code{#if}. When going forwards,
|
|
1239 @code{#elif} is ignored.@refill
|
|
1240
|
|
1241 @item C-c C-p (c-backward-conditional)
|
|
1242 @kindex C-c C-p
|
|
1243 @findex c-backward-conditional
|
|
1244 @findex backward-conditional (c-)
|
110
|
1245 Move point back over a preprocessor conditional, leaving the mark
|
2
|
1246 behind. A prefix argument acts as a repeat count. With a negative
|
|
1247 argument, move forward.
|
|
1248
|
|
1249 @item C-c C-n (c-forward-conditional)
|
|
1250 @kindex C-c C-n
|
|
1251 @findex c-forward-conditional
|
|
1252 @findex forward-conditional (c-)
|
110
|
1253 Move point forward across a preprocessor conditional, leaving the mark
|
2
|
1254 behind. A prefix argument acts as a repeat count. With a negative
|
|
1255 argument, move backward.
|
|
1256
|
|
1257 @item M-a (c-beginning-of-statement)
|
|
1258 @kindex ESC a
|
|
1259 @findex c-beginning-of-statement
|
|
1260 @findex beginning-of-statement (c-)
|
110
|
1261 Move point to the beginning of the innermost C statement. If point is
|
2
|
1262 already at the beginning of a statement, it moves to the beginning of
|
|
1263 the preceding statement. With prefix argument @var{n}, move back
|
|
1264 @var{n} @minus{} 1 statements.
|
|
1265
|
110
|
1266 If point is within a string or comment, or at the end of a comment, this
|
|
1267 command moves by sentences instead of statements.
|
|
1268
|
|
1269 When called from a program, this function takes three optional
|
|
1270 arguments: the numeric prefix argument, a buffer position limit (don't
|
|
1271 move back before that place), and a flag to indicate whether movement
|
|
1272 should be by statements (if @code{t}) or sentence (if non-@code{nil}).
|
2
|
1273
|
|
1274 @item M-e (c-end-of-statement)
|
|
1275 @kindex ESC e
|
|
1276 @findex c-end-of-statement
|
|
1277 @findex end-of-statement (c-)
|
110
|
1278 Move point to the end of the innermost C statement. If point is at the
|
2
|
1279 end of a statement, move to the end of the next statement. With prefix
|
|
1280 argument @var{n}, move forward @var{n} @minus{} 1 statements.
|
|
1281
|
110
|
1282 If point is within a string or comment, or at the end of a comment, this
|
|
1283 command moves by sentences instead of statements.
|
|
1284
|
|
1285 When called from a program, this function takes three optional
|
|
1286 arguments: the numeric prefix argument, a buffer position limit (don't
|
|
1287 move back before that place), and a flag to indicate whether movement
|
|
1288 should be by statements (if @code{t}) or sentence (if non-@code{nil}).
|
2
|
1289
|
|
1290 @item M-x c-forward-into-nomenclature
|
|
1291 @findex c-forward-into-nomenclature
|
|
1292 @findex forward-into-nomenclature (c-)
|
|
1293 A popular programming style, especially for object-oriented languages
|
|
1294 such as C++ is to write symbols in a mixed case format, where the first
|
|
1295 letter of each word is capitalized, and not separated by underscores.
|
|
1296 E.g. @samp{SymbolsWithMixedCaseAndNoUnderlines}.
|
|
1297
|
177
|
1298 This command moves point forward to next capitalized word. With prefix
|
|
1299 argument @var{n}, move @var{n} times.
|
2
|
1300
|
|
1301 @item M-x c-backward-into-nomenclature
|
|
1302 @findex c-backward-into-nomenclature
|
|
1303 @findex backward-into-nomenclature (c-)
|
177
|
1304 Move point backward to beginning of the next capitalized
|
|
1305 word. With prefix argument @var{n}, move @var{n} times. If
|
2
|
1306 @var{n} is negative, move forward.
|
|
1307
|
|
1308 @kindex C-c :
|
|
1309 @findex c-scope-operator
|
|
1310 @findex scope-operator (c-)
|
|
1311 @item C-c : (c-scope-operator)
|
|
1312 In C++, it is also sometimes desirable to insert the double-colon scope
|
|
1313 operator without performing the electric behavior of colon insertion.
|
|
1314 @kbd{C-c :} does just this.
|
|
1315
|
110
|
1316 @item M-q (fill-paragraph)
|
|
1317 @kindex ESC q
|
|
1318 @findex fill-paragraph
|
|
1319 @vindex c-hanging-comment-starter-p
|
|
1320 @vindex c-hanging-comment-ender-p
|
|
1321 @vindex hanging-comment-starter-p (c-)
|
|
1322 @vindex hanging-comment-ender-p (c-)
|
177
|
1323
|
110
|
1324 The command is used to fill a block style (C) or line style (C++)
|
|
1325 comment, in much the same way that text in the various text modes can be
|
177
|
1326 filled@footnote{You should not use specialized filling packages such as
|
|
1327 @code{filladapt} with CC Mode. They don't work as well for filling as
|
|
1328 @code{c-fill-paragraph}}. You should never attempt to fill non-comment
|
|
1329 code sections; you'll end up with garbage! Two variables control how C
|
|
1330 style block comments are filled, specifically how the comment start and
|
|
1331 end delimiters are handled.
|
110
|
1332
|
|
1333 The variable @code{c-hanging-comment-starter-p} controls whether comment
|
|
1334 start delimiters which appear on a line by themselves, end up on a line
|
|
1335 by themselves after the fill. When the value is @code{nil}, the comment
|
|
1336 starter will remain on its own line@footnote{It will not be placed on a
|
|
1337 separate line if it is not already on a separate line.}. Otherwise,
|
|
1338 text on the next line will be put on the same line as the comment
|
|
1339 starter. This is called @dfn{hanging} because the following text hangs
|
177
|
1340 on the line with the comment starter@footnote{This variable is @code{t}
|
|
1341 by default, except in @code{java-mode}. Hanging comment starters mess
|
|
1342 up Javadoc style comments.}
|
110
|
1343
|
|
1344 The variable @code{c-hanging-comment-ender-p} controls the analogous
|
|
1345 behavior for the block comment end delimiter. When the value is
|
|
1346 @code{nil}, the comment ender will remain on its own line after the
|
|
1347 file@footnote{The same caveat as above holds true.}. Otherwise, the
|
|
1348 comment end delimiter will be placed at the end of the previous line.
|
|
1349
|
2
|
1350 @end table
|
0
|
1351
|
|
1352 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
2
|
1353 @node Customizing Indentation, Syntactic Symbols, Commands, Top
|
0
|
1354 @comment node-name, next, previous,up
|
|
1355
|
|
1356 @chapter Customizing Indentation
|
|
1357 @cindex Customizing Indentation
|
|
1358 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
1359
|
110
|
1360 @vindex c-offsets-alist
|
|
1361 @vindex offsets-alist (c-)
|
0
|
1362 @cindex c-set-offset
|
|
1363 @cindex set-offset (c-)
|
110
|
1364 The variable @code{c-offsets-alist} contains the mappings between
|
|
1365 syntactic symbols and the offsets to apply for those symbols. You
|
|
1366 should never modify this variable directly though. Use the function
|
|
1367 @code{c-set-offset} instead (see below for details).
|
|
1368
|
0
|
1369 The @code{c-offsets-alist} variable is where you customize all your
|
|
1370 indentations. You simply need to decide what additional offset you want
|
|
1371 to add for every syntactic symbol. You can use the command @kbd{C-c
|
|
1372 C-o} (@code{c-set-offset}) as the way to set offsets, both interactively
|
|
1373 and from your mode hook. Also, you can set up @emph{styles} of
|
177
|
1374 indentatio. Most likely, you'll
|
0
|
1375 find one of the pre-defined styles will suit your needs, but if not,
|
|
1376 this section will describe how to set up basic editing configurations.
|
|
1377 @xref{Styles} for an explanation of how to set up named styles.
|
|
1378
|
|
1379 @cindex c-basic-offset
|
|
1380 @cindex basic-offset (c-)
|
|
1381 As mentioned previously, the variable @code{c-offsets-alist} is an
|
2
|
1382 association list of syntactic symbols and the offsets to be applied for
|
110
|
1383 those symbols. In fact, these offset values can be any of an integer, a
|
|
1384 function or lambda expression, a variable name, or one of the following
|
|
1385 symbols: @code{+}, @code{-}, @code{++}, @code{--}, @code{*}, or
|
|
1386 @code{/}. These symbols describe offset in multiples of the value of
|
|
1387 the variable @code{c-basic-offset}. By defining a style's indentation
|
|
1388 in terms of this fundamental variable, you can change the amount of
|
|
1389 whitespace given to an indentation level while leaving the same
|
|
1390 relationship between levels. Here are the values that the special
|
0
|
1391 symbols correspond to:
|
|
1392
|
2
|
1393 @table @code
|
|
1394
|
|
1395 @item +
|
|
1396 @code{c-basic-offset} times 1
|
|
1397 @item -
|
|
1398 @code{c-basic-offset} times -1
|
|
1399 @item ++
|
|
1400 @code{c-basic-offset} times 2
|
|
1401 @item --
|
|
1402 @code{c-basic-offset} times -2
|
|
1403 @item *
|
|
1404 @code{c-basic-offset} times 0.5
|
|
1405 @item /
|
|
1406 @code{c-basic-offset} times -0.5
|
|
1407
|
|
1408 @end table
|
0
|
1409
|
110
|
1410 @vindex c-style-variables-are-local-p
|
|
1411 @vindex style-variables-are-local-p (c-)
|
0
|
1412 @noindent
|
|
1413 So, for example, because most of the default offsets are defined in
|
|
1414 terms of @code{+}, @code{-}, and @code{0}, if you like the general
|
|
1415 indentation style, but you use 4 spaces instead of 2 spaces per level,
|
|
1416 you can probably achieve your style just by changing
|
165
|
1417 @code{c-basic-offset} like so (in your @file{.emacs} file):
|
0
|
1418 @example
|
|
1419
|
165
|
1420 (setq c-basic-offset 4)
|
0
|
1421
|
|
1422 @end example
|
|
1423
|
|
1424 @noindent
|
|
1425 This would change
|
|
1426 @example
|
|
1427 @group
|
|
1428
|
|
1429 int add( int val, int incr, int doit )
|
|
1430 @{
|
2
|
1431 if( doit )
|
|
1432 @{
|
|
1433 return( val + incr );
|
|
1434 @}
|
|
1435 return( val );
|
|
1436 @}
|
|
1437
|
|
1438 @end group
|
|
1439 @end example
|
|
1440 @noindent
|
|
1441 to
|
|
1442 @example
|
|
1443 @group
|
|
1444
|
|
1445 int add( int val, int incr, int doit )
|
|
1446 @{
|
0
|
1447 if( doit )
|
|
1448 @{
|
|
1449 return( val + incr );
|
|
1450 @}
|
|
1451 return( val );
|
|
1452 @}
|
|
1453
|
|
1454 @end group
|
|
1455 @end example
|
|
1456
|
|
1457
|
|
1458 To change indentation styles more radically, you will want to change the
|
|
1459 value associated with the syntactic symbols in the
|
|
1460 @code{c-offsets-alist} variable. First, I'll show you how to do that
|
|
1461 interactively, then I'll describe how to make changes to your
|
|
1462 @file{.emacs} file so that your changes are more permanent.
|
|
1463
|
|
1464 @menu
|
|
1465 * Interactive Customization::
|
|
1466 * Permanent Customization::
|
|
1467 * Styles::
|
|
1468 * Advanced Customizations::
|
|
1469 @end menu
|
|
1470
|
|
1471 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
1472 @node Interactive Customization, Permanent Customization, , Customizing Indentation
|
|
1473 @comment node-name, next, previous,up
|
|
1474
|
|
1475 @section Interactive Customization
|
|
1476 @cindex Interactive Customization
|
|
1477 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
1478
|
|
1479 As an example of how to customize indentation, let's change the
|
2
|
1480 style of this example@footnote{In this an subsequent examples, the
|
|
1481 original code is formatted using the @samp{gnu} style unless otherwise
|
|
1482 indicated. @xref{Styles}.}:
|
0
|
1483 @example
|
|
1484 @group
|
|
1485
|
|
1486 1: int add( int val, int incr, int doit )
|
|
1487 2: @{
|
2
|
1488 3: if( doit )
|
|
1489 4: @{
|
|
1490 5: return( val + incr );
|
|
1491 6: @}
|
|
1492 7: return( val );
|
0
|
1493 8: @}
|
|
1494
|
|
1495 @end group
|
|
1496 @end example
|
|
1497 @noindent
|
|
1498 to:
|
|
1499 @example
|
|
1500 @group
|
|
1501
|
|
1502 1: int add( int val, int incr, int doit )
|
|
1503 2: @{
|
2
|
1504 3: if( doit )
|
|
1505 4: @{
|
|
1506 5: return( val + incr );
|
|
1507 6: @}
|
|
1508 7: return( val );
|
0
|
1509 8: @}
|
|
1510
|
|
1511 @end group
|
|
1512 @end example
|
|
1513
|
|
1514 In other words, we want to change the indentation of braces that open a
|
|
1515 block following a condition so that the braces line up under the
|
|
1516 conditional, instead of being indented. Notice that the construct we
|
|
1517 want to change starts on line 4. To change the indentation of a line,
|
2
|
1518 we need to see which syntactic components affect the offset calculations
|
0
|
1519 for that line. Hitting @kbd{C-c C-s} on line 4 yields:
|
|
1520 @example
|
|
1521
|
2
|
1522 ((substatement-open . 44))
|
0
|
1523
|
|
1524 @end example
|
|
1525
|
|
1526 @findex c-set-offset
|
|
1527 @findex set-offset (c-)
|
|
1528 @kindex C-c C-o
|
|
1529 @noindent
|
|
1530 so we know that to change the offset of the open brace, we need to
|
|
1531 change the indentation for the @code{substatement-open} syntactic
|
|
1532 symbol. To do this interactively, just hit @kbd{C-c C-o}
|
|
1533 (@code{c-set-offset}). This prompts you for the syntactic symbol to
|
|
1534 change, providing a reasonable default. In this case, the default is
|
|
1535 @code{substatement-open}, which is just the syntactic symbol we want to
|
|
1536 change!
|
|
1537
|
110
|
1538 After you hit return, @ccmode{} will then prompt you for the new
|
0
|
1539 offset value, with the old value as the default. The default in this
|
2
|
1540 case is @samp{+}, but we want no extra indentation so enter
|
0
|
1541 @samp{0} and @kbd{RET}. This will associate the offset 0 with the
|
|
1542 syntactic symbol @code{substatement-open} in the @code{c-offsets-alist}
|
|
1543 variable.
|
|
1544
|
|
1545 @findex c-indent-defun
|
|
1546 @findex indent-defun (c-)
|
|
1547 @kindex C-c C-q
|
|
1548 To check your changes quickly, just hit @kbd{C-c C-q}
|
|
1549 (@code{c-indent-defun}) to reindent the entire function. The example
|
|
1550 should now look like:
|
|
1551 @example
|
|
1552 @group
|
|
1553
|
|
1554 1: int add( int val, int incr, int doit )
|
|
1555 2: @{
|
2
|
1556 3: if( doit )
|
|
1557 4: @{
|
|
1558 5: return( val + incr );
|
|
1559 6: @}
|
|
1560 7: return( val );
|
0
|
1561 8: @}
|
|
1562
|
|
1563 @end group
|
|
1564 @end example
|
|
1565
|
|
1566 Notice how just changing the open brace offset on line 4 is all we
|
|
1567 needed to do. Since the other affected lines are indented relative to
|
|
1568 line 4, they are automatically indented the way you'd expect. For more
|
|
1569 complicated examples, this may not always work. The general approach to
|
|
1570 take is to always start adjusting offsets for lines higher up in the
|
|
1571 file, then re-indent and see if any following lines need further
|
|
1572 adjustments.
|
|
1573
|
|
1574 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
1575 @node Permanent Customization, Styles, Interactive Customization, Customizing Indentation
|
|
1576 @comment node-name, next, previous,up
|
|
1577
|
110
|
1578 @section Permanent Customization
|
|
1579 @cindex Permanent Customization
|
0
|
1580 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
1581
|
|
1582 @vindex c-mode-common-hook
|
|
1583 @vindex c-mode-hook
|
|
1584 @vindex c++-mode-hook
|
|
1585 @vindex objc-mode-hook
|
|
1586 @vindex java-mode-hook
|
177
|
1587 @vindex idl-mode-hook
|
|
1588 @vindex c-initialization-hook
|
|
1589 @vindex initialization-hook (c-)
|
0
|
1590 @cindex hooks
|
165
|
1591 To make your changes permanent, you need to add some lisp code to your
|
|
1592 @file{.emacs} file, but first you need to decide whether your styles
|
|
1593 should be global in every buffer, or local to each specific buffer.
|
|
1594
|
177
|
1595 If you edit primarily one style of code, you may want to make the
|
|
1596 @ccmode{} style variables have global values so that every buffer will
|
|
1597 share the style settings. This will allow you to set the @ccmode{}
|
|
1598 variables at the top level of your @file{.emacs} file, and is the
|
|
1599 way @ccmode{} works by default.
|
165
|
1600
|
|
1601 @vindex c-mode-common-hook
|
|
1602 @vindex mode-common-hook (c-)
|
|
1603 @vindex c-style-variables-are-local-p
|
|
1604 @vindex style-variables-are-local-p (c-)
|
177
|
1605 If you edit many different styles of code at
|
|
1606 the same time, you might want to make the @ccmode{} style variables
|
165
|
1607 have buffer local values. If you do this, then you will need to set any
|
|
1608 @ccmode{} style variables in a hook function (e.g. off of
|
|
1609 @code{c-mode-common-hook} instead of at the top level of your
|
|
1610 @file{.emacs} file. The recommended way to do this is to set the
|
|
1611 variable @code{c-style-variables-are-local-p} to @code{t}
|
|
1612 @strong{before} @ccmode{} is loaded into your Emacs session.
|
|
1613
|
|
1614 @ccmode{} provides several hooks that you can
|
2
|
1615 use to customize the mode according to your coding style. Each language
|
110
|
1616 mode has its own hook, adhering to standard Emacs major mode
|
177
|
1617 conventions. There is also one general hook and one package
|
|
1618 initialization hook:
|
2
|
1619
|
|
1620 @itemize @bullet
|
|
1621
|
|
1622 @item
|
|
1623 @code{c-mode-hook} --- for C buffers only
|
|
1624 @item
|
|
1625 @code{c++-mode-hook} --- for C++ buffers only
|
|
1626 @item
|
|
1627 @code{objc-mode-hook} --- for Objective-C buffers only
|
|
1628 @item
|
|
1629 @code{java-mode-hook} --- for Java buffers only
|
|
1630 @item
|
177
|
1631 @code{idl-mode-hook} --- for IDL buffers only
|
|
1632 @item
|
2
|
1633 @code{c-mode-common-hook} --- common across all languages
|
177
|
1634 @item
|
|
1635 @code{c-initialization-hook} --- hook run only once per Emacs session,
|
|
1636 when @ccmode{} is initialized.
|
2
|
1637
|
|
1638 @end itemize
|
|
1639
|
|
1640 The language hooks get run as the last thing when you enter that
|
177
|
1641 language mode. The @code{c-mode-common-hook} is run by all
|
2
|
1642 supported modes @emph{before} the language specific hook, and thus can
|
|
1643 contain customizations that are common across all languages. Most of
|
|
1644 the examples in this section will assume you are using the common
|
|
1645 hook@footnote{The interaction between @code{java-mode} and the hook
|
|
1646 variables is slightly different than for the other modes.
|
|
1647 @code{java-mode} sets the style (see @ref{Styles}) of the buffer to
|
|
1648 @samp{java} @emph{before} running the @code{c-mode-common-hook} or
|
177
|
1649 @code{java-mode-hook}. You need to be aware of this so that style
|
|
1650 settings in @code{c-mode-common-hook} don't clobber your Java style.}.
|
0
|
1651
|
|
1652 Here's a simplified example of what you can add to your @file{.emacs}
|
|
1653 file to make the changes described in the previous section
|
110
|
1654 (@ref{Interactive Customization}) more permanent. See the Emacs manuals
|
|
1655 for more information on customizing Emacs via hooks. @xref{Sample
|
|
1656 .emacs File} for a more complete sample @file{.emacs} file.
|
0
|
1657 @example
|
|
1658 @group
|
|
1659
|
|
1660 (defun my-c-mode-common-hook ()
|
177
|
1661 ;; my customizations for all of c-mode and related modes
|
0
|
1662 (c-set-offset 'substatement-open 0)
|
|
1663 ;; other customizations can go here
|
|
1664 )
|
|
1665 (add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
|
|
1666
|
|
1667 @end group
|
|
1668 @end example
|
|
1669
|
|
1670 For complex customizations, you will probably want to set up a
|
|
1671 @emph{style} that groups all your customizations under a single
|
|
1672 name.
|
|
1673
|
|
1674 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
1675 @node Styles, Advanced Customizations, Permanent Customization, Customizing Indentation
|
|
1676 @comment node-name, next, previous,up
|
|
1677
|
|
1678 @section Styles
|
|
1679 @cindex Styles
|
|
1680 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
1681
|
|
1682 Most people only need to edit code formatted in just a few well-defined
|
|
1683 and consistent styles. For example, their organization might impose a
|
|
1684 ``blessed'' style that all its programmers must conform to. Similarly,
|
|
1685 people who work on GNU software will have to use the GNU coding style on
|
177
|
1686 C code. Some shops are more lenient, allowing a variety of coding
|
0
|
1687 styles, and as programmers come and go, there could be a number of
|
110
|
1688 styles in use. For this reason, @ccmode{} makes it convenient for
|
0
|
1689 you to set up logical groupings of customizations called @dfn{styles},
|
|
1690 associate a single name for any particular style, and pretty easily
|
2
|
1691 start editing new or existing code using these styles. This section
|
0
|
1692 describes how to set up styles and how to edit your C code using styles.
|
|
1693
|
|
1694 @menu
|
|
1695 * Built-in Styles::
|
|
1696 * Adding Styles::
|
|
1697 * File Styles::
|
|
1698 @end menu
|
|
1699
|
|
1700
|
|
1701 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
1702 @node Built-in Styles, Adding Styles, , Styles
|
|
1703 @comment node-name, next, previous,up
|
|
1704
|
|
1705 @subsection Built-in Styles
|
|
1706 @cindex Built-in Styles
|
|
1707 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
1708
|
110
|
1709 If you're lucky, one of @ccmode{}'s built-in styles might be just
|
|
1710 what you're looking for. These include:
|
0
|
1711
|
|
1712 @itemize @bullet
|
|
1713 @item
|
|
1714 @cindex GNU style
|
2
|
1715 @code{gnu} --- coding style blessed by the Free Software Foundation
|
0
|
1716 for C code in GNU programs.
|
|
1717
|
|
1718 @item
|
|
1719 @cindex K&R style
|
2
|
1720 @code{k&r} --- The classic Kernighan and Ritchie style for C code.
|
0
|
1721
|
|
1722 @item
|
|
1723 @cindex BSD style
|
2
|
1724 @code{bsd} --- Also known as ``Allman style'' after Eric Allman.
|
|
1725
|
|
1726 @item
|
|
1727 @cindex Whitesmith style
|
|
1728 @code{whitesmith} --- Popularized by the examples that came with
|
|
1729 Whitesmiths C, an early commercial C compiler.
|
0
|
1730
|
|
1731 @item
|
|
1732 @cindex Stroustrup style
|
2
|
1733 @code{stroustrup} --- The classic Stroustrup style for C++ code.
|
0
|
1734
|
|
1735 @item
|
|
1736 @cindex Ellemtel style
|
2
|
1737 @code{ellemtel} --- Popular C++ coding standards as defined by
|
0
|
1738 ``Programming in C++, Rules and Recommendations'', Erik Nyquist and Mats
|
|
1739 Henricson, Ellemtel @footnote{This document is ftp'able from
|
|
1740 @code{euagate.eua.ericsson.se}}.
|
|
1741
|
|
1742 @item
|
110
|
1743 @cindex Linux style
|
|
1744 @code{linux} --- C coding standard for Linux development.
|
|
1745
|
|
1746 @item
|
|
1747 @cindex Python style
|
|
1748 @code{python} --- C coding standard for Python extension
|
|
1749 modules@footnote{Python is a high level scripting language with a C/C++
|
|
1750 foreign function interface. For more information, see
|
|
1751 @code{<http://www.python.org/>}.}.
|
|
1752
|
|
1753 @item
|
0
|
1754 @cindex Java style
|
|
1755 @cindex java-mode
|
2
|
1756 @code{java} --- The style for editing Java code. Note that this style is
|
0
|
1757 automatically installed when you enter @code{java-mode}.
|
|
1758
|
|
1759 @end itemize
|
|
1760
|
|
1761 @findex c-set-style
|
|
1762 @findex set-style (c-)
|
110
|
1763 @kindex C-c .
|
0
|
1764 If you'd like to experiment with these built-in styles you can simply
|
110
|
1765 type the following in a @ccmode{} buffer:
|
0
|
1766 @example
|
|
1767 @group
|
|
1768
|
110
|
1769 @kbd{C-c . @var{STYLE-NAME} RET}
|
0
|
1770
|
|
1771 @end group
|
|
1772 @end example
|
|
1773 @noindent
|
110
|
1774 @kbd{C-c .} runs the command @code{c-set-style}. Note that all style
|
|
1775 names are case insensitive, even the ones you define.
|
0
|
1776
|
|
1777 Setting a style in this way does @emph{not} automatically re-indent your
|
|
1778 file. For commands that you can use to view the effect of your changes,
|
2
|
1779 see @ref{Commands}.
|
0
|
1780
|
|
1781 Once you find a built-in style you like, you can make the change
|
110
|
1782 permanent by adding some lisp to your @file{.emacs} file. Let's say for
|
2
|
1783 example that you want to use the @samp{ellemtel} style in all your
|
0
|
1784 files. You would add this:
|
|
1785 @example
|
|
1786 @group
|
|
1787
|
|
1788 (defun my-c-mode-common-hook ()
|
2
|
1789 ;; use Ellemtel style for all C like languages
|
0
|
1790 (c-set-style "ellemtel")
|
|
1791 ;; other customizations can go here
|
|
1792 )
|
|
1793 (add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
|
|
1794
|
|
1795 @end group
|
|
1796 @end example
|
|
1797
|
110
|
1798 @cindex cc-mode style
|
2
|
1799 There is one other special style you can use, called @samp{cc-mode}
|
|
1800 style. This style is special because all other styles implicitly
|
|
1801 inherit from it; in other words, whenever you set a style,
|
|
1802 @samp{cc-mode} is applied before the one you selected. This means
|
|
1803 your style need only define the differences between it and
|
|
1804 @samp{cc-mode} style.
|
|
1805
|
110
|
1806 Note @emph{you should never change any of the default styles}.
|
|
1807 Instead, it's better to add a new style using @code{c-add-style}
|
|
1808 (@xref{Adding Styles}). This is especially true for @code{cc-mode} and
|
|
1809 @code{java} styles.
|
|
1810
|
|
1811 @vindex c-indentation-style
|
|
1812 @vindex indentation-style (c-)
|
2
|
1813 Note that for BOCM compatibility, @samp{gnu} is the default
|
|
1814 style, and any non-style based customizations you make (i.e. in
|
|
1815 @code{c-mode-common-hook} in your
|
|
1816 @file{.emacs} file) will be based on @samp{gnu} style unless you do
|
110
|
1817 a @code{c-set-style} as the first thing in your hook. The variable
|
|
1818 @code{c-indentation-style} always contains the buffer's current style name,
|
|
1819 as a string.
|
0
|
1820
|
|
1821
|
|
1822 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
1823 @node Adding Styles, File Styles, Built-in Styles, Styles
|
|
1824 @comment node-name, next, previous,up
|
|
1825
|
|
1826 @subsection Adding Styles
|
|
1827 @cindex Adding Styles
|
|
1828 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
1829
|
|
1830 @vindex c-style-alist
|
|
1831 @vindex style-alist (c-)
|
|
1832 @findex c-add-style
|
|
1833 @findex add-style (c-)
|
|
1834 If none of the built-in styles is appropriate, you'll probably want to
|
2
|
1835 add a new @dfn{style definition}. Styles are kept in the
|
|
1836 @code{c-style-alist} variable, but you should never modify this variable
|
110
|
1837 directly. Instead, @ccmode{} provides the function
|
2
|
1838 @code{c-add-style} that you can use to easily add new styles or change
|
|
1839 existing styles. This function takes two arguments, a @var{stylename}
|
|
1840 string, and an association list @var{description} of style
|
|
1841 customizations. If @var{stylename} is not already in
|
|
1842 @code{c-style-alist}, the new style is added, otherwise the style is
|
|
1843 changed to the new @var{description}.
|
|
1844 This function also takes an optional third argument, which if
|
|
1845 non-@code{nil}, automatically applies the new style to the current
|
|
1846 buffer.
|
0
|
1847
|
177
|
1848 @comment TBD: The next paragraph is bogus. I really need to better
|
|
1849 @comment document adding styles, including setting up inherited styles.
|
|
1850
|
0
|
1851 The sample @file{.emacs} file provides a concrete example of how a new
|
|
1852 style can be added and automatically set. @xref{Sample .emacs File}.
|
|
1853
|
|
1854 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
1855 @node File Styles, , Adding Styles, Styles
|
|
1856 @comment node-name, next, previous,up
|
|
1857
|
|
1858 @subsection File Styles
|
|
1859 @cindex File Styles
|
|
1860 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
1861
|
|
1862 @cindex local variables
|
177
|
1863
|
0
|
1864 The Emacs manual describes how you can customize certain variables on a
|
|
1865 per-file basis by including a @dfn{Local Variable} block at the end of
|
177
|
1866 the file. So far, you've only seen a functional interface to @ccmode{}
|
|
1867 customization, which is highly inconvenient for use in a Local Variable
|
|
1868 block. @ccmode{} provides two variables that make it easier for you to
|
|
1869 customize your style on a per-file basis@footnote{Note that file styles
|
|
1870 don't work with Emacs versions before XEmacs 19.12 and Emacs 19.29.
|
|
1871 File styles work via the standard Emacs hook variable
|
|
1872 @code{hack-local-variables-hook}.}.
|
0
|
1873
|
|
1874 @vindex c-file-style
|
|
1875 @vindex file-style (c-)
|
|
1876 @vindex c-file-offsets
|
|
1877 @vindex file-offsets (c-)
|
|
1878
|
2
|
1879 The variable @code{c-file-style} can be set to a style name string.
|
110
|
1880 When the file is visited, @ccmode{} will automatically set the
|
2
|
1881 file's style to this style using @code{c-set-style}.
|
0
|
1882
|
|
1883 @vindex c-offsets-alist
|
|
1884 @vindex offsets-alist (c-)
|
|
1885 @findex c-set-offset
|
|
1886 @findex set-offset (c-)
|
|
1887 Another variable, @code{c-file-offsets}, takes an association list
|
|
1888 similar to what is allowed in @code{c-offsets-alist}. When the file is
|
110
|
1889 visited, @ccmode{} will automatically institute these offets using
|
0
|
1890 @code{c-set-offset}.
|
|
1891
|
|
1892 Note that file style settings (i.e. @code{c-file-style}) are applied
|
177
|
1893 before file offset settings (i.e. @code{c-file-offsets}).
|
0
|
1894
|
|
1895
|
|
1896 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
1897 @node Advanced Customizations, , Styles, Customizing Indentation
|
|
1898 @comment node-name, next, previous,up
|
|
1899
|
|
1900 @section Advanced Customizations
|
|
1901 @cindex Advanced Customizations
|
|
1902 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
1903
|
|
1904 @vindex c-style-alist
|
|
1905 @vindex style-alist (c-)
|
|
1906 @vindex c-basic-offset
|
|
1907 @vindex basic-offset (c-)
|
110
|
1908 For most users, @ccmode{} will support their coding styles with
|
2
|
1909 very little need for more advanced customizations. Usually, one of the
|
|
1910 standard styles defined in @code{c-style-alist} will do the trick. At
|
|
1911 most, perhaps one of the syntactic symbol offsets will need to be
|
|
1912 tweaked slightly, or maybe @code{c-basic-offset} will need to be
|
|
1913 changed. However, some styles require a more flexible framework for
|
110
|
1914 customization, and one of the real strengths of @ccmode{} is that
|
2
|
1915 the syntactic analysis model provides just such a framework. This allows
|
110
|
1916 you to implement custom indentation calculations for situations not
|
2
|
1917 handled by the mode directly.
|
0
|
1918
|
110
|
1919 @vindex c-style-variables-are-local-p
|
|
1920 @vindex style-variables-are-local-p
|
|
1921 Note that the style controlling variables can either have global values,
|
|
1922 or can be buffer local (e.g. different in every buffer). If all the C
|
|
1923 files you edit tend to have the same style, you might want to keep the
|
|
1924 variables global. If you tend to edit files with many different styles,
|
|
1925 you will have to make the variables buffer local. The variable
|
|
1926 @code{c-style-variables-are-local-p} controls this.
|
|
1927
|
|
1928 When @code{c-style-variables-are-local-p} is non-nil, then the style
|
|
1929 variables will have a different settable value for each buffer,
|
165
|
1930 otherwise all buffers will share the same values. By default, its value
|
|
1931 is @code{nil} (i.e. global values). You @strong{must} set this variable
|
|
1932 before @ccmode{} is loaded into your Emacs session, and once the
|
|
1933 variables are made buffer local, they cannot be made global again
|
|
1934 (unless you restart Emacs of course!)
|
110
|
1935
|
0
|
1936 @menu
|
|
1937 * Custom Indentation Functions::
|
|
1938 * Custom Brace and Colon Hanging::
|
|
1939 * Customizing Semi-colons and Commas::
|
|
1940 * Other Special Indentations::
|
|
1941 @end menu
|
|
1942
|
|
1943 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
1944 @node Custom Indentation Functions, Custom Brace and Colon Hanging, , Advanced Customizations
|
|
1945 @comment node-name, next, previous,up
|
|
1946
|
|
1947 @subsection Custom Indentation Functions
|
|
1948 @cindex Custom Indentation Functions
|
|
1949 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
1950
|
|
1951 @cindex custom indentation functions
|
110
|
1952 The most flexible way to customize @ccmode{} is by writing @dfn{custom
|
|
1953 indentation functions} and associating them with specific syntactic
|
|
1954 symbols (see @ref{Syntactic Symbols}). @ccmode{} itself uses custom
|
|
1955 indentation functions to provide more sophisticated indentation, for
|
|
1956 example when lining up C++ stream operator blocks:
|
0
|
1957 @example
|
|
1958 @group
|
|
1959
|
|
1960 1: void main(int argc, char**)
|
|
1961 2: @{
|
|
1962 3: cout << "There were "
|
|
1963 4: << argc
|
|
1964 5: << "arguments passed to the program"
|
|
1965 6: << endl;
|
|
1966 7: @}
|
|
1967
|
|
1968 @end group
|
|
1969 @end example
|
|
1970
|
|
1971 In this example, lines 4 through 6 are assigned the @code{stream-op}
|
2
|
1972 syntactic symbol. Here, @code{stream-op} has an offset of @code{+}, and
|
|
1973 with a @code{c-basic-offset} of 2, you can see that lines 4 through 6
|
|
1974 are simply indented two spaces to the right of line 3. But perhaps we'd
|
177
|
1975 like @ccmode{} to be a little more intelligent so that it aligns
|
2
|
1976 all the @samp{<<} symbols in lines 3 through 6. To do this, we have
|
|
1977 to write a custom indentation function which finds the column of first
|
177
|
1978 stream operator on the first line of the statement. Here is sample
|
|
1979 lisp code implementing this:
|
0
|
1980 @example
|
|
1981 @group
|
|
1982
|
|
1983 (defun c-lineup-streamop (langelem)
|
|
1984 ;; lineup stream operators
|
|
1985 (save-excursion
|
|
1986 (let* ((relpos (cdr langelem))
|
|
1987 (curcol (progn (goto-char relpos)
|
|
1988 (current-column))))
|
|
1989 (re-search-forward "<<\\|>>" (c-point 'eol) 'move)
|
|
1990 (goto-char (match-beginning 0))
|
|
1991 (- (current-column) curcol))))
|
|
1992
|
|
1993 @end group
|
|
1994 @end example
|
|
1995 @noindent
|
|
1996 Custom indent functions take a single argument, which is a syntactic
|
|
1997 component cons cell (see @ref{Syntactic Analysis}). The
|
|
1998 function returns an integer offset value that will be added to the
|
2
|
1999 running total indentation for the line. Note that what actually gets
|
0
|
2000 returned is the difference between the column that the first stream
|
|
2001 operator is on, and the column of the buffer relative position passed in
|
110
|
2002 the function's argument. Remember that @ccmode{} automatically
|
0
|
2003 adds in the column of the component's relative buffer position and we
|
177
|
2004 don't the column offset added in twice.
|
0
|
2005
|
|
2006 @cindex stream-op syntactic symbol
|
|
2007 @findex c-lineup-streamop
|
|
2008 @findex lineup-streamop (c-)
|
|
2009 Now, to associate the function @code{c-lineup-streamop} with the
|
|
2010 @code{stream-op} syntactic symbol, we can add something like the
|
|
2011 following to our @code{c++-mode-hook}@footnote{It probably makes more
|
|
2012 sense to add this to @code{c++-mode-hook} than @code{c-mode-common-hook}
|
|
2013 since stream operators are only relevent for C++.}:
|
|
2014 @example
|
|
2015
|
|
2016 (c-set-offset 'stream-op 'c-lineup-streamop)
|
|
2017
|
|
2018 @end example
|
|
2019
|
|
2020 @kindex C-c C-q
|
|
2021 Now the function looks like this after re-indenting (using @kbd{C-c
|
|
2022 C-q}):
|
|
2023 @example
|
|
2024 @group
|
|
2025
|
|
2026 1: void main(int argc, char**)
|
|
2027 2: @{
|
|
2028 3: cout << "There were "
|
|
2029 4: << argc
|
|
2030 5: << "arguments passed to the program"
|
|
2031 6: << endl;
|
|
2032 7: @}
|
|
2033
|
|
2034 @end group
|
|
2035 @end example
|
|
2036
|
|
2037 @vindex c-offsets-alist
|
|
2038 @vindex offsets-alist (c-)
|
|
2039 Custom indentation functions can be as simple or as complex as you like,
|
|
2040 and any syntactic symbol that appears in @code{c-offsets-alist} can have
|
110
|
2041 a custom indentation function associated with it. @ccmode{} comes
|
2
|
2042 with several standard custom indentation functions, not all of which are
|
|
2043 used by the default styles.
|
|
2044
|
|
2045 @itemize @bullet
|
|
2046 @item
|
|
2047 @findex c-lineup-arglist
|
|
2048 @findex lineup-arglist (c-)
|
|
2049 @code{c-lineup-arglist} --- lines up function argument lines under the
|
|
2050 argument on the previous line.
|
|
2051
|
|
2052 @item
|
|
2053 @findex c-lineup-arglist-intro-after-paren
|
|
2054 @findex lineup-arglist-intro-after-paren (c-)
|
|
2055 @code{c-lineup-arglist-intro-after-paren} --- similar to
|
|
2056 @code{c-lineup-arglist}, but works for argument lists that begin with an
|
|
2057 open parenthesis followed by a newline.
|
|
2058
|
|
2059 @item
|
|
2060 @findex c-lineup-arglist-close-under-paren
|
|
2061 @findex lineup-arglist-close-under-paren (c-)
|
|
2062 @code{c-lineup-arglist-close-under-paren} --- set your
|
|
2063 @code{arglist-close} syntactic symbol to this line-up function so that
|
|
2064 parentheses that close argument lists will line up under the parenthesis
|
|
2065 that opened the argument list.
|
|
2066
|
|
2067 @item
|
|
2068 @findex c-lineup-streamop
|
|
2069 @findex lineup-streamop (c-)
|
|
2070 @code{c-lineup-streamop} --- lines up C++ stream operators
|
|
2071 (e.g. @samp{<<} and @samp{>>}).
|
|
2072
|
|
2073 @item
|
|
2074 @findex c-lineup-multi-inher
|
|
2075 @findex lineup-multi-inher (c-)
|
|
2076 @code{c-lineup-multi-inher} --- lines up multiple inheritance lines.
|
|
2077
|
|
2078 @item
|
|
2079 @findex c-lineup-C-comments
|
|
2080 @findex lineup-C-comments (c-)
|
|
2081 @code{c-lineup-C-comments} --- lines up C block comment continuation
|
|
2082 lines.
|
|
2083
|
|
2084 @item
|
|
2085 @findex c-lineup-comment
|
|
2086 @findex lineup-comment (c-)
|
|
2087 @vindex c-comment-only-line-offset
|
|
2088 @vindex comment-only-line-offset (c-)
|
177
|
2089 @code{c-lineup-comment} --- lines up comment only lines according to
|
|
2090 the variable @code{c-comment-only-line-offset}.
|
2
|
2091
|
|
2092 @item
|
|
2093 @findex c-lineup-runin-statements
|
|
2094 @findex lineup-runin-statements (c-)
|
|
2095 @code{c-lineup-runin-statements} --- lines up @code{statement}s for coding
|
|
2096 standards which place the first statement in a block on the same line as
|
177
|
2097 the block opening brace@footnote{Run-in style doesn't really work too
|
|
2098 well. You might need to write your own custom indentation functions to
|
|
2099 better support this style.}.
|
2
|
2100
|
|
2101 @item
|
|
2102 @findex c-lineup-math
|
|
2103 @findex lineup-math (c-)
|
|
2104 @code{c-lineup-math} --- lines up math @code{statement-cont} lines under
|
|
2105 the previous line after the equals sign.
|
|
2106
|
|
2107 @item
|
|
2108 @findex c-lineup-ObjC-method-call
|
|
2109 @findex lineup-ObjC-method-call (c-)
|
|
2110 @code{c-lineup-ObjC-method-call} --- for Objective-C code, lines up
|
|
2111 selector arguments just after the message receiver.
|
|
2112
|
|
2113 @item
|
|
2114 @findex c-lineup-ObjC-method-args
|
|
2115 @findex lineup-ObjC-method-args (c-)
|
|
2116 @code{c-lineup-ObjC-method-args} --- for Objective-C code, lines up the
|
|
2117 colons that separate arguments by aligning colons vertically.
|
|
2118
|
|
2119 @item
|
|
2120 @findex c-lineup-ObjC-method-args-2
|
|
2121 @findex lineup-ObjC-method-args-2 (c-)
|
|
2122 @code{c-lineup-ObjC-method-args-2} --- similar to
|
|
2123 @code{c-lineup-ObjC-method-args} but lines up the colon on the current
|
|
2124 line with the colon on the previous line.
|
|
2125
|
|
2126 @end itemize
|
0
|
2127
|
|
2128 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
2129 @node Custom Brace and Colon Hanging, Customizing Semi-colons and Commas, Custom Indentation Functions, Advanced Customizations
|
|
2130 @comment node-name, next, previous,up
|
|
2131
|
|
2132 @subsection Custom Brace and Colon Hanging
|
|
2133 @cindex Custom Brace and Colon Hanging
|
|
2134 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
2135
|
|
2136 @vindex c-hanging-braces-alist
|
|
2137 @vindex hanging-braces-alist (c-)
|
|
2138 Syntactic symbols aren't the only place where you can customize
|
110
|
2139 @ccmode{} with the lisp equivalent of callback functions. Brace
|
2
|
2140 ``hanginess'' can also be determined by custom functions associated with
|
0
|
2141 syntactic symbols on the @code{c-hanging-braces-alist} variable.
|
|
2142 Remember that @var{ACTION}'s are typically a list containing some
|
|
2143 combination of the symbols @code{before} and @code{after} (see
|
|
2144 @ref{Hanging Braces}). However, an @var{ACTION} can also be a function
|
177
|
2145 which gets called when a brace matching that syntactic symbol is
|
|
2146 entered.
|
0
|
2147
|
|
2148 @cindex customizing brace hanging
|
|
2149 These @var{ACTION} functions are called with two arguments: the
|
|
2150 syntactic symbol for the brace, and the buffer position at which the
|
|
2151 brace was inserted. The @var{ACTION} function is expected to return a
|
|
2152 list containing some combination of @code{before} and @code{after}. The
|
|
2153 function can also return @code{nil}. This return value has the normal
|
2
|
2154 brace hanging semantics.
|
0
|
2155
|
110
|
2156 As an example, @ccmode{} itself uses this feature to dynamically
|
2
|
2157 determine the hanginess of braces which close ``do-while''
|
0
|
2158 constructs:
|
|
2159 @example
|
|
2160 @group
|
|
2161
|
|
2162 void do_list( int count, char** atleast_one_string )
|
|
2163 @{
|
|
2164 int i=0;
|
|
2165 do @{
|
2
|
2166 handle_string( atleast_one_string[i] );
|
0
|
2167 i++;
|
|
2168 @} while( i < count );
|
|
2169 @}
|
|
2170
|
|
2171 @end group
|
|
2172 @end example
|
|
2173
|
|
2174 @findex c-snug-do-while
|
|
2175 @findex snug-do-while (c-)
|
110
|
2176 @ccmode{} assigns the @code{block-close} syntactic symbol to the
|
0
|
2177 brace that closes the @code{do} construct, and normally we'd like the
|
|
2178 line that follows a @code{block-close} brace to begin on a separate
|
2
|
2179 line. However, with ``do-while'' constructs, we want the
|
0
|
2180 @code{while} clause to follow the closing brace. To do this, we
|
|
2181 associate the @code{block-close} symbol with the @var{ACTION} function
|
|
2182 @code{c-snug-do-while}:
|
|
2183 @example
|
|
2184
|
|
2185 (defun c-snug-do-while (syntax pos)
|
|
2186 "Dynamically calculate brace hanginess for do-while statements.
|
|
2187 Using this function, `while' clauses that end a `do-while' block will
|
|
2188 remain on the same line as the brace that closes that block.
|
|
2189
|
|
2190 See `c-hanging-braces-alist' for how to utilize this function as an
|
|
2191 ACTION associated with `block-close' syntax."
|
|
2192 (save-excursion
|
|
2193 (let (langelem)
|
|
2194 (if (and (eq syntax 'block-close)
|
|
2195 (setq langelem (assq 'block-close c-syntactic-context))
|
|
2196 (progn (goto-char (cdr langelem))
|
|
2197 (if (= (following-char) ?@{)
|
|
2198 (forward-sexp -1))
|
|
2199 (looking-at "\\<do\\>[^_]")))
|
|
2200 '(before)
|
|
2201 '(before after)))))
|
|
2202
|
|
2203 @end example
|
|
2204
|
2
|
2205 This function simply looks to see if the brace closes a ``do-while''
|
|
2206 clause and if so, returns the list @samp{(before)} indicating
|
0
|
2207 that a newline should be inserted before the brace, but not after it.
|
2
|
2208 In all other cases, it returns the list @samp{(before after)} so
|
0
|
2209 that the brace appears on a line by itself.
|
|
2210
|
|
2211 @vindex c-syntactic-context
|
|
2212 @vindex syntactic-context (c-)
|
|
2213 During the call to the brace hanging @var{ACTION} function, the variable
|
|
2214 @code{c-syntactic-context} is bound to the full syntactic analysis list.
|
|
2215
|
|
2216 @cindex customizing colon hanging
|
|
2217 @vindex c-hanging-colon-alist
|
|
2218 @vindex hanging-colon-alist (c-)
|
|
2219 Note that for symmetry, colon hanginess should be customizable by
|
|
2220 allowing function symbols as @var{ACTION}s on the
|
|
2221 @code{c-hanging-colon-alist} variable. Since no use has actually been
|
110
|
2222 found for this feature, it isn't currently implemented!
|
0
|
2223
|
|
2224 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
2225 @node Customizing Semi-colons and Commas, Other Special Indentations, Custom Brace and Colon Hanging, Advanced Customizations
|
|
2226 @comment node-name, next, previous,up
|
|
2227
|
|
2228 @subsection Customizing Semi-colons and Commas
|
|
2229 @cindex Customizing Semi-colons and Commas
|
|
2230 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
2231
|
|
2232 @cindex customizing semi-colons and commas
|
|
2233 @vindex c-hanging-semi&comma-criteria
|
|
2234 @vindex hanging-semi&comma-criteria (c-)
|
|
2235 You can also customize the insertion of newlines after semi-colons and
|
|
2236 commas, when the auto-newline minor mode is enabled (see @ref{Minor
|
|
2237 Modes}). This is controlled by the variable
|
|
2238 @code{c-hanging-semi&comma-criteria}, which contains a list of functions
|
|
2239 that are called in the order they appear. Each function is called with
|
|
2240 zero arguments, and is expected to return one of the following values:
|
|
2241
|
|
2242 @itemize @bullet
|
|
2243 @item
|
2
|
2244 non-@code{nil} --- A newline is inserted, and no more functions from the
|
0
|
2245 list are called.
|
|
2246
|
|
2247 @item
|
2
|
2248 @code{stop} --- No more functions from the list are called, but no
|
0
|
2249 newline is inserted.
|
|
2250
|
|
2251 @item
|
2
|
2252 @code{nil} --- No determination is made, and the next function in the
|
0
|
2253 list is called.
|
|
2254
|
|
2255 @end itemize
|
|
2256
|
|
2257 If every function in the list is called without a determination being
|
|
2258 made, then no newline is added. The default value for this variable is a
|
|
2259 list containing a single function which inserts newlines only after
|
|
2260 semi-colons which do not appear inside parenthesis lists (i.e. those
|
|
2261 that separate @code{for}-clause statements).
|
|
2262
|
2
|
2263 Here's an example of a criteria function that will prevent newlines from
|
|
2264 being inserted after semicolons when there is a non-blank following
|
110
|
2265 line. Otherwise, it makes no determination. To use, add this to the
|
|
2266 front of the @code{c-hanging-semi&comma-criteria} list.
|
2
|
2267
|
|
2268 @example
|
|
2269 @group
|
|
2270
|
|
2271 (defun my-semicolon-criteria ()
|
|
2272 (save-excursion
|
177
|
2273 (if (and (eq last-command-char ?\;)
|
2
|
2274 (zerop (forward-line 1))
|
|
2275 (not (looking-at "^[ \t]*$")))
|
|
2276 'stop
|
|
2277 nil)))
|
|
2278
|
|
2279 @end group
|
|
2280 @end example
|
|
2281
|
|
2282
|
0
|
2283 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
2284 @node Other Special Indentations, , Customizing Semi-colons and Commas, Advanced Customizations
|
|
2285 @comment node-name, next, previous,up
|
|
2286
|
|
2287 @subsection Other Special Indentations
|
|
2288 @cindex Customizing Semi-colons and Commas
|
|
2289 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
2290
|
2
|
2291 @vindex c-label-minimum-indentation
|
|
2292 @vindex label-minimum-indentation (c-)
|
|
2293 In @samp{gnu} style (see @ref{Built-in Styles}), a minimum indentation
|
110
|
2294 is imposed on lines inside top-level constructs. This minimum
|
|
2295 indentation is controlled by the variable
|
2
|
2296 @code{c-label-minimum-indentation}. The default value for this variable
|
|
2297 is 1.
|
|
2298
|
0
|
2299 @vindex c-special-indent-hook
|
|
2300 @vindex special-indent-hook (c-)
|
110
|
2301 One other customization variable is available in @ccmode{}:
|
0
|
2302 @code{c-special-indent-hook}. This is a standard hook variable that is
|
110
|
2303 called after every line is indented by @ccmode{}. You can use it
|
0
|
2304 to do any special indentation or line adjustments your style dictates,
|
|
2305 such as adding extra indentation to constructors or destructor
|
|
2306 declarations in a class definition, etc. Note however, that you should
|
110
|
2307 not change point or mark inside your @code{c-special-indent-hook}
|
0
|
2308 functions (i.e. you'll probably want to wrap your function in a
|
|
2309 @code{save-excursion}).
|
|
2310
|
2
|
2311 Setting @code{c-special-indent-hook} in your style definition is handled
|
|
2312 slightly differently than other variables. In your style definition,
|
|
2313 you should set the value for
|
|
2314 @code{c-special-indent-hook} to a function or list of functions, which
|
|
2315 will be appended to @code{c-special-indent-hook} using @code{add-hook}.
|
|
2316 That way, the current setting for the buffer local value of
|
|
2317 @code{c-special-indent-hook} won't be overridden.
|
|
2318
|
175
|
2319 @kindex M-;
|
|
2320 @findex indent-for-comment
|
|
2321 @vindex c-indent-comments-syntactically-p
|
|
2322 @vindex indent-comments-syntactically-p (c-)
|
|
2323 @vindex comment-column
|
|
2324
|
|
2325 Normally, the standard Emacs command @kbd{M-;}
|
|
2326 (@code{indent-for-comment}) will indent comment-only lines to
|
|
2327 @code{comment-column}. Some users however, prefer that @kbd{M-;} act
|
|
2328 just like @kbd{TAB} for purposes of indenting comment-only lines;
|
|
2329 i.e. they want the comments to always indent as they would for normal
|
|
2330 code, regardless of whether @kbd{TAB} or @kbd{M-;} were used. This
|
|
2331 behavior is controlled by the variable
|
|
2332 @code{c-indent-comments-syntactically-p}. When @code{nil} (the
|
|
2333 default), @kbd{M-;} indents comment-only lines to @code{comment-column},
|
|
2334 otherwise, they are indented just as they would be if @kbd{TAB} were
|
|
2335 typed.
|
0
|
2336
|
|
2337 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
2338 @node Syntactic Symbols, Performance Issues, Customizing Indentation, Top
|
|
2339 @comment node-name, next, previous,up
|
|
2340
|
|
2341 @chapter Syntactic Symbols
|
|
2342 @cindex Syntactic Symbols
|
|
2343 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
2344
|
|
2345 @vindex c-offsets-alist
|
|
2346 @vindex offsets-alist (c-)
|
2
|
2347
|
|
2348 Here is a complete list of the recognized syntactic symbols as described
|
|
2349 in the @code{c-offsets-alist} variable, along with a brief description.
|
|
2350 More detailed descriptions follow below.
|
|
2351
|
|
2352 @itemize @bullet
|
|
2353 @item
|
|
2354 @code{string} --- inside multi-line string
|
|
2355 @item
|
|
2356 @code{c} --- inside a multi-line C style block comment
|
|
2357 @item
|
|
2358 @code{defun-open} --- brace that opens a function definition
|
|
2359 @item
|
|
2360 @code{defun-close} --- brace that closes a function definition
|
|
2361 @item
|
|
2362 @code{defun-block-intro} --- the first line in a top-level defun
|
|
2363 @item
|
|
2364 @code{class-open} --- brace that opens a class definition
|
|
2365 @item
|
|
2366 @code{class-close} --- brace that closes a class definition
|
|
2367 @item
|
|
2368 @code{inline-open} --- brace that opens an in-class inline method
|
|
2369 @item
|
|
2370 @code{inline-close} --- brace that closes an in-class inline method
|
|
2371 @item
|
165
|
2372 @code{func-decl-cont} --- the region between a function definition's
|
|
2373 argument list and the function opening brace (excluding K&R argument
|
|
2374 declarations). In C, you cannot put anything but whitespace and comments
|
|
2375 between them; in C++ and Java, @code{throws} declarations and other
|
|
2376 things can appear in this context.
|
2
|
2377 @item
|
|
2378 @code{knr-argdecl-intro} --- first line of a K&R C argument declaration
|
|
2379 @item
|
|
2380 @code{knr-argdecl} --- subsequent lines in a K&R C argument declaration
|
|
2381 @item
|
110
|
2382 @code{topmost-intro} --- the first line in a topmost definition
|
2
|
2383 @item
|
|
2384 @code{topmost-intro-cont} --- topmost definition continuation lines
|
|
2385 @item
|
|
2386 @code{member-init-intro} --- first line in a member initialization list
|
|
2387 @item
|
|
2388 @code{member-init-cont} --- subsequent member initialization list lines
|
|
2389 @item
|
|
2390 @code{inher-intro} --- first line of a multiple inheritance list
|
|
2391 @item
|
|
2392 @code{inher-cont} --- subsequent multiple inheritance lines
|
|
2393 @item
|
|
2394 @code{block-open} --- statement block open brace
|
|
2395 @item
|
|
2396 @code{block-close} --- statement block close brace
|
|
2397 @item
|
|
2398 @code{brace-list-open} --- open brace of an enum or static array list
|
|
2399 @item
|
|
2400 @code{brace-list-close} --- close brace of an enum or static array list
|
|
2401 @item
|
|
2402 @code{brace-list-intro} --- first line in an enum or static array list
|
|
2403 @item
|
|
2404 @code{brace-list-entry} --- subsequent lines in an enum or static array list
|
|
2405 @item
|
110
|
2406 @code{statement} --- a C statement
|
2
|
2407 @item
|
110
|
2408 @code{statement-cont} --- a continuation of a C statement
|
2
|
2409 @item
|
|
2410 @code{statement-block-intro} --- the first line in a new statement block
|
|
2411 @item
|
|
2412 @code{statement-case-intro} --- the first line in a case `block'
|
|
2413 @item
|
|
2414 @code{statement-case-open} --- the first line in a case block starting
|
|
2415 with brace
|
|
2416 @item
|
110
|
2417 @code{substatement} --- the first line after a conditional
|
2
|
2418 @item
|
|
2419 @code{substatement-open} --- the brace that opens a substatement block
|
|
2420 @item
|
|
2421 @code{case-label} --- a case or default label
|
|
2422 @item
|
110
|
2423 @code{access-label} --- C++ access control label
|
2
|
2424 @item
|
110
|
2425 @code{label} --- any non-special C label
|
2
|
2426 @item
|
110
|
2427 @code{do-while-closure} --- the `while' that ends a
|
|
2428 @code{do}-@code{while} construct
|
2
|
2429 @item
|
110
|
2430 @code{else-clause} --- the `else' of an @code{if}-@code{else} construct
|
2
|
2431 @item
|
|
2432 @code{comment-intro} --- a line containing only a comment introduction
|
|
2433 @item
|
|
2434 @code{arglist-intro} --- the first line in an argument list
|
|
2435 @item
|
|
2436 @code{arglist-cont} --- subsequent argument list lines when no arguments
|
|
2437 follow on the same line as the the arglist opening paren
|
|
2438 @item
|
|
2439 @code{arglist-cont-nonempty} --- subsequent argument list lines when at
|
|
2440 least one argument follows on the same line as the arglist opening paren
|
|
2441 @item
|
|
2442 @code{arglist-close} --- the solo close paren of an argument list
|
|
2443 @item
|
110
|
2444 @code{stream-op} --- lines continuing a stream operator
|
2
|
2445 @item
|
110
|
2446 @code{inclass} --- the line is nested inside a class definition
|
2
|
2447 @item
|
|
2448 @code{cpp-macro} --- the start of a cpp macro
|
|
2449 @item
|
|
2450 @code{friend} --- a C++ friend declaration
|
|
2451 @item
|
|
2452 @code{objc-method-intro} --- the first line of an Objective-C method definition
|
|
2453 @item
|
|
2454 @code{objc-method-args-cont} --- lines continuing an Objective-C method
|
|
2455 definition
|
|
2456 @item
|
|
2457 @code{objc-method-call-cont} --- lines continuing an Objective-C method call
|
|
2458 @item
|
|
2459 @code{extern-lang-open} --- brace that opens an external language block
|
|
2460 @item
|
|
2461 @code{extern-lang-close} --- brace that closes an external language block
|
|
2462 @item
|
110
|
2463 @code{inextern-lang} --- analogous to `inclass' syntactic symbol, but
|
|
2464 for @code{extern} blocks.
|
2
|
2465 @end itemize
|
0
|
2466
|
|
2467 @cindex -open syntactic symbols
|
|
2468 @cindex -close syntactic symbols
|
|
2469 Most syntactic symbol names follow a general naming convention. When a
|
|
2470 line begins with an open or close brace, the syntactic symbol will
|
|
2471 contain the suffix @code{-open} or @code{-close} respectively.
|
|
2472
|
|
2473 @cindex -intro syntactic symbols
|
|
2474 @cindex -cont syntactic symbols
|
|
2475 @cindex -block-intro syntactic symbols
|
|
2476 Usually, a distinction is made between the first line that introduces a
|
|
2477 construct and lines that continue a construct, and the syntactic symbols
|
|
2478 that represent these lines will contain the suffix @code{-intro} or
|
|
2479 @code{-cont} respectively. As a sub-classification of this scheme, a
|
|
2480 line which is the first of a particular brace block construct will
|
|
2481 contain the suffix @code{-block-intro}.
|
|
2482
|
|
2483 @kindex C-c C-s
|
|
2484 Let's look at some examples to understand how this works. Remember that
|
|
2485 you can check the syntax of any line by using @kbd{C-c C-s}.
|
|
2486 @example
|
|
2487 @group
|
|
2488
|
|
2489 1: void
|
|
2490 2: swap( int& a, int& b )
|
|
2491 3: @{
|
|
2492 4: int tmp = a;
|
|
2493 5: a = b;
|
|
2494 6: b = tmp;
|
|
2495 7: int ignored =
|
|
2496 8: a + b;
|
|
2497 9: @}
|
|
2498
|
|
2499 @end group
|
|
2500 @end example
|
|
2501
|
2
|
2502 @cindex topmost-intro syntactic symbol
|
|
2503 @cindex topmost-intro-cont syntactic symbol
|
|
2504 @cindex defun-open syntactic symbol
|
|
2505 @cindex defun-close syntactic symbol
|
|
2506 @cindex defun-block-intro syntactic symbol
|
0
|
2507 Line 1 shows a @code{topmost-intro} since it is the first line that
|
|
2508 introduces a top-level construct. Line 2 is a continuation of the
|
|
2509 top-level construct introduction so it has the syntax
|
|
2510 @code{topmost-intro-cont}. Line 3 shows a @code{defun-open} since it is
|
|
2511 the brace that opens a top-level function definition. Line 9 is a
|
|
2512 @code{defun-close} since it contains the brace that closes the top-level
|
|
2513 function definition. Line 4 is a @code{defun-block-intro}, i.e. it is
|
177
|
2514 the first line of a brace-block, enclosed in a
|
0
|
2515 top-level function definition.
|
|
2516
|
2
|
2517 @cindex statement syntactic symbol
|
|
2518 @cindex statement-cont syntactic symbol
|
0
|
2519 Lines 5, 6, and 7 are all given @code{statement} syntax since there
|
|
2520 isn't much special about them. Note however that line 8 is given
|
|
2521 @code{statement-cont} syntax since it continues the statement begun
|
|
2522 on the previous line.
|
|
2523
|
|
2524 Here's another example, which illustrates some C++ class syntactic
|
|
2525 symbols:
|
|
2526 @example
|
|
2527 @group
|
|
2528
|
|
2529 1: class Bass
|
|
2530 2: : public Guitar,
|
|
2531 3: public Amplifiable
|
|
2532 4: @{
|
|
2533 5: public:
|
|
2534 6: Bass()
|
|
2535 7: : eString( new BassString( 0.105 )),
|
|
2536 8: aString( new BassString( 0.085 )),
|
|
2537 9: dString( new BassString( 0.065 )),
|
|
2538 10: gString( new BassString( 0.045 ))
|
|
2539 11: @{
|
|
2540 12: eString.tune( 'E' );
|
|
2541 13: aString.tune( 'A' );
|
|
2542 14: dString.tune( 'D' );
|
|
2543 15: gString.tune( 'G' );
|
|
2544 16: @}
|
2
|
2545 17: friend class Luthier;
|
|
2546 18: @}
|
0
|
2547
|
|
2548 @end group
|
|
2549 @end example
|
|
2550
|
2
|
2551 @cindex class-open syntactic symbol
|
|
2552 @cindex class-close syntactic symbol
|
0
|
2553 As in the previous example, line 1 has the @code{topmost-intro} syntax.
|
|
2554 Here however, the brace that opens a C++ class definition on line 4 is
|
2
|
2555 assigned the @code{class-open} syntax. Note that in C++, classes,
|
|
2556 structs, and unions are essentially equivalent syntactically (and are
|
|
2557 very similar semantically), so replacing the @code{class} keyword in the
|
|
2558 example above with @code{struct} or @code{union} would still result in a
|
|
2559 syntax of @code{class-open} for line 4 @footnote{This is the case even
|
|
2560 for C and Objective-C. For consistency, structs in all supported
|
|
2561 languages are syntactically equivalent to classes. Note however that
|
|
2562 the keyword @code{class} is meaningless in C and Objective-C.}.
|
|
2563 Similarly, line 18 is assigned @code{class-close} syntax.
|
|
2564
|
|
2565 @cindex inher-intro syntactic symbol
|
|
2566 @cindex inher-cont syntactic symbol
|
0
|
2567 Line 2 introduces the inheritance list for the class so it is assigned
|
|
2568 the @code{inher-intro} syntax, and line 3, which continues the
|
|
2569 inheritance list is given @code{inher-cont} syntax.
|
|
2570
|
2
|
2571 @cindex access-label syntactic symbol
|
|
2572 @cindex inclass syntactic symbol
|
|
2573 Hitting @kbd{C-c C-s} on line 5 shows the following analysis:
|
|
2574
|
|
2575 @example
|
|
2576 @group
|
|
2577
|
|
2578 @code{((inclass . 1) (access-label . 67))}
|
|
2579
|
|
2580 @end group
|
|
2581 @end example
|
|
2582
|
|
2583 @noindent
|
|
2584 The primary syntactic symbol for this line is @code{access-label} as
|
|
2585 this a label keyword that specifies access protection in C++. However,
|
|
2586 because this line is also a top-level construct inside a class
|
|
2587 definition, the analysis actually shows two syntactic symbols. The
|
|
2588 other syntactic symbol assigned to this line is @code{inclass}.
|
|
2589 Similarly, line 6 is given both @code{inclass} and @code{topmost-intro}
|
|
2590 syntax:
|
|
2591
|
|
2592 @example
|
|
2593 @group
|
|
2594
|
|
2595 @code{((inclass . 58) (topmost-intro . 60))}
|
|
2596
|
|
2597 @end group
|
|
2598 @end example
|
|
2599
|
|
2600 @cindex member-init-intro syntactic symbol
|
|
2601 @cindex member-init-cont syntactic symbol
|
0
|
2602 Line 7 introduces a C++ member initialization list and as such is given
|
|
2603 @code{member-init-intro} syntax. Note that in this case it is
|
|
2604 @emph{not} assigned @code{inclass} since this is not considered a
|
|
2605 top-level construct. Lines 8 through 10 are all assigned
|
|
2606 @code{member-init-cont} since they continue the member initialization
|
|
2607 list started on line 7.
|
|
2608
|
|
2609 @cindex in-class inline methods
|
2
|
2610 @cindex inline-open syntactic symbol
|
|
2611 @cindex inline-close syntactic symbol
|
177
|
2612 Line 11's analysis is a bit more complicated:
|
2
|
2613
|
|
2614 @example
|
|
2615 @group
|
|
2616
|
|
2617 @code{((inclass . 1) (inline-open))}
|
|
2618
|
|
2619 @end group
|
|
2620 @end example
|
|
2621
|
|
2622 This line is assigned a syntax of both @code{inline-open} and
|
|
2623 @code{inclass} because it opens an @dfn{in-class} C++ inline method
|
|
2624 definition. This is distinct from, but related to, the C++ notion of an
|
|
2625 inline function in that its definition occurs inside an enclosing class
|
|
2626 definition, which in C++ implies that the function should be inlined.
|
177
|
2627 If though, the definition of the @code{Bass} constructor appeared
|
|
2628 outside the class definition, the construct would be given the
|
2
|
2629 @code{defun-open} syntax, even if the keyword @code{inline} appeared
|
|
2630 before the method name, as in:
|
0
|
2631 @example
|
|
2632 @group
|
|
2633
|
|
2634 class Bass
|
|
2635 : public Guitar,
|
|
2636 public Amplifiable
|
|
2637 @{
|
|
2638 public:
|
|
2639 Bass();
|
|
2640 @}
|
|
2641
|
|
2642 inline
|
|
2643 Bass::Bass()
|
|
2644 : eString( new BassString( 0.105 )),
|
|
2645 aString( new BassString( 0.085 )),
|
|
2646 dString( new BassString( 0.065 )),
|
|
2647 gString( new BassString( 0.045 ))
|
|
2648 @{
|
|
2649 eString.tune( 'E' );
|
|
2650 aString.tune( 'A' );
|
|
2651 dString.tune( 'D' );
|
|
2652 gString.tune( 'G' );
|
|
2653 @}
|
|
2654
|
|
2655 @end group
|
|
2656 @end example
|
|
2657
|
2
|
2658 @cindex friend syntactic symbol
|
|
2659 Returning to the previous example, line 16 is given @code{inline-close}
|
|
2660 syntax, while line 12 is given @code{defun-block-open} syntax, and lines
|
|
2661 13 through 15 are all given @code{statement} syntax. Line 17 is
|
165
|
2662 interesting in that its syntactic analysis list contains three
|
2
|
2663 elements:
|
|
2664
|
|
2665 @example
|
|
2666
|
|
2667 @code{((friend) (inclass . 58) (topmost-intro . 380))}
|
|
2668
|
|
2669 @end example
|
|
2670
|
|
2671 The @code{friend} syntactic symbol is a modifier that typically does not
|
|
2672 have a relative buffer position.
|
0
|
2673
|
|
2674 Here is another (totally contrived) example which illustrates how syntax
|
|
2675 is assigned to various conditional constructs:
|
|
2676 @example
|
|
2677 @group
|
|
2678
|
|
2679 1: void spam( int index )
|
|
2680 2: @{
|
|
2681 3: for( int i=0; i<index; i++ )
|
|
2682 4: @{
|
|
2683 5: if( i == 10 )
|
|
2684 6: @{
|
|
2685 7: do_something_special();
|
|
2686 8: @}
|
|
2687 9: else
|
|
2688 10: do_something( i );
|
|
2689 11: @}
|
|
2690 12: do @{
|
|
2691 13: another_thing( i-- );
|
|
2692 14: @}
|
|
2693 15: while( i > 0 );
|
|
2694 16: @}
|
|
2695
|
|
2696
|
|
2697 @end group
|
|
2698 @end example
|
|
2699
|
|
2700 @noindent
|
|
2701 Only the lines that illustrate new syntactic symbols will be discussed.
|
|
2702
|
2
|
2703 @cindex substatement-open syntactic symbol
|
|
2704 @cindex substatement-block-intro syntactic symbol
|
|
2705 @cindex block-close syntactic symbol
|
0
|
2706 Line 4 has a brace which opens a conditional's substatement block. It
|
|
2707 is thus assigned @code{substatement-open} syntax, and since line 5 is
|
|
2708 the first line in the substatement block, it is assigned
|
|
2709 @code{substatement-block-intro} syntax. Lines 6 and 7 are assigned
|
|
2710 similar syntax. Line 8 contains the brace that closes the inner
|
2
|
2711 substatement block. It is given the syntax @code{block-close},
|
0
|
2712 as are lines 11 and 14.
|
|
2713
|
2
|
2714 @cindex else-clause syntactic symbol
|
|
2715 @cindex substatement syntactic symbol
|
|
2716 Line 9 is a little different --- since it contains the keyword
|
|
2717 @code{else} matching the @code{if} statement introduced on line 5, it is
|
0
|
2718 given the @code{else-clause} syntax. Note also that line 10 is slightly
|
|
2719 different too. Because @code{else} is considered a conditional
|
|
2720 introducing keyword @footnote{The list of conditional keywords are (in
|
2
|
2721 C, C++, Objective-C, and Java): @code{for}, @code{if}, @code{do},
|
|
2722 @code{else}, @code{while}, and @code{switch}. C++ and Java have two
|
|
2723 additional conditional keywords: @code{try} and @code{catch}. Java also
|
|
2724 has the @code{finally} and @code{synchronized} keywords.}, and because
|
|
2725 the following substatement is not a brace block, line 10 is assigned the
|
0
|
2726 @code{substatement} syntax.
|
|
2727
|
2
|
2728 @cindex do-while-closure syntactic symbol
|
0
|
2729 One other difference is seen on line 15. The @code{while} construct
|
|
2730 that closes a @code{do} conditional is given the special syntax
|
|
2731 @code{do-while-closure} if it appears on a line by itself. Note that if
|
|
2732 the @code{while} appeared on the same line as the preceding close brace,
|
|
2733 that line would have been assigned @code{block-close} syntax instead.
|
|
2734
|
|
2735 Switch statements have their own set of syntactic symbols. Here's an
|
|
2736 example:
|
|
2737 @example
|
|
2738 @group
|
|
2739
|
|
2740 1: void spam( enum Ingredient i )
|
|
2741 2: @{
|
|
2742 3: switch( i ) @{
|
|
2743 4: case Ham:
|
|
2744 5: be_a_pig();
|
|
2745 6: break;
|
|
2746 7: case Salt:
|
|
2747 8: drink_some_water();
|
|
2748 9: break;
|
|
2749 10: default:
|
|
2750 11: @{
|
|
2751 12: what_is_it();
|
|
2752 13: break;
|
|
2753 14: @}
|
|
2754 15: @}
|
|
2755 14: @}
|
|
2756
|
|
2757 @end group
|
|
2758 @end example
|
|
2759
|
2
|
2760 @cindex case-label syntactic symbol
|
|
2761 @cindex statement-case-intro syntactic symbol
|
|
2762 @cindex statement-case-open syntactic symbol
|
0
|
2763 Here, lines 4, 7, and 10 are all assigned @code{case-label} syntax,
|
|
2764 while lines 5 and 8 are assigned @code{statement-case-intro}. Line 11
|
|
2765 is treated slightly differently since it contains a brace that opens a
|
2
|
2766 block --- it is given @code{statement-case-open} syntax.
|
0
|
2767
|
|
2768 @cindex brace lists
|
|
2769 There are a set of syntactic symbols that are used to recognize
|
|
2770 constructs inside of brace lists. A brace list is defined as an
|
|
2771 @code{enum} or aggregate initializer list, such as might statically
|
|
2772 initialize an array of structs. For example:
|
|
2773 @example
|
|
2774 @group
|
|
2775
|
|
2776 1: static char* ingredients[] =
|
|
2777 2: @{
|
|
2778 3: "Ham",
|
|
2779 4: "Salt",
|
|
2780 5: NULL
|
|
2781 6: @}
|
|
2782
|
|
2783 @end group
|
|
2784 @end example
|
|
2785
|
2
|
2786 @cindex brace-list-open syntactic symbol
|
|
2787 @cindex brace-list-intro syntactic symbol
|
|
2788 @cindex brace-list-close syntactic symbol
|
|
2789 @cindex brace-list-entry syntactic symbol
|
0
|
2790 Following convention, line 2 in this example is assigned
|
|
2791 @code{brace-list-open} syntax, and line 3 is assigned
|
|
2792 @code{brace-list-intro} syntax. Likewise, line 6 is assigned
|
|
2793 @code{brace-list-close} syntax. Lines 4 and 5 however, are assigned
|
|
2794 @code{brace-list-entry} syntax, as would all subsequent lines in this
|
|
2795 initializer list.
|
|
2796
|
2
|
2797 External language definition blocks also have their own syntactic
|
|
2798 symbols. In this example:
|
|
2799 @example
|
|
2800 @group
|
|
2801
|
|
2802 1: extern "C"
|
|
2803 2: @{
|
|
2804 3: int thing_one( int );
|
|
2805 4: int thing_two( double );
|
|
2806 5: @}
|
|
2807
|
|
2808 @end group
|
|
2809 @end example
|
|
2810
|
|
2811 @cindex extern-lang-open syntactic symbol
|
|
2812 @cindex extern-lang-close syntactic symbol
|
|
2813 @cindex inextern-lang syntactic symbol
|
|
2814 @cindex inclass syntactic symbol
|
|
2815 @noindent
|
|
2816 line 2 is given the @code{extern-lang-open} syntax while line 5 is given
|
|
2817 the @code{extern-lang-close} syntax. The analysis for line 3 yields:
|
|
2818 @code{((inextern-lang) (topmost-intro . 14))}, where
|
|
2819 @code{inextern-lang} is a modifier similar in purpose to @code{inclass}.
|
|
2820
|
0
|
2821 A number of syntactic symbols are associated with parenthesis lists,
|
|
2822 a.k.a argument lists, as found in function declarations and function
|
|
2823 calls. This example illustrates these:
|
|
2824 @example
|
|
2825 @group
|
|
2826
|
|
2827 1: void a_function( int line1,
|
|
2828 2: int line2 );
|
|
2829 3:
|
|
2830 4: void a_longer_function(
|
|
2831 5: int line1,
|
|
2832 6: int line2
|
|
2833 7: );
|
|
2834 8:
|
|
2835 9: void call_them( int line1, int line2 )
|
|
2836 10: @{
|
|
2837 11: a_function(
|
|
2838 12: line1,
|
|
2839 13: line2
|
|
2840 14: );
|
|
2841 15:
|
|
2842 16: a_longer_function( line1,
|
|
2843 17: line2 );
|
|
2844 18: @}
|
|
2845
|
|
2846 @end group
|
|
2847 @end example
|
|
2848
|
2
|
2849 @cindex arglist-intro syntactic symbol
|
|
2850 @cindex arglist-close syntactic symbol
|
0
|
2851 Lines 5 and 12 are assigned @code{arglist-intro} syntax since they are
|
|
2852 the first line following the open parenthesis, and lines 7 and 14 are
|
|
2853 assigned @code{arglist-close} syntax since they contain the parenthesis
|
|
2854 that closes the argument list.
|
|
2855
|
2
|
2856 @cindex arglist-cont-nonempty syntactic symbol
|
|
2857 @cindex arglist-cont syntactic symbol
|
|
2858 Lines that continue argument lists can be assigned one of two syntactic
|
|
2859 symbols. For example, Lines 2 and 17
|
|
2860 are assigned @code{arglist-cont-nonempty} syntax. What this means
|
0
|
2861 is that they continue an argument list, but that the line containing the
|
2
|
2862 parenthesis that opens the list is @emph{not empty} following the open
|
0
|
2863 parenthesis. Contrast this against lines 6 and 13 which are assigned
|
|
2864 @code{arglist-cont} syntax. This is because the parenthesis that opens
|
110
|
2865 their argument lists is the last character on that line.
|
0
|
2866
|
|
2867 Note that there is no @code{arglist-open} syntax. This is because any
|
|
2868 parenthesis that opens an argument list, appearing on a separate line,
|
|
2869 is assigned the @code{statement-cont} syntax instead.
|
|
2870
|
|
2871 A few miscellaneous syntactic symbols that haven't been previously
|
110
|
2872 covered are illustrated by this C++ example:
|
0
|
2873 @example
|
|
2874 @group
|
|
2875
|
|
2876 1: void Bass::play( int volume )
|
|
2877 2: const
|
|
2878 3: @{
|
|
2879 4: /* this line starts a multi-line
|
|
2880 5: * comment. This line should get `c' syntax */
|
|
2881 6:
|
110
|
2882 7: char* a_multiline_string = "This line starts a multi-line \
|
0
|
2883 8: string. This line should get `string' syntax.";
|
|
2884 9:
|
|
2885 10: note:
|
|
2886 11: @{
|
|
2887 12: #ifdef LOCK
|
|
2888 13: Lock acquire();
|
|
2889 14: #endif // LOCK
|
|
2890 15: slap_pop();
|
|
2891 16: cout << "I played "
|
|
2892 17: << "a note\n";
|
|
2893 18: @}
|
|
2894 19: @}
|
|
2895
|
|
2896 @end group
|
|
2897 @end example
|
|
2898
|
|
2899 @cindex modifier syntactic symbol
|
|
2900 The lines to note in this example include:
|
|
2901
|
|
2902 @itemize @bullet
|
|
2903
|
110
|
2904 @cindex func-decl-cont syntactic symbol
|
0
|
2905 @item
|
110
|
2906 line 2, assigned the @code{func-decl-cont} syntax;
|
2
|
2907
|
|
2908 @cindex comment-intro syntactic symbol
|
0
|
2909 @item
|
2
|
2910 line 4, assigned both @code{defun-block-intro} @emph{and}
|
110
|
2911 @code{comment-intro} syntax;
|
2
|
2912
|
|
2913 @cindex c syntactic symbol
|
0
|
2914 @item
|
2
|
2915 line 5, assigned @code{c} syntax;
|
0
|
2916
|
|
2917 @item
|
|
2918 @cindex syntactic whitespace
|
|
2919 line 6 which, even though it contains nothing but whitespace, is
|
|
2920 assigned @code{defun-block-intro}. Note that the appearance of the
|
|
2921 comment on lines 4 and 5 do not cause line 6 to be assigned
|
|
2922 @code{statement} syntax because comments are considered to be
|
2
|
2923 @dfn{syntactic whitespace}, which are ignored when analyzing
|
0
|
2924 code;
|
|
2925
|
2
|
2926 @cindex string syntactic symbol
|
0
|
2927 @item
|
2
|
2928 line 8, assigned @code{string} syntax;
|
|
2929
|
|
2930 @cindex label syntactic symbol
|
0
|
2931 @item
|
2
|
2932 line 10, assigned @code{label} syntax;
|
|
2933
|
|
2934 @cindex block-open syntactic symbol
|
0
|
2935 @item
|
2
|
2936 line 11, assigned @code{block-open} syntax;
|
|
2937
|
|
2938 @cindex cpp-macro syntactic symbol
|
0
|
2939 @item
|
2
|
2940 lines 12 and 14, assigned @code{cpp-macro} syntax;
|
|
2941
|
|
2942 @cindex stream-op syntactic symbol
|
0
|
2943 @item
|
110
|
2944 line 17, assigned @code{stream-op} syntax.
|
0
|
2945
|
|
2946 @end itemize
|
|
2947
|
|
2948 In Objective-C buffers, there are three additional syntactic symbols
|
|
2949 assigned to various message calling constructs. Here's an example
|
|
2950 illustrating these:
|
|
2951 @example
|
|
2952 @group
|
|
2953
|
|
2954 1: - (void)setDelegate:anObject
|
|
2955 2: withStuff:stuff
|
|
2956 3: @{
|
|
2957 4: [delegate masterWillRebind:self
|
|
2958 5: toDelegate:anObject
|
|
2959 6: withExtraStuff:stuff];
|
|
2960 7: @}
|
|
2961
|
|
2962 @end group
|
|
2963 @end example
|
|
2964
|
2
|
2965 @cindex objc-method-intro syntactic symbol
|
|
2966 @cindex objc-method-args-cont syntactic symbol
|
|
2967 @cindex objc-method-call-cont syntactic symbol
|
0
|
2968 Here, line 1 is assigned @code{objc-method-intro} syntax, and line 2 is
|
|
2969 assigned @code{objc-method-args-cont} syntax. Lines 5 and 6 are both
|
|
2970 assigned @code{objc-method-call-cont} syntax.
|
|
2971
|
2
|
2972 @cindex knr-argdecl-intro
|
|
2973 @cindex knr-argdecl
|
|
2974 Two other syntactic symbols can appear in old style, non-prototyped C
|
|
2975 code @footnote{a.k.a. K&R C, or Kernighan & Ritchie C}:
|
|
2976 @example
|
|
2977 @group
|
|
2978
|
|
2979 1: int add_three_integers(a, b, c)
|
|
2980 2: int a;
|
|
2981 3: int b;
|
|
2982 4: int c;
|
|
2983 5: @{
|
|
2984 6: return a + b + c;
|
|
2985 7: @}
|
|
2986
|
|
2987 @end group
|
|
2988 @end example
|
|
2989
|
|
2990 Here, line 2 is the first line in an argument declaration list and so is
|
|
2991 given the @code{knr-argdecl-intro} syntactic symbol. Subsequent lines
|
|
2992 (i.e. lines 3 and 4 in this example), are given @code{knr-argdecl}
|
|
2993 syntax.
|
0
|
2994
|
|
2995 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
2996 @node Performance Issues, Frequently Asked Questions, Syntactic Symbols, Top
|
|
2997 @comment node-name, next, previous,up
|
|
2998
|
|
2999 @chapter Performance Issues
|
|
3000 @cindex Performance Issues
|
|
3001 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
3002
|
165
|
3003 C and its derivative languages are highly complex creatures. Often,
|
110
|
3004 ambiguous code situations arise that require @ccmode{} to scan
|
2
|
3005 large portions of the buffer to determine syntactic context. Such
|
|
3006 pathological code@footnote{such as the output of @code{lex(1)}!}
|
110
|
3007 can cause @ccmode{} to perform fairly badly.
|
0
|
3008 This section identifies some of the coding styles to watch out for, and
|
|
3009 suggests some workarounds that you can use to improve performance.
|
|
3010
|
110
|
3011 Because @ccmode{} has to scan the buffer backwards from the current
|
0
|
3012 insertion point, and because C's syntax is fairly difficult to parse in
|
110
|
3013 the backwards direction, @ccmode{} often tries to find the nearest
|
0
|
3014 position higher up in the buffer from which to begin a forward scan.
|
|
3015 The farther this position is from the current insertion point, the
|
110
|
3016 slower the mode gets. Some coding styles can even force @ccmode{}
|
177
|
3017 to scan from the beginning of the buffer for every line of code!
|
0
|
3018
|
|
3019 @findex beginning-of-defun
|
|
3020 @findex defun-prompt-regexp
|
|
3021 One of the simplest things you can do to reduce scan time, is make sure
|
|
3022 any brace that opens a top-level block construct always appears in the
|
|
3023 leftmost column. This is actually an Emacs constraint, as embodied in
|
110
|
3024 the @code{beginning-of-defun} function which @ccmode{} uses
|
0
|
3025 heavily. If you insist on hanging top-level open braces on the right
|
|
3026 side of the line, then you should set the variable
|
|
3027 @code{defun-prompt-regexp} to something reasonable @footnote{Note that
|
|
3028 this variable is only defined in Emacs 19.}, however that ``something
|
110
|
3029 reasonable'' is difficult to define, so @ccmode{} doesn't do it
|
0
|
3030 for you.
|
|
3031
|
110
|
3032 @vindex c-Java-defun-prompt-regexp
|
|
3033 @vindex Java-defun-prompt-regexp (c-)
|
|
3034 A special note about @code{defun-prompt-regexp} in Java mode: while much
|
|
3035 of the early sample Java code seems to encourage a style where the brace
|
|
3036 that opens a class is hung on the right side of the line, this is not a
|
|
3037 good style to pursue in Emacs. @ccmode{} comes with a variable
|
|
3038 @code{c-Java-defun-prompt-regexp} which tries to define a regular
|
|
3039 expression usable for this style, but there are problems with it. In
|
|
3040 some cases it can cause @code{beginning-of-defun} to hang@footnote{This
|
|
3041 has been observed in Emacs 19.34 and XEmacs 19.15.}. For this reason,
|
|
3042 it is not used by default, but if you feel adventurous, you can set
|
|
3043 @code{defun-prompt-regexp} to it in your mode hook. In any event,
|
|
3044 setting and rely on @code{defun-prompt-regexp} will definitely slow
|
|
3045 things down!
|
|
3046
|
|
3047 You will probably notice pathological behavior from @ccmode{} when
|
0
|
3048 working in files containing large amounts of cpp macros. This is
|
177
|
3049 because Emacs cannot be made to quickly skip backwards over these lines.
|
0
|
3050
|
|
3051 @vindex c-recognize-knr-p
|
|
3052 @vindex recognize-knr-p (c-)
|
110
|
3053 Previous versions of @ccmode{} had potential performance problems
|
|
3054 when recognizing K&R style function argument declarations. This was
|
2
|
3055 because there are ambiguities in the C syntax when K&R style argument
|
110
|
3056 lists are used@footnote{It is hard to distinguish them from top-level
|
|
3057 declarations.}. @ccmode{} has adopted BOCM's convention for
|
2
|
3058 limiting the search: it assumes that argdecls are indented at least one
|
|
3059 space, and that the function headers are not indented at all. With
|
110
|
3060 current versions of @ccmode{}, user customization of
|
|
3061 @code{c-recognize-knr-p} is deprecated. Just don't put argdecls in
|
|
3062 column zero!
|
2
|
3063
|
|
3064 @cindex @file{cc-lobotomy.el} file
|
0
|
3065 @vindex cc-lobotomy-pith-list
|
110
|
3066 You might want to investigate the speed-ups contained in the
|
165
|
3067 file @file{cc-lobotomy.el}, which comes as part of the @ccmode{}
|
|
3068 distribution, but is completely unsupported.
|
110
|
3069 As mentioned previous, @ccmode{} always trades accuracy for speed,
|
|
3070 however it is recognized that sometimes you need speed and can sacrifice
|
|
3071 some accuracy in indentation. The file @file{cc-lobotomy.el} contains
|
|
3072 hacks that will ``dumb down'' @ccmode{} in some specific ways, making
|
|
3073 that trade-off of speed for accuracy. I won't go into details of its
|
|
3074 use here; you should read the comments at the top of the file, and look
|
|
3075 at the variable @code{cc-lobotomy-pith-list} for details.
|
0
|
3076
|
|
3077
|
|
3078 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
110
|
3079 @node Frequently Asked Questions, Getting the latest CC Mode release, Performance Issues, Top
|
0
|
3080 @comment node-name, next, previous,up
|
|
3081
|
|
3082 @chapter Frequently Asked Questions
|
|
3083 @cindex Frequently Asked Questions
|
2
|
3084 @comment FAQ
|
0
|
3085 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
3086
|
|
3087 @kindex C-x h
|
|
3088 @kindex ESC C-\
|
|
3089 @kindex ESC C-x
|
|
3090 @kindex C-c C-q
|
|
3091 @kindex ESC C-q
|
|
3092 @kindex ESC C-u
|
|
3093 @kindex RET
|
165
|
3094 @kindex C-j
|
0
|
3095 @findex newline-and-indent
|
|
3096 @quotation
|
|
3097
|
|
3098 @strong{Q.} @emph{How do I re-indent the whole file?}
|
|
3099
|
|
3100 @strong{A.} Visit the file and hit @kbd{C-x h} to mark the whole
|
|
3101 buffer. Then hit @kbd{@key{ESC} C-\}.
|
2
|
3102 @sp 1
|
0
|
3103
|
|
3104 @strong{Q.} @emph{How do I re-indent the entire function?
|
|
3105 @kbd{@key{ESC} C-x} doesn't work.}
|
|
3106
|
|
3107 @strong{A.} @kbd{@key{ESC} C-x} is reserved for future Emacs use.
|
|
3108 To re-indent the entire function hit @kbd{C-c C-q}.
|
2
|
3109 @sp 1
|
0
|
3110
|
|
3111 @strong{Q.} @emph{How do I re-indent the current block?}
|
|
3112
|
|
3113 @strong{A.} First move to the brace which opens the block with
|
|
3114 @kbd{@key{ESC} C-u}, then re-indent that expression with
|
|
3115 @kbd{@key{ESC} C-q}.
|
2
|
3116 @sp 1
|
0
|
3117
|
|
3118 @strong{Q.} @emph{Why doesn't the @key{RET} key indent the line to
|
|
3119 where the new text should go after inserting the newline?}
|
|
3120
|
|
3121 @strong{A.} Emacs' convention is that @key{RET} just adds a newline,
|
165
|
3122 and that @key{C-j} adds a newline and indents it. You can make
|
0
|
3123 @key{RET} do this too by adding this to your
|
|
3124 @code{c-mode-common-hook} (see the sample @file{.emacs} file
|
|
3125 @ref{Sample .emacs File}):
|
|
3126 @example
|
|
3127
|
|
3128 (define-key c-mode-map "\C-m" 'newline-and-indent)
|
|
3129
|
|
3130 @end example
|
|
3131
|
110
|
3132 This is a very common question. If you want this to be the default
|
|
3133 behavior, don't lobby me, lobby RMS! @code{:-)}
|
2
|
3134 @sp 1
|
0
|
3135
|
|
3136 @strong{Q.} @emph{I put @code{(c-set-offset 'substatement-open 0)}
|
|
3137 in my @file{.emacs} file but I get an error saying that
|
|
3138 @code{c-set-offset}'s function definition is void.}
|
|
3139
|
110
|
3140 @strong{A.} This means that @ccmode{} wasn't loaded into your
|
0
|
3141 Emacs session by the time the @code{c-set-offset} call was reached,
|
110
|
3142 mostly likely because @ccmode{} is being autoloaded. Instead
|
0
|
3143 of putting the @code{c-set-offset} line in your top-level
|
|
3144 @file{.emacs} file, put it in your @code{c-mode-common-hook}, or
|
|
3145 simply add the following to the top of your @file{.emacs} file:
|
|
3146 @example
|
|
3147
|
|
3148 (require 'cc-mode)
|
|
3149
|
|
3150 @end example
|
|
3151
|
|
3152 See the sample @file{.emacs} file @ref{Sample .emacs File} for
|
|
3153 details.
|
|
3154
|
2
|
3155 @sp 1
|
0
|
3156 @strong{Q.} @emph{How do I make strings, comments, keywords, and other
|
|
3157 constructs appear in different colors, or in bold face, etc.?}
|
|
3158
|
177
|
3159 @strong{A.} ``Syntax Colorization'' is a standard Emacs feature,
|
|
3160 controlled by @code{font-lock-mode}. It is not part of @ccmode{}.
|
0
|
3161
|
|
3162 @end quotation
|
|
3163
|
|
3164
|
|
3165 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
110
|
3166 @node Getting the latest CC Mode release, Sample .emacs File, Frequently Asked Questions, Top
|
0
|
3167 @comment node-name, next, previous,up
|
|
3168
|
110
|
3169 @chapter Getting the latest CC Mode release
|
|
3170 @cindex Getting the latest CC Mode release
|
0
|
3171 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
3172
|
177
|
3173 @ccmode{} is now standard with later versions Emacs 19 and XEmacs 19.
|
|
3174 It is also the standard for XEmacs 20, and will be the standard for
|
|
3175 Emacs 20 (unreleased as of this writing). You would typically just use
|
|
3176 the version that comes with your X/Emacs. These may be slightly out of
|
|
3177 date due to release schedule skew, so you should always check the
|
|
3178 canonical site for the latest version.
|
0
|
3179
|
|
3180 @example
|
2
|
3181 @group
|
|
3182
|
|
3183 World Wide Web:
|
|
3184
|
|
3185 @code{http://www.python.org/ftp/emacs/}
|
|
3186
|
|
3187 Anonymous FTP:
|
|
3188
|
|
3189 @code{ftp://ftp.python.org/pub/emacs/}
|
|
3190
|
|
3191 @end group
|
0
|
3192 @end example
|
|
3193
|
2
|
3194 There are many files under these directories; you can pick up the entire
|
|
3195 distribution (named @code{cc-mode.tar.gz}; a gzip'd tar file), or any of
|
|
3196 the individual files, including PostScript documentation.
|
0
|
3197
|
110
|
3198 If you do not have World Wide Web, or anonymous ftp access, you can get
|
|
3199 the distribution through an anonymous ftp-to-mail gateway, such as the
|
|
3200 one run by DEC at:
|
|
3201 @example
|
|
3202
|
|
3203 @code{ftpmail@@decwrl.dec.com}
|
|
3204
|
|
3205 @end example
|
|
3206 To get @ccmode{} via email, send the following message in the body of
|
|
3207 your mail to that address:
|
0
|
3208 @example
|
|
3209
|
|
3210 reply <a valid net address back to you>
|
|
3211 connect ftp.python.org
|
|
3212 binary
|
|
3213 uuencode
|
|
3214 chdir pub/emacs
|
|
3215 get cc-mode.tar.gz
|
|
3216
|
|
3217 @end example
|
|
3218 @noindent
|
|
3219 or just send the message "help" for more information on ftpmail.
|
2
|
3220 Response times will vary with the number of requests in the queue. I am
|
|
3221 in no way connected to this service, so I make no claims or guarantees
|
|
3222 about its availability!
|
0
|
3223
|
|
3224 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
110
|
3225 @node Sample .emacs File, Limitations and Known Bugs, Getting the latest CC Mode release, Top
|
0
|
3226 @comment node-name, next, previous,up
|
|
3227
|
110
|
3228 @chapter Sample .emacs file
|
|
3229 @cindex Sample .emacs file
|
0
|
3230 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
3231
|
|
3232 @example
|
|
3233 ;; Here's a sample .emacs file that might help you along the way. Just
|
|
3234 ;; copy this region and paste it into your .emacs file. You may want to
|
|
3235 ;; change some of the actual values.
|
|
3236
|
|
3237 (defconst my-c-style
|
110
|
3238 '((c-tab-always-indent . t)
|
|
3239 (c-comment-only-line-offset . 4)
|
|
3240 (c-hanging-braces-alist . ((substatement-open after)
|
|
3241 (brace-list-open)))
|
|
3242 (c-hanging-colons-alist . ((member-init-intro before)
|
|
3243 (inher-intro)
|
|
3244 (case-label after)
|
|
3245 (label after)
|
|
3246 (access-label after)))
|
|
3247 (c-cleanup-list . (scope-operator
|
|
3248 empty-defun-braces
|
|
3249 defun-close-semi))
|
|
3250 (c-offsets-alist . ((arglist-close . c-lineup-arglist)
|
|
3251 (substatement-open . 0)
|
|
3252 (case-label . 4)
|
|
3253 (block-open . 0)
|
|
3254 (knr-argdecl-intro . -)))
|
0
|
3255 (c-echo-syntactic-information-p . t)
|
|
3256 )
|
|
3257 "My C Programming Style")
|
|
3258
|
|
3259 ;; Customizations for all of c-mode, c++-mode, and objc-mode
|
|
3260 (defun my-c-mode-common-hook ()
|
|
3261 ;; add my personal style and set it for the current buffer
|
|
3262 (c-add-style "PERSONAL" my-c-style t)
|
|
3263 ;; offset customizations not in my-c-style
|
|
3264 (c-set-offset 'member-init-intro '++)
|
|
3265 ;; other customizations
|
|
3266 (setq tab-width 8
|
|
3267 ;; this will make sure spaces are used instead of tabs
|
|
3268 indent-tabs-mode nil)
|
|
3269 ;; we like auto-newline and hungry-delete
|
|
3270 (c-toggle-auto-hungry-state 1)
|
2
|
3271 ;; keybindings for all supported languages. We can put these in
|
177
|
3272 ;; c-mode-base-map because c-mode-map, c++-mode-map, objc-mode-map,
|
|
3273 ;; java-mode-map, and idl-mode-map inherit from it.
|
|
3274 (define-key c-mode-base-map "\C-m" 'newline-and-indent)
|
0
|
3275 )
|
|
3276
|
|
3277 (add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
|
|
3278 @end example
|
|
3279
|
|
3280 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
2
|
3281 @node Limitations and Known Bugs, Mailing Lists and Submitting Bug Reports, Sample .emacs File, Top
|
0
|
3282 @comment node-name, next, previous,up
|
|
3283 @chapter Limitations and Known Bugs
|
|
3284 @cindex Limitations and Known Bugs
|
|
3285 @comment * Limitations and Known Bugs
|
|
3286 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
3287
|
|
3288 @itemize @bullet
|
|
3289 @item
|
|
3290 Multi-line macros are not handled properly.
|
|
3291
|
|
3292 @item
|
|
3293 Re-indenting large regions or expressions can be slow.
|
|
3294
|
|
3295 @item
|
110
|
3296 Add-on fill packages may not work as well as @ccmode{}'s built-in
|
|
3297 filling routines. I no longer recommend you use @code{filladapt} to
|
|
3298 fill comments.
|
2
|
3299
|
|
3300 @cindex c-indent-exp
|
|
3301 @cindex indent-exp (c-)
|
0
|
3302 @item
|
2
|
3303 @code{c-indent-exp} has not been fully optimized. It essentially
|
|
3304 equivalent to hitting @kbd{TAB} (@code{c-indent-command}) on every
|
|
3305 line. Some information is cached from line to line, but such caching
|
|
3306 invariable causes inaccuracies in analysis in some bizarre situations.
|
0
|
3307
|
|
3308 @end itemize
|
|
3309
|
|
3310 @c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
3311 @node Mailing Lists and Submitting Bug Reports, Concept Index, Limitations and Known Bugs, Top
|
|
3312 @comment node-name, next, previous,up
|
|
3313 @chapter Mailing Lists and Submitting Bug Reports
|
|
3314 @cindex Mailing Lists and Submitting Bug Reports
|
|
3315 @c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
3316
|
|
3317 @kindex C-c C-b
|
|
3318 @findex c-submit-bug-report
|
|
3319 @findex submit-bug-report (c-)
|
|
3320 @cindex beta testers mailing list
|
|
3321 @cindex announcement mailing list
|
|
3322 To report bugs, use the @kbd{C-c C-b} (@code{c-submit-bug-report})
|
|
3323 command. This provides vital information I need to reproduce your
|
|
3324 problem. Make sure you include a concise, but complete code example.
|
|
3325 Please try to boil your example down to just the essential code needed
|
|
3326 to reproduce the problem, and include an exact recipe of steps needed to
|
|
3327 expose the bug. Be especially sure to include any code that appears
|
2
|
3328 @emph{before} your bug example, if you think it might affect my ability
|
|
3329 to reproduce it.
|
|
3330
|
|
3331 Bug reports are now sent to the following email addresses:
|
|
3332 @code{cc-mode-help@@python.org} and
|
110
|
3333 @code{bug-gnu-emacs@@prep.ai.mit.edu}; the latter is mirrored on the
|
177
|
3334 Usenet newsgroup @code{gnu.emacs.bug}. You can send other questions and
|
|
3335 suggestions (kudos? @code{;-)} to @code{cc-mode-help@@python.org}, or
|
110
|
3336 @code{help-gnu-emacs@@prep.ai.mit.edu} which is mirrored on newsgroup
|
0
|
3337 @code{gnu.emacs.help}.
|
|
3338
|
177
|
3339 If you want to get announcements of new CC Mode releases, send the
|
|
3340 word @emph{subscribe} in the body of a message to
|
|
3341 @code{cc-mode-announce-request@@python.org}. Announcements will also be
|
|
3342 posted to the Usenet newsgroups @code{gnu.emacs.sources},
|
|
3343 @code{comp.emacs}, @code{comp.emacs.xemacs}, and possibly some of the
|
|
3344 language oriented newsgroups. Note that the
|
|
3345 @code{cc-mode-victims@@python.org} mailing list was recently
|
|
3346 decommissioned.
|
0
|
3347
|
|
3348 @c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
3349 @node Concept Index, Command Index, Mailing Lists and Submitting Bug Reports, Top
|
|
3350 @comment node-name, next, previous, up
|
|
3351 @unnumbered Concept Index
|
|
3352 @c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
3353
|
|
3354 @printindex cp
|
|
3355
|
|
3356
|
|
3357 @c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
3358 @node Command Index, Key Index, Concept Index, Top
|
|
3359 @comment node-name, next, previous, up
|
|
3360 @unnumbered Command Index
|
|
3361 @c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
3362
|
|
3363 @ifinfo
|
|
3364
|
|
3365 @end ifinfo
|
110
|
3366 Since all @ccmode{} commands are prepended with the string
|
2
|
3367 @samp{c-}, each appears under its @code{c-@var{<thing>}} name and its
|
|
3368 @code{@var{<thing>} (c-)} name.
|
0
|
3369 @iftex
|
|
3370 @sp 2
|
|
3371 @end iftex
|
|
3372 @printindex fn
|
|
3373
|
|
3374
|
|
3375 @c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
3376 @node Key Index, Variable Index, Command Index, Top
|
|
3377 @comment node-name, next, previous, up
|
|
3378 @unnumbered Key Index
|
|
3379 @c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
3380
|
|
3381 @printindex ky
|
|
3382
|
|
3383
|
|
3384 @c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
3385 @node Variable Index, , Key Index, Top
|
|
3386 @comment node-name, next, previous, up
|
|
3387 @unnumbered Variable Index
|
|
3388 @c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
3389
|
110
|
3390 Since all @ccmode{} variables are prepended with the string
|
2
|
3391 @samp{c-}, each appears under its @code{c-@var{<thing>}} name and its
|
|
3392 @code{@var{<thing>} (c-)} name.
|
0
|
3393 @iftex
|
|
3394 @sp 2
|
|
3395 @end iftex
|
|
3396 @printindex vr
|
|
3397 @summarycontents
|
|
3398 @contents
|
|
3399 @bye
|