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