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
|
203
|
49 @center @titlefont{CC Mode 5.19}
|
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
|
203
|
1145 @code{nil} to inhibit progress messages, including messages normally
|
|
1146 printed when indentation is started and completed.
|
0
|
1147
|
|
1148 Also, except as noted below, re-indentation is always driven by the
|
|
1149 same mechanisms that control on-the-fly indentation of code. @xref{New
|
|
1150 Indentation Engine} for details.
|
|
1151
|
|
1152 @findex c-indent-command
|
|
1153 @findex indent-command (c-)
|
|
1154 @vindex c-tab-always-indent
|
|
1155 @vindex tab-always-indent (c-)
|
|
1156 @kindex TAB
|
|
1157 @cindex literal
|
2
|
1158 @vindex indent-tabs-mode
|
|
1159 @vindex c-insert-tab-function
|
|
1160 @vindex insert-tab-function (c-)
|
|
1161 @findex tab-to-tab-stop
|
0
|
1162 To indent a single line of code, use @kbd{TAB}
|
|
1163 (@code{c-indent-command}). The behavior of this command is controlled
|
|
1164 by the variable @code{c-tab-always-indent}. When this variable is
|
|
1165 @code{t}, @kbd{TAB} always just indents the current line. When
|
110
|
1166 @code{nil}, the line is indented only if point is at the left margin, or
|
2
|
1167 on or before the first non-whitespace character on the line, otherwise
|
|
1168 @emph{something else happens}@footnote{Actually what happens is that the
|
110
|
1169 function stored in @code{c-insert-tab-function} is called.
|
2
|
1170 Normally this just inserts a real tab character, or the equivalent
|
|
1171 number of spaces, depending on the setting of the variable
|
|
1172 @code{indent-tabs-mode}. If you preferred, you could set
|
|
1173 @code{c-insert-tab-function} to @code{tab-to-tab-stop} for example.}.
|
|
1174 If the value of @code{c-tab-always-indent} is something other than
|
|
1175 @code{t} or @code{nil} (e.g. @code{'other}), then a real tab
|
|
1176 character@footnote{The caveat about @code{indent-tabs-mode} in the
|
110
|
1177 previous footnote also applies here.} is inserted only when point is
|
2
|
1178 inside a literal (see @ref{Auto-newline insertion}), otherwise the line
|
|
1179 is indented.
|
0
|
1180
|
|
1181 @kindex M-C-q
|
|
1182 @findex c-indent-exp
|
|
1183 @findex indent-exp (c-)
|
|
1184 To indent an entire balanced brace or parenthesis expression, use
|
110
|
1185 @kbd{M-C-q} (@code{c-indent-exp}). Note that point should be on
|
0
|
1186 the opening brace or parenthesis of the expression you want to indent.
|
|
1187
|
|
1188 @kindex C-c C-q
|
|
1189 @findex c-indent-defun
|
|
1190 @findex indent-defun (c-)
|
|
1191 Another very convenient keystroke is @kbd{C-c C-q}
|
|
1192 (@code{c-indent-defun}) when re-indents the entire top-level function or
|
177
|
1193 class definition that encompasses point. It leaves point at the
|
0
|
1194 same position within the buffer.
|
|
1195
|
|
1196 @kindex M-C-\
|
|
1197 @findex indent-region
|
|
1198 To indent any arbitrary region of code, use @kbd{M-C-\}
|
|
1199 (@code{indent-region}). This is a standard Emacs command, specially
|
110
|
1200 tailored for C code in a @ccmode{} buffer. Note that of course,
|
|
1201 point and mark must delineate the region you
|
0
|
1202 want to indent.
|
|
1203
|
|
1204 @kindex M-C-h
|
|
1205 @findex c-mark-function
|
|
1206 @findex mark-function (c-)
|
|
1207 While not strictly an indentation function, @kbd{M-C-h}
|
|
1208 (@code{c-mark-function}) is useful for marking the current top-level
|
|
1209 function or class definition as the current region.
|
|
1210
|
2
|
1211 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
1212 @node Other Commands, , Indentation Commands, Commands
|
|
1213 @comment node-name, next, previous,up
|
|
1214
|
|
1215 @section Other Commands
|
|
1216 @cindex Other Commands
|
|
1217 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
1218
|
110
|
1219 @ccmode{} contains other useful command for moving around in C
|
2
|
1220 code.
|
|
1221
|
|
1222 @table @code
|
|
1223 @item C-c C-u (c-up-conditional)
|
|
1224 @kindex C-c C-u
|
|
1225 @findex c-up-conditional
|
|
1226 @findex up-conditional (c-)
|
110
|
1227 Move point back to the containing preprocessor conditional, leaving the
|
|
1228 mark behind. A prefix argument acts as a repeat count. With a negative
|
|
1229 argument, move point forward to the end of the containing
|
2
|
1230 preprocessor conditional. When going backwards, @code{#elif} is treated
|
|
1231 like @code{#else} followed by @code{#if}. When going forwards,
|
|
1232 @code{#elif} is ignored.@refill
|
|
1233
|
|
1234 @item C-c C-p (c-backward-conditional)
|
|
1235 @kindex C-c C-p
|
|
1236 @findex c-backward-conditional
|
|
1237 @findex backward-conditional (c-)
|
110
|
1238 Move point back over a preprocessor conditional, leaving the mark
|
2
|
1239 behind. A prefix argument acts as a repeat count. With a negative
|
|
1240 argument, move forward.
|
|
1241
|
|
1242 @item C-c C-n (c-forward-conditional)
|
|
1243 @kindex C-c C-n
|
|
1244 @findex c-forward-conditional
|
|
1245 @findex forward-conditional (c-)
|
110
|
1246 Move point forward across a preprocessor conditional, leaving the mark
|
2
|
1247 behind. A prefix argument acts as a repeat count. With a negative
|
|
1248 argument, move backward.
|
|
1249
|
|
1250 @item M-a (c-beginning-of-statement)
|
|
1251 @kindex ESC a
|
|
1252 @findex c-beginning-of-statement
|
|
1253 @findex beginning-of-statement (c-)
|
110
|
1254 Move point to the beginning of the innermost C statement. If point is
|
2
|
1255 already at the beginning of a statement, it moves to the beginning of
|
|
1256 the preceding statement. With prefix argument @var{n}, move back
|
|
1257 @var{n} @minus{} 1 statements.
|
|
1258
|
110
|
1259 If point is within a string or comment, or at the end of a comment, this
|
|
1260 command moves by sentences instead of statements.
|
|
1261
|
|
1262 When called from a program, this function takes three optional
|
|
1263 arguments: the numeric prefix argument, a buffer position limit (don't
|
|
1264 move back before that place), and a flag to indicate whether movement
|
|
1265 should be by statements (if @code{t}) or sentence (if non-@code{nil}).
|
2
|
1266
|
|
1267 @item M-e (c-end-of-statement)
|
|
1268 @kindex ESC e
|
|
1269 @findex c-end-of-statement
|
|
1270 @findex end-of-statement (c-)
|
110
|
1271 Move point to the end of the innermost C statement. If point is at the
|
2
|
1272 end of a statement, move to the end of the next statement. With prefix
|
|
1273 argument @var{n}, move forward @var{n} @minus{} 1 statements.
|
|
1274
|
110
|
1275 If point is within a string or comment, or at the end of a comment, this
|
|
1276 command moves by sentences instead of statements.
|
|
1277
|
|
1278 When called from a program, this function takes three optional
|
|
1279 arguments: the numeric prefix argument, a buffer position limit (don't
|
|
1280 move back before that place), and a flag to indicate whether movement
|
|
1281 should be by statements (if @code{t}) or sentence (if non-@code{nil}).
|
2
|
1282
|
|
1283 @item M-x c-forward-into-nomenclature
|
|
1284 @findex c-forward-into-nomenclature
|
|
1285 @findex forward-into-nomenclature (c-)
|
|
1286 A popular programming style, especially for object-oriented languages
|
|
1287 such as C++ is to write symbols in a mixed case format, where the first
|
|
1288 letter of each word is capitalized, and not separated by underscores.
|
|
1289 E.g. @samp{SymbolsWithMixedCaseAndNoUnderlines}.
|
|
1290
|
177
|
1291 This command moves point forward to next capitalized word. With prefix
|
|
1292 argument @var{n}, move @var{n} times.
|
2
|
1293
|
|
1294 @item M-x c-backward-into-nomenclature
|
|
1295 @findex c-backward-into-nomenclature
|
|
1296 @findex backward-into-nomenclature (c-)
|
177
|
1297 Move point backward to beginning of the next capitalized
|
|
1298 word. With prefix argument @var{n}, move @var{n} times. If
|
2
|
1299 @var{n} is negative, move forward.
|
|
1300
|
|
1301 @kindex C-c :
|
|
1302 @findex c-scope-operator
|
|
1303 @findex scope-operator (c-)
|
|
1304 @item C-c : (c-scope-operator)
|
|
1305 In C++, it is also sometimes desirable to insert the double-colon scope
|
|
1306 operator without performing the electric behavior of colon insertion.
|
|
1307 @kbd{C-c :} does just this.
|
|
1308
|
110
|
1309 @item M-q (fill-paragraph)
|
|
1310 @kindex ESC q
|
|
1311 @findex fill-paragraph
|
|
1312 @vindex c-hanging-comment-starter-p
|
|
1313 @vindex c-hanging-comment-ender-p
|
|
1314 @vindex hanging-comment-starter-p (c-)
|
|
1315 @vindex hanging-comment-ender-p (c-)
|
177
|
1316
|
110
|
1317 The command is used to fill a block style (C) or line style (C++)
|
|
1318 comment, in much the same way that text in the various text modes can be
|
177
|
1319 filled@footnote{You should not use specialized filling packages such as
|
|
1320 @code{filladapt} with CC Mode. They don't work as well for filling as
|
|
1321 @code{c-fill-paragraph}}. You should never attempt to fill non-comment
|
|
1322 code sections; you'll end up with garbage! Two variables control how C
|
|
1323 style block comments are filled, specifically how the comment start and
|
|
1324 end delimiters are handled.
|
110
|
1325
|
|
1326 The variable @code{c-hanging-comment-starter-p} controls whether comment
|
|
1327 start delimiters which appear on a line by themselves, end up on a line
|
|
1328 by themselves after the fill. When the value is @code{nil}, the comment
|
|
1329 starter will remain on its own line@footnote{It will not be placed on a
|
|
1330 separate line if it is not already on a separate line.}. Otherwise,
|
|
1331 text on the next line will be put on the same line as the comment
|
|
1332 starter. This is called @dfn{hanging} because the following text hangs
|
177
|
1333 on the line with the comment starter@footnote{This variable is @code{t}
|
|
1334 by default, except in @code{java-mode}. Hanging comment starters mess
|
|
1335 up Javadoc style comments.}
|
110
|
1336
|
|
1337 The variable @code{c-hanging-comment-ender-p} controls the analogous
|
|
1338 behavior for the block comment end delimiter. When the value is
|
|
1339 @code{nil}, the comment ender will remain on its own line after the
|
|
1340 file@footnote{The same caveat as above holds true.}. Otherwise, the
|
|
1341 comment end delimiter will be placed at the end of the previous line.
|
|
1342
|
2
|
1343 @end table
|
0
|
1344
|
|
1345 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
2
|
1346 @node Customizing Indentation, Syntactic Symbols, Commands, Top
|
0
|
1347 @comment node-name, next, previous,up
|
|
1348
|
|
1349 @chapter Customizing Indentation
|
|
1350 @cindex Customizing Indentation
|
|
1351 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
1352
|
110
|
1353 @vindex c-offsets-alist
|
|
1354 @vindex offsets-alist (c-)
|
0
|
1355 @cindex c-set-offset
|
|
1356 @cindex set-offset (c-)
|
110
|
1357 The variable @code{c-offsets-alist} contains the mappings between
|
|
1358 syntactic symbols and the offsets to apply for those symbols. You
|
|
1359 should never modify this variable directly though. Use the function
|
|
1360 @code{c-set-offset} instead (see below for details).
|
|
1361
|
0
|
1362 The @code{c-offsets-alist} variable is where you customize all your
|
|
1363 indentations. You simply need to decide what additional offset you want
|
|
1364 to add for every syntactic symbol. You can use the command @kbd{C-c
|
|
1365 C-o} (@code{c-set-offset}) as the way to set offsets, both interactively
|
|
1366 and from your mode hook. Also, you can set up @emph{styles} of
|
177
|
1367 indentatio. Most likely, you'll
|
0
|
1368 find one of the pre-defined styles will suit your needs, but if not,
|
|
1369 this section will describe how to set up basic editing configurations.
|
|
1370 @xref{Styles} for an explanation of how to set up named styles.
|
|
1371
|
|
1372 @cindex c-basic-offset
|
|
1373 @cindex basic-offset (c-)
|
|
1374 As mentioned previously, the variable @code{c-offsets-alist} is an
|
2
|
1375 association list of syntactic symbols and the offsets to be applied for
|
110
|
1376 those symbols. In fact, these offset values can be any of an integer, a
|
|
1377 function or lambda expression, a variable name, or one of the following
|
|
1378 symbols: @code{+}, @code{-}, @code{++}, @code{--}, @code{*}, or
|
|
1379 @code{/}. These symbols describe offset in multiples of the value of
|
|
1380 the variable @code{c-basic-offset}. By defining a style's indentation
|
|
1381 in terms of this fundamental variable, you can change the amount of
|
|
1382 whitespace given to an indentation level while leaving the same
|
|
1383 relationship between levels. Here are the values that the special
|
0
|
1384 symbols correspond to:
|
|
1385
|
2
|
1386 @table @code
|
|
1387
|
|
1388 @item +
|
|
1389 @code{c-basic-offset} times 1
|
|
1390 @item -
|
|
1391 @code{c-basic-offset} times -1
|
|
1392 @item ++
|
|
1393 @code{c-basic-offset} times 2
|
|
1394 @item --
|
|
1395 @code{c-basic-offset} times -2
|
|
1396 @item *
|
|
1397 @code{c-basic-offset} times 0.5
|
|
1398 @item /
|
|
1399 @code{c-basic-offset} times -0.5
|
|
1400
|
|
1401 @end table
|
0
|
1402
|
110
|
1403 @vindex c-style-variables-are-local-p
|
|
1404 @vindex style-variables-are-local-p (c-)
|
0
|
1405 @noindent
|
|
1406 So, for example, because most of the default offsets are defined in
|
|
1407 terms of @code{+}, @code{-}, and @code{0}, if you like the general
|
|
1408 indentation style, but you use 4 spaces instead of 2 spaces per level,
|
|
1409 you can probably achieve your style just by changing
|
165
|
1410 @code{c-basic-offset} like so (in your @file{.emacs} file):
|
0
|
1411 @example
|
|
1412
|
165
|
1413 (setq c-basic-offset 4)
|
0
|
1414
|
|
1415 @end example
|
|
1416
|
|
1417 @noindent
|
|
1418 This would change
|
|
1419 @example
|
|
1420 @group
|
|
1421
|
|
1422 int add( int val, int incr, int doit )
|
|
1423 @{
|
2
|
1424 if( doit )
|
|
1425 @{
|
|
1426 return( val + incr );
|
|
1427 @}
|
|
1428 return( val );
|
|
1429 @}
|
|
1430
|
|
1431 @end group
|
|
1432 @end example
|
|
1433 @noindent
|
|
1434 to
|
|
1435 @example
|
|
1436 @group
|
|
1437
|
|
1438 int add( int val, int incr, int doit )
|
|
1439 @{
|
0
|
1440 if( doit )
|
|
1441 @{
|
|
1442 return( val + incr );
|
|
1443 @}
|
|
1444 return( val );
|
|
1445 @}
|
|
1446
|
|
1447 @end group
|
|
1448 @end example
|
|
1449
|
|
1450
|
|
1451 To change indentation styles more radically, you will want to change the
|
|
1452 value associated with the syntactic symbols in the
|
|
1453 @code{c-offsets-alist} variable. First, I'll show you how to do that
|
|
1454 interactively, then I'll describe how to make changes to your
|
|
1455 @file{.emacs} file so that your changes are more permanent.
|
|
1456
|
|
1457 @menu
|
|
1458 * Interactive Customization::
|
|
1459 * Permanent Customization::
|
|
1460 * Styles::
|
|
1461 * Advanced Customizations::
|
|
1462 @end menu
|
|
1463
|
|
1464 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
1465 @node Interactive Customization, Permanent Customization, , Customizing Indentation
|
|
1466 @comment node-name, next, previous,up
|
|
1467
|
|
1468 @section Interactive Customization
|
|
1469 @cindex Interactive Customization
|
|
1470 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
1471
|
|
1472 As an example of how to customize indentation, let's change the
|
2
|
1473 style of this example@footnote{In this an subsequent examples, the
|
|
1474 original code is formatted using the @samp{gnu} style unless otherwise
|
|
1475 indicated. @xref{Styles}.}:
|
0
|
1476 @example
|
|
1477 @group
|
|
1478
|
|
1479 1: int add( int val, int incr, int doit )
|
|
1480 2: @{
|
2
|
1481 3: if( doit )
|
|
1482 4: @{
|
|
1483 5: return( val + incr );
|
|
1484 6: @}
|
|
1485 7: return( val );
|
0
|
1486 8: @}
|
|
1487
|
|
1488 @end group
|
|
1489 @end example
|
|
1490 @noindent
|
|
1491 to:
|
|
1492 @example
|
|
1493 @group
|
|
1494
|
|
1495 1: int add( int val, int incr, int doit )
|
|
1496 2: @{
|
2
|
1497 3: if( doit )
|
|
1498 4: @{
|
|
1499 5: return( val + incr );
|
|
1500 6: @}
|
|
1501 7: return( val );
|
0
|
1502 8: @}
|
|
1503
|
|
1504 @end group
|
|
1505 @end example
|
|
1506
|
|
1507 In other words, we want to change the indentation of braces that open a
|
|
1508 block following a condition so that the braces line up under the
|
|
1509 conditional, instead of being indented. Notice that the construct we
|
|
1510 want to change starts on line 4. To change the indentation of a line,
|
2
|
1511 we need to see which syntactic components affect the offset calculations
|
0
|
1512 for that line. Hitting @kbd{C-c C-s} on line 4 yields:
|
|
1513 @example
|
|
1514
|
2
|
1515 ((substatement-open . 44))
|
0
|
1516
|
|
1517 @end example
|
|
1518
|
|
1519 @findex c-set-offset
|
|
1520 @findex set-offset (c-)
|
|
1521 @kindex C-c C-o
|
|
1522 @noindent
|
|
1523 so we know that to change the offset of the open brace, we need to
|
|
1524 change the indentation for the @code{substatement-open} syntactic
|
|
1525 symbol. To do this interactively, just hit @kbd{C-c C-o}
|
|
1526 (@code{c-set-offset}). This prompts you for the syntactic symbol to
|
|
1527 change, providing a reasonable default. In this case, the default is
|
|
1528 @code{substatement-open}, which is just the syntactic symbol we want to
|
|
1529 change!
|
|
1530
|
110
|
1531 After you hit return, @ccmode{} will then prompt you for the new
|
0
|
1532 offset value, with the old value as the default. The default in this
|
2
|
1533 case is @samp{+}, but we want no extra indentation so enter
|
0
|
1534 @samp{0} and @kbd{RET}. This will associate the offset 0 with the
|
|
1535 syntactic symbol @code{substatement-open} in the @code{c-offsets-alist}
|
|
1536 variable.
|
|
1537
|
|
1538 @findex c-indent-defun
|
|
1539 @findex indent-defun (c-)
|
|
1540 @kindex C-c C-q
|
|
1541 To check your changes quickly, just hit @kbd{C-c C-q}
|
|
1542 (@code{c-indent-defun}) to reindent the entire function. The example
|
|
1543 should now look like:
|
|
1544 @example
|
|
1545 @group
|
|
1546
|
|
1547 1: int add( int val, int incr, int doit )
|
|
1548 2: @{
|
2
|
1549 3: if( doit )
|
|
1550 4: @{
|
|
1551 5: return( val + incr );
|
|
1552 6: @}
|
|
1553 7: return( val );
|
0
|
1554 8: @}
|
|
1555
|
|
1556 @end group
|
|
1557 @end example
|
|
1558
|
|
1559 Notice how just changing the open brace offset on line 4 is all we
|
|
1560 needed to do. Since the other affected lines are indented relative to
|
|
1561 line 4, they are automatically indented the way you'd expect. For more
|
|
1562 complicated examples, this may not always work. The general approach to
|
|
1563 take is to always start adjusting offsets for lines higher up in the
|
|
1564 file, then re-indent and see if any following lines need further
|
|
1565 adjustments.
|
|
1566
|
|
1567 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
1568 @node Permanent Customization, Styles, Interactive Customization, Customizing Indentation
|
|
1569 @comment node-name, next, previous,up
|
|
1570
|
110
|
1571 @section Permanent Customization
|
|
1572 @cindex Permanent Customization
|
0
|
1573 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
1574
|
|
1575 @vindex c-mode-common-hook
|
|
1576 @vindex c-mode-hook
|
|
1577 @vindex c++-mode-hook
|
|
1578 @vindex objc-mode-hook
|
|
1579 @vindex java-mode-hook
|
177
|
1580 @vindex idl-mode-hook
|
|
1581 @vindex c-initialization-hook
|
|
1582 @vindex initialization-hook (c-)
|
0
|
1583 @cindex hooks
|
165
|
1584 To make your changes permanent, you need to add some lisp code to your
|
|
1585 @file{.emacs} file, but first you need to decide whether your styles
|
|
1586 should be global in every buffer, or local to each specific buffer.
|
|
1587
|
177
|
1588 If you edit primarily one style of code, you may want to make the
|
|
1589 @ccmode{} style variables have global values so that every buffer will
|
|
1590 share the style settings. This will allow you to set the @ccmode{}
|
|
1591 variables at the top level of your @file{.emacs} file, and is the
|
|
1592 way @ccmode{} works by default.
|
165
|
1593
|
|
1594 @vindex c-mode-common-hook
|
|
1595 @vindex mode-common-hook (c-)
|
|
1596 @vindex c-style-variables-are-local-p
|
|
1597 @vindex style-variables-are-local-p (c-)
|
177
|
1598 If you edit many different styles of code at
|
|
1599 the same time, you might want to make the @ccmode{} style variables
|
165
|
1600 have buffer local values. If you do this, then you will need to set any
|
|
1601 @ccmode{} style variables in a hook function (e.g. off of
|
|
1602 @code{c-mode-common-hook} instead of at the top level of your
|
|
1603 @file{.emacs} file. The recommended way to do this is to set the
|
|
1604 variable @code{c-style-variables-are-local-p} to @code{t}
|
|
1605 @strong{before} @ccmode{} is loaded into your Emacs session.
|
|
1606
|
|
1607 @ccmode{} provides several hooks that you can
|
2
|
1608 use to customize the mode according to your coding style. Each language
|
110
|
1609 mode has its own hook, adhering to standard Emacs major mode
|
177
|
1610 conventions. There is also one general hook and one package
|
|
1611 initialization hook:
|
2
|
1612
|
|
1613 @itemize @bullet
|
|
1614
|
|
1615 @item
|
|
1616 @code{c-mode-hook} --- for C buffers only
|
|
1617 @item
|
|
1618 @code{c++-mode-hook} --- for C++ buffers only
|
|
1619 @item
|
|
1620 @code{objc-mode-hook} --- for Objective-C buffers only
|
|
1621 @item
|
|
1622 @code{java-mode-hook} --- for Java buffers only
|
|
1623 @item
|
177
|
1624 @code{idl-mode-hook} --- for IDL buffers only
|
|
1625 @item
|
2
|
1626 @code{c-mode-common-hook} --- common across all languages
|
177
|
1627 @item
|
|
1628 @code{c-initialization-hook} --- hook run only once per Emacs session,
|
|
1629 when @ccmode{} is initialized.
|
2
|
1630
|
|
1631 @end itemize
|
|
1632
|
|
1633 The language hooks get run as the last thing when you enter that
|
177
|
1634 language mode. The @code{c-mode-common-hook} is run by all
|
2
|
1635 supported modes @emph{before} the language specific hook, and thus can
|
|
1636 contain customizations that are common across all languages. Most of
|
|
1637 the examples in this section will assume you are using the common
|
|
1638 hook@footnote{The interaction between @code{java-mode} and the hook
|
|
1639 variables is slightly different than for the other modes.
|
|
1640 @code{java-mode} sets the style (see @ref{Styles}) of the buffer to
|
|
1641 @samp{java} @emph{before} running the @code{c-mode-common-hook} or
|
177
|
1642 @code{java-mode-hook}. You need to be aware of this so that style
|
|
1643 settings in @code{c-mode-common-hook} don't clobber your Java style.}.
|
0
|
1644
|
|
1645 Here's a simplified example of what you can add to your @file{.emacs}
|
|
1646 file to make the changes described in the previous section
|
110
|
1647 (@ref{Interactive Customization}) more permanent. See the Emacs manuals
|
|
1648 for more information on customizing Emacs via hooks. @xref{Sample
|
|
1649 .emacs File} for a more complete sample @file{.emacs} file.
|
0
|
1650 @example
|
|
1651 @group
|
|
1652
|
|
1653 (defun my-c-mode-common-hook ()
|
177
|
1654 ;; my customizations for all of c-mode and related modes
|
0
|
1655 (c-set-offset 'substatement-open 0)
|
|
1656 ;; other customizations can go here
|
|
1657 )
|
|
1658 (add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
|
|
1659
|
|
1660 @end group
|
|
1661 @end example
|
|
1662
|
|
1663 For complex customizations, you will probably want to set up a
|
|
1664 @emph{style} that groups all your customizations under a single
|
|
1665 name.
|
|
1666
|
|
1667 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
1668 @node Styles, Advanced Customizations, Permanent Customization, Customizing Indentation
|
|
1669 @comment node-name, next, previous,up
|
|
1670
|
|
1671 @section Styles
|
|
1672 @cindex Styles
|
|
1673 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
1674
|
|
1675 Most people only need to edit code formatted in just a few well-defined
|
|
1676 and consistent styles. For example, their organization might impose a
|
|
1677 ``blessed'' style that all its programmers must conform to. Similarly,
|
|
1678 people who work on GNU software will have to use the GNU coding style on
|
177
|
1679 C code. Some shops are more lenient, allowing a variety of coding
|
0
|
1680 styles, and as programmers come and go, there could be a number of
|
110
|
1681 styles in use. For this reason, @ccmode{} makes it convenient for
|
0
|
1682 you to set up logical groupings of customizations called @dfn{styles},
|
|
1683 associate a single name for any particular style, and pretty easily
|
2
|
1684 start editing new or existing code using these styles. This section
|
0
|
1685 describes how to set up styles and how to edit your C code using styles.
|
|
1686
|
|
1687 @menu
|
|
1688 * Built-in Styles::
|
|
1689 * Adding Styles::
|
|
1690 * File Styles::
|
|
1691 @end menu
|
|
1692
|
|
1693
|
|
1694 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
1695 @node Built-in Styles, Adding Styles, , Styles
|
|
1696 @comment node-name, next, previous,up
|
|
1697
|
|
1698 @subsection Built-in Styles
|
|
1699 @cindex Built-in Styles
|
|
1700 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
1701
|
110
|
1702 If you're lucky, one of @ccmode{}'s built-in styles might be just
|
|
1703 what you're looking for. These include:
|
0
|
1704
|
|
1705 @itemize @bullet
|
|
1706 @item
|
|
1707 @cindex GNU style
|
2
|
1708 @code{gnu} --- coding style blessed by the Free Software Foundation
|
0
|
1709 for C code in GNU programs.
|
|
1710
|
|
1711 @item
|
|
1712 @cindex K&R style
|
2
|
1713 @code{k&r} --- The classic Kernighan and Ritchie style for C code.
|
0
|
1714
|
|
1715 @item
|
|
1716 @cindex BSD style
|
2
|
1717 @code{bsd} --- Also known as ``Allman style'' after Eric Allman.
|
|
1718
|
|
1719 @item
|
|
1720 @cindex Whitesmith style
|
|
1721 @code{whitesmith} --- Popularized by the examples that came with
|
|
1722 Whitesmiths C, an early commercial C compiler.
|
0
|
1723
|
|
1724 @item
|
|
1725 @cindex Stroustrup style
|
2
|
1726 @code{stroustrup} --- The classic Stroustrup style for C++ code.
|
0
|
1727
|
|
1728 @item
|
|
1729 @cindex Ellemtel style
|
2
|
1730 @code{ellemtel} --- Popular C++ coding standards as defined by
|
0
|
1731 ``Programming in C++, Rules and Recommendations'', Erik Nyquist and Mats
|
|
1732 Henricson, Ellemtel @footnote{This document is ftp'able from
|
|
1733 @code{euagate.eua.ericsson.se}}.
|
|
1734
|
|
1735 @item
|
110
|
1736 @cindex Linux style
|
|
1737 @code{linux} --- C coding standard for Linux development.
|
|
1738
|
|
1739 @item
|
|
1740 @cindex Python style
|
|
1741 @code{python} --- C coding standard for Python extension
|
|
1742 modules@footnote{Python is a high level scripting language with a C/C++
|
|
1743 foreign function interface. For more information, see
|
|
1744 @code{<http://www.python.org/>}.}.
|
|
1745
|
|
1746 @item
|
0
|
1747 @cindex Java style
|
|
1748 @cindex java-mode
|
2
|
1749 @code{java} --- The style for editing Java code. Note that this style is
|
0
|
1750 automatically installed when you enter @code{java-mode}.
|
|
1751
|
|
1752 @end itemize
|
|
1753
|
|
1754 @findex c-set-style
|
|
1755 @findex set-style (c-)
|
110
|
1756 @kindex C-c .
|
0
|
1757 If you'd like to experiment with these built-in styles you can simply
|
110
|
1758 type the following in a @ccmode{} buffer:
|
0
|
1759 @example
|
|
1760 @group
|
|
1761
|
110
|
1762 @kbd{C-c . @var{STYLE-NAME} RET}
|
0
|
1763
|
|
1764 @end group
|
|
1765 @end example
|
|
1766 @noindent
|
110
|
1767 @kbd{C-c .} runs the command @code{c-set-style}. Note that all style
|
|
1768 names are case insensitive, even the ones you define.
|
0
|
1769
|
|
1770 Setting a style in this way does @emph{not} automatically re-indent your
|
|
1771 file. For commands that you can use to view the effect of your changes,
|
2
|
1772 see @ref{Commands}.
|
0
|
1773
|
|
1774 Once you find a built-in style you like, you can make the change
|
110
|
1775 permanent by adding some lisp to your @file{.emacs} file. Let's say for
|
2
|
1776 example that you want to use the @samp{ellemtel} style in all your
|
0
|
1777 files. You would add this:
|
|
1778 @example
|
|
1779 @group
|
|
1780
|
|
1781 (defun my-c-mode-common-hook ()
|
2
|
1782 ;; use Ellemtel style for all C like languages
|
0
|
1783 (c-set-style "ellemtel")
|
|
1784 ;; other customizations can go here
|
|
1785 )
|
|
1786 (add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
|
|
1787
|
|
1788 @end group
|
|
1789 @end example
|
|
1790
|
110
|
1791 @cindex cc-mode style
|
2
|
1792 There is one other special style you can use, called @samp{cc-mode}
|
|
1793 style. This style is special because all other styles implicitly
|
|
1794 inherit from it; in other words, whenever you set a style,
|
|
1795 @samp{cc-mode} is applied before the one you selected. This means
|
|
1796 your style need only define the differences between it and
|
|
1797 @samp{cc-mode} style.
|
|
1798
|
110
|
1799 Note @emph{you should never change any of the default styles}.
|
|
1800 Instead, it's better to add a new style using @code{c-add-style}
|
|
1801 (@xref{Adding Styles}). This is especially true for @code{cc-mode} and
|
|
1802 @code{java} styles.
|
|
1803
|
|
1804 @vindex c-indentation-style
|
|
1805 @vindex indentation-style (c-)
|
2
|
1806 Note that for BOCM compatibility, @samp{gnu} is the default
|
|
1807 style, and any non-style based customizations you make (i.e. in
|
|
1808 @code{c-mode-common-hook} in your
|
|
1809 @file{.emacs} file) will be based on @samp{gnu} style unless you do
|
110
|
1810 a @code{c-set-style} as the first thing in your hook. The variable
|
|
1811 @code{c-indentation-style} always contains the buffer's current style name,
|
|
1812 as a string.
|
0
|
1813
|
|
1814
|
|
1815 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
1816 @node Adding Styles, File Styles, Built-in Styles, Styles
|
|
1817 @comment node-name, next, previous,up
|
|
1818
|
|
1819 @subsection Adding Styles
|
|
1820 @cindex Adding Styles
|
|
1821 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
1822
|
|
1823 @vindex c-style-alist
|
|
1824 @vindex style-alist (c-)
|
|
1825 @findex c-add-style
|
|
1826 @findex add-style (c-)
|
|
1827 If none of the built-in styles is appropriate, you'll probably want to
|
2
|
1828 add a new @dfn{style definition}. Styles are kept in the
|
|
1829 @code{c-style-alist} variable, but you should never modify this variable
|
110
|
1830 directly. Instead, @ccmode{} provides the function
|
2
|
1831 @code{c-add-style} that you can use to easily add new styles or change
|
|
1832 existing styles. This function takes two arguments, a @var{stylename}
|
|
1833 string, and an association list @var{description} of style
|
|
1834 customizations. If @var{stylename} is not already in
|
|
1835 @code{c-style-alist}, the new style is added, otherwise the style is
|
|
1836 changed to the new @var{description}.
|
|
1837 This function also takes an optional third argument, which if
|
|
1838 non-@code{nil}, automatically applies the new style to the current
|
|
1839 buffer.
|
0
|
1840
|
177
|
1841 @comment TBD: The next paragraph is bogus. I really need to better
|
|
1842 @comment document adding styles, including setting up inherited styles.
|
|
1843
|
0
|
1844 The sample @file{.emacs} file provides a concrete example of how a new
|
|
1845 style can be added and automatically set. @xref{Sample .emacs File}.
|
|
1846
|
|
1847 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
1848 @node File Styles, , Adding Styles, Styles
|
|
1849 @comment node-name, next, previous,up
|
|
1850
|
|
1851 @subsection File Styles
|
|
1852 @cindex File Styles
|
|
1853 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
1854
|
|
1855 @cindex local variables
|
177
|
1856
|
0
|
1857 The Emacs manual describes how you can customize certain variables on a
|
|
1858 per-file basis by including a @dfn{Local Variable} block at the end of
|
177
|
1859 the file. So far, you've only seen a functional interface to @ccmode{}
|
|
1860 customization, which is highly inconvenient for use in a Local Variable
|
|
1861 block. @ccmode{} provides two variables that make it easier for you to
|
181
|
1862 customize your style on a per-file basis@footnote{Note that this feature
|
|
1863 doesn't work with Emacs versions before XEmacs 19.12 and Emacs 19.29.
|
|
1864 It works via the standard Emacs hook variable
|
|
1865 @code{hack-local-variables-hook}.}
|
0
|
1866
|
|
1867 @vindex c-file-style
|
|
1868 @vindex file-style (c-)
|
|
1869 @vindex c-file-offsets
|
|
1870 @vindex file-offsets (c-)
|
|
1871
|
2
|
1872 The variable @code{c-file-style} can be set to a style name string.
|
110
|
1873 When the file is visited, @ccmode{} will automatically set the
|
2
|
1874 file's style to this style using @code{c-set-style}.
|
0
|
1875
|
|
1876 @vindex c-offsets-alist
|
|
1877 @vindex offsets-alist (c-)
|
|
1878 @findex c-set-offset
|
|
1879 @findex set-offset (c-)
|
|
1880 Another variable, @code{c-file-offsets}, takes an association list
|
|
1881 similar to what is allowed in @code{c-offsets-alist}. When the file is
|
110
|
1882 visited, @ccmode{} will automatically institute these offets using
|
0
|
1883 @code{c-set-offset}.
|
|
1884
|
|
1885 Note that file style settings (i.e. @code{c-file-style}) are applied
|
177
|
1886 before file offset settings (i.e. @code{c-file-offsets}).
|
0
|
1887
|
|
1888
|
|
1889 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
1890 @node Advanced Customizations, , Styles, Customizing Indentation
|
|
1891 @comment node-name, next, previous,up
|
|
1892
|
|
1893 @section Advanced Customizations
|
|
1894 @cindex Advanced Customizations
|
|
1895 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
1896
|
|
1897 @vindex c-style-alist
|
|
1898 @vindex style-alist (c-)
|
|
1899 @vindex c-basic-offset
|
|
1900 @vindex basic-offset (c-)
|
110
|
1901 For most users, @ccmode{} will support their coding styles with
|
2
|
1902 very little need for more advanced customizations. Usually, one of the
|
|
1903 standard styles defined in @code{c-style-alist} will do the trick. At
|
|
1904 most, perhaps one of the syntactic symbol offsets will need to be
|
|
1905 tweaked slightly, or maybe @code{c-basic-offset} will need to be
|
|
1906 changed. However, some styles require a more flexible framework for
|
110
|
1907 customization, and one of the real strengths of @ccmode{} is that
|
2
|
1908 the syntactic analysis model provides just such a framework. This allows
|
110
|
1909 you to implement custom indentation calculations for situations not
|
2
|
1910 handled by the mode directly.
|
0
|
1911
|
110
|
1912 @vindex c-style-variables-are-local-p
|
|
1913 @vindex style-variables-are-local-p
|
|
1914 Note that the style controlling variables can either have global values,
|
|
1915 or can be buffer local (e.g. different in every buffer). If all the C
|
|
1916 files you edit tend to have the same style, you might want to keep the
|
|
1917 variables global. If you tend to edit files with many different styles,
|
|
1918 you will have to make the variables buffer local. The variable
|
|
1919 @code{c-style-variables-are-local-p} controls this.
|
|
1920
|
|
1921 When @code{c-style-variables-are-local-p} is non-nil, then the style
|
|
1922 variables will have a different settable value for each buffer,
|
165
|
1923 otherwise all buffers will share the same values. By default, its value
|
|
1924 is @code{nil} (i.e. global values). You @strong{must} set this variable
|
|
1925 before @ccmode{} is loaded into your Emacs session, and once the
|
|
1926 variables are made buffer local, they cannot be made global again
|
|
1927 (unless you restart Emacs of course!)
|
110
|
1928
|
0
|
1929 @menu
|
|
1930 * Custom Indentation Functions::
|
|
1931 * Custom Brace and Colon Hanging::
|
|
1932 * Customizing Semi-colons and Commas::
|
|
1933 * Other Special Indentations::
|
|
1934 @end menu
|
|
1935
|
|
1936 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
1937 @node Custom Indentation Functions, Custom Brace and Colon Hanging, , Advanced Customizations
|
|
1938 @comment node-name, next, previous,up
|
|
1939
|
|
1940 @subsection Custom Indentation Functions
|
|
1941 @cindex Custom Indentation Functions
|
|
1942 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
1943
|
|
1944 @cindex custom indentation functions
|
110
|
1945 The most flexible way to customize @ccmode{} is by writing @dfn{custom
|
|
1946 indentation functions} and associating them with specific syntactic
|
|
1947 symbols (see @ref{Syntactic Symbols}). @ccmode{} itself uses custom
|
|
1948 indentation functions to provide more sophisticated indentation, for
|
|
1949 example when lining up C++ stream operator blocks:
|
0
|
1950 @example
|
|
1951 @group
|
|
1952
|
|
1953 1: void main(int argc, char**)
|
|
1954 2: @{
|
|
1955 3: cout << "There were "
|
|
1956 4: << argc
|
|
1957 5: << "arguments passed to the program"
|
|
1958 6: << endl;
|
|
1959 7: @}
|
|
1960
|
|
1961 @end group
|
|
1962 @end example
|
|
1963
|
|
1964 In this example, lines 4 through 6 are assigned the @code{stream-op}
|
2
|
1965 syntactic symbol. Here, @code{stream-op} has an offset of @code{+}, and
|
|
1966 with a @code{c-basic-offset} of 2, you can see that lines 4 through 6
|
|
1967 are simply indented two spaces to the right of line 3. But perhaps we'd
|
177
|
1968 like @ccmode{} to be a little more intelligent so that it aligns
|
2
|
1969 all the @samp{<<} symbols in lines 3 through 6. To do this, we have
|
|
1970 to write a custom indentation function which finds the column of first
|
177
|
1971 stream operator on the first line of the statement. Here is sample
|
|
1972 lisp code implementing this:
|
0
|
1973 @example
|
|
1974 @group
|
|
1975
|
|
1976 (defun c-lineup-streamop (langelem)
|
|
1977 ;; lineup stream operators
|
|
1978 (save-excursion
|
|
1979 (let* ((relpos (cdr langelem))
|
|
1980 (curcol (progn (goto-char relpos)
|
|
1981 (current-column))))
|
|
1982 (re-search-forward "<<\\|>>" (c-point 'eol) 'move)
|
|
1983 (goto-char (match-beginning 0))
|
|
1984 (- (current-column) curcol))))
|
|
1985
|
|
1986 @end group
|
|
1987 @end example
|
|
1988 @noindent
|
|
1989 Custom indent functions take a single argument, which is a syntactic
|
|
1990 component cons cell (see @ref{Syntactic Analysis}). The
|
|
1991 function returns an integer offset value that will be added to the
|
2
|
1992 running total indentation for the line. Note that what actually gets
|
0
|
1993 returned is the difference between the column that the first stream
|
|
1994 operator is on, and the column of the buffer relative position passed in
|
110
|
1995 the function's argument. Remember that @ccmode{} automatically
|
0
|
1996 adds in the column of the component's relative buffer position and we
|
177
|
1997 don't the column offset added in twice.
|
0
|
1998
|
|
1999 @cindex stream-op syntactic symbol
|
|
2000 @findex c-lineup-streamop
|
|
2001 @findex lineup-streamop (c-)
|
|
2002 Now, to associate the function @code{c-lineup-streamop} with the
|
|
2003 @code{stream-op} syntactic symbol, we can add something like the
|
|
2004 following to our @code{c++-mode-hook}@footnote{It probably makes more
|
|
2005 sense to add this to @code{c++-mode-hook} than @code{c-mode-common-hook}
|
|
2006 since stream operators are only relevent for C++.}:
|
|
2007 @example
|
|
2008
|
|
2009 (c-set-offset 'stream-op 'c-lineup-streamop)
|
|
2010
|
|
2011 @end example
|
|
2012
|
|
2013 @kindex C-c C-q
|
|
2014 Now the function looks like this after re-indenting (using @kbd{C-c
|
|
2015 C-q}):
|
|
2016 @example
|
|
2017 @group
|
|
2018
|
|
2019 1: void main(int argc, char**)
|
|
2020 2: @{
|
|
2021 3: cout << "There were "
|
|
2022 4: << argc
|
|
2023 5: << "arguments passed to the program"
|
|
2024 6: << endl;
|
|
2025 7: @}
|
|
2026
|
|
2027 @end group
|
|
2028 @end example
|
|
2029
|
|
2030 @vindex c-offsets-alist
|
|
2031 @vindex offsets-alist (c-)
|
|
2032 Custom indentation functions can be as simple or as complex as you like,
|
|
2033 and any syntactic symbol that appears in @code{c-offsets-alist} can have
|
110
|
2034 a custom indentation function associated with it. @ccmode{} comes
|
2
|
2035 with several standard custom indentation functions, not all of which are
|
|
2036 used by the default styles.
|
|
2037
|
|
2038 @itemize @bullet
|
|
2039 @item
|
|
2040 @findex c-lineup-arglist
|
|
2041 @findex lineup-arglist (c-)
|
|
2042 @code{c-lineup-arglist} --- lines up function argument lines under the
|
|
2043 argument on the previous line.
|
|
2044
|
|
2045 @item
|
|
2046 @findex c-lineup-arglist-intro-after-paren
|
|
2047 @findex lineup-arglist-intro-after-paren (c-)
|
|
2048 @code{c-lineup-arglist-intro-after-paren} --- similar to
|
|
2049 @code{c-lineup-arglist}, but works for argument lists that begin with an
|
|
2050 open parenthesis followed by a newline.
|
|
2051
|
|
2052 @item
|
|
2053 @findex c-lineup-arglist-close-under-paren
|
|
2054 @findex lineup-arglist-close-under-paren (c-)
|
|
2055 @code{c-lineup-arglist-close-under-paren} --- set your
|
|
2056 @code{arglist-close} syntactic symbol to this line-up function so that
|
|
2057 parentheses that close argument lists will line up under the parenthesis
|
|
2058 that opened the argument list.
|
|
2059
|
|
2060 @item
|
|
2061 @findex c-lineup-streamop
|
|
2062 @findex lineup-streamop (c-)
|
|
2063 @code{c-lineup-streamop} --- lines up C++ stream operators
|
|
2064 (e.g. @samp{<<} and @samp{>>}).
|
|
2065
|
|
2066 @item
|
|
2067 @findex c-lineup-multi-inher
|
|
2068 @findex lineup-multi-inher (c-)
|
|
2069 @code{c-lineup-multi-inher} --- lines up multiple inheritance lines.
|
|
2070
|
|
2071 @item
|
|
2072 @findex c-lineup-C-comments
|
|
2073 @findex lineup-C-comments (c-)
|
|
2074 @code{c-lineup-C-comments} --- lines up C block comment continuation
|
|
2075 lines.
|
|
2076
|
|
2077 @item
|
|
2078 @findex c-lineup-comment
|
|
2079 @findex lineup-comment (c-)
|
|
2080 @vindex c-comment-only-line-offset
|
|
2081 @vindex comment-only-line-offset (c-)
|
177
|
2082 @code{c-lineup-comment} --- lines up comment only lines according to
|
|
2083 the variable @code{c-comment-only-line-offset}.
|
2
|
2084
|
|
2085 @item
|
|
2086 @findex c-lineup-runin-statements
|
|
2087 @findex lineup-runin-statements (c-)
|
|
2088 @code{c-lineup-runin-statements} --- lines up @code{statement}s for coding
|
|
2089 standards which place the first statement in a block on the same line as
|
177
|
2090 the block opening brace@footnote{Run-in style doesn't really work too
|
|
2091 well. You might need to write your own custom indentation functions to
|
|
2092 better support this style.}.
|
2
|
2093
|
|
2094 @item
|
|
2095 @findex c-lineup-math
|
|
2096 @findex lineup-math (c-)
|
|
2097 @code{c-lineup-math} --- lines up math @code{statement-cont} lines under
|
|
2098 the previous line after the equals sign.
|
|
2099
|
|
2100 @item
|
|
2101 @findex c-lineup-ObjC-method-call
|
|
2102 @findex lineup-ObjC-method-call (c-)
|
|
2103 @code{c-lineup-ObjC-method-call} --- for Objective-C code, lines up
|
|
2104 selector arguments just after the message receiver.
|
|
2105
|
|
2106 @item
|
|
2107 @findex c-lineup-ObjC-method-args
|
|
2108 @findex lineup-ObjC-method-args (c-)
|
|
2109 @code{c-lineup-ObjC-method-args} --- for Objective-C code, lines up the
|
|
2110 colons that separate arguments by aligning colons vertically.
|
|
2111
|
|
2112 @item
|
|
2113 @findex c-lineup-ObjC-method-args-2
|
|
2114 @findex lineup-ObjC-method-args-2 (c-)
|
|
2115 @code{c-lineup-ObjC-method-args-2} --- similar to
|
|
2116 @code{c-lineup-ObjC-method-args} but lines up the colon on the current
|
|
2117 line with the colon on the previous line.
|
|
2118
|
|
2119 @end itemize
|
0
|
2120
|
|
2121 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
2122 @node Custom Brace and Colon Hanging, Customizing Semi-colons and Commas, Custom Indentation Functions, Advanced Customizations
|
|
2123 @comment node-name, next, previous,up
|
|
2124
|
|
2125 @subsection Custom Brace and Colon Hanging
|
|
2126 @cindex Custom Brace and Colon Hanging
|
|
2127 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
2128
|
|
2129 @vindex c-hanging-braces-alist
|
|
2130 @vindex hanging-braces-alist (c-)
|
|
2131 Syntactic symbols aren't the only place where you can customize
|
110
|
2132 @ccmode{} with the lisp equivalent of callback functions. Brace
|
2
|
2133 ``hanginess'' can also be determined by custom functions associated with
|
0
|
2134 syntactic symbols on the @code{c-hanging-braces-alist} variable.
|
|
2135 Remember that @var{ACTION}'s are typically a list containing some
|
|
2136 combination of the symbols @code{before} and @code{after} (see
|
|
2137 @ref{Hanging Braces}). However, an @var{ACTION} can also be a function
|
177
|
2138 which gets called when a brace matching that syntactic symbol is
|
|
2139 entered.
|
0
|
2140
|
|
2141 @cindex customizing brace hanging
|
|
2142 These @var{ACTION} functions are called with two arguments: the
|
|
2143 syntactic symbol for the brace, and the buffer position at which the
|
|
2144 brace was inserted. The @var{ACTION} function is expected to return a
|
|
2145 list containing some combination of @code{before} and @code{after}. The
|
|
2146 function can also return @code{nil}. This return value has the normal
|
2
|
2147 brace hanging semantics.
|
0
|
2148
|
110
|
2149 As an example, @ccmode{} itself uses this feature to dynamically
|
2
|
2150 determine the hanginess of braces which close ``do-while''
|
0
|
2151 constructs:
|
|
2152 @example
|
|
2153 @group
|
|
2154
|
|
2155 void do_list( int count, char** atleast_one_string )
|
|
2156 @{
|
|
2157 int i=0;
|
|
2158 do @{
|
2
|
2159 handle_string( atleast_one_string[i] );
|
0
|
2160 i++;
|
|
2161 @} while( i < count );
|
|
2162 @}
|
|
2163
|
|
2164 @end group
|
|
2165 @end example
|
|
2166
|
|
2167 @findex c-snug-do-while
|
|
2168 @findex snug-do-while (c-)
|
110
|
2169 @ccmode{} assigns the @code{block-close} syntactic symbol to the
|
0
|
2170 brace that closes the @code{do} construct, and normally we'd like the
|
|
2171 line that follows a @code{block-close} brace to begin on a separate
|
2
|
2172 line. However, with ``do-while'' constructs, we want the
|
0
|
2173 @code{while} clause to follow the closing brace. To do this, we
|
|
2174 associate the @code{block-close} symbol with the @var{ACTION} function
|
|
2175 @code{c-snug-do-while}:
|
|
2176 @example
|
|
2177
|
|
2178 (defun c-snug-do-while (syntax pos)
|
|
2179 "Dynamically calculate brace hanginess for do-while statements.
|
|
2180 Using this function, `while' clauses that end a `do-while' block will
|
|
2181 remain on the same line as the brace that closes that block.
|
|
2182
|
|
2183 See `c-hanging-braces-alist' for how to utilize this function as an
|
|
2184 ACTION associated with `block-close' syntax."
|
|
2185 (save-excursion
|
|
2186 (let (langelem)
|
|
2187 (if (and (eq syntax 'block-close)
|
|
2188 (setq langelem (assq 'block-close c-syntactic-context))
|
|
2189 (progn (goto-char (cdr langelem))
|
|
2190 (if (= (following-char) ?@{)
|
|
2191 (forward-sexp -1))
|
|
2192 (looking-at "\\<do\\>[^_]")))
|
|
2193 '(before)
|
|
2194 '(before after)))))
|
|
2195
|
|
2196 @end example
|
|
2197
|
2
|
2198 This function simply looks to see if the brace closes a ``do-while''
|
|
2199 clause and if so, returns the list @samp{(before)} indicating
|
0
|
2200 that a newline should be inserted before the brace, but not after it.
|
2
|
2201 In all other cases, it returns the list @samp{(before after)} so
|
0
|
2202 that the brace appears on a line by itself.
|
|
2203
|
|
2204 @vindex c-syntactic-context
|
|
2205 @vindex syntactic-context (c-)
|
|
2206 During the call to the brace hanging @var{ACTION} function, the variable
|
|
2207 @code{c-syntactic-context} is bound to the full syntactic analysis list.
|
|
2208
|
|
2209 @cindex customizing colon hanging
|
|
2210 @vindex c-hanging-colon-alist
|
|
2211 @vindex hanging-colon-alist (c-)
|
|
2212 Note that for symmetry, colon hanginess should be customizable by
|
|
2213 allowing function symbols as @var{ACTION}s on the
|
|
2214 @code{c-hanging-colon-alist} variable. Since no use has actually been
|
110
|
2215 found for this feature, it isn't currently implemented!
|
0
|
2216
|
|
2217 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
2218 @node Customizing Semi-colons and Commas, Other Special Indentations, Custom Brace and Colon Hanging, Advanced Customizations
|
|
2219 @comment node-name, next, previous,up
|
|
2220
|
|
2221 @subsection Customizing Semi-colons and Commas
|
|
2222 @cindex Customizing Semi-colons and Commas
|
|
2223 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
2224
|
|
2225 @cindex customizing semi-colons and commas
|
|
2226 @vindex c-hanging-semi&comma-criteria
|
|
2227 @vindex hanging-semi&comma-criteria (c-)
|
|
2228 You can also customize the insertion of newlines after semi-colons and
|
|
2229 commas, when the auto-newline minor mode is enabled (see @ref{Minor
|
|
2230 Modes}). This is controlled by the variable
|
|
2231 @code{c-hanging-semi&comma-criteria}, which contains a list of functions
|
|
2232 that are called in the order they appear. Each function is called with
|
|
2233 zero arguments, and is expected to return one of the following values:
|
|
2234
|
|
2235 @itemize @bullet
|
|
2236 @item
|
2
|
2237 non-@code{nil} --- A newline is inserted, and no more functions from the
|
0
|
2238 list are called.
|
|
2239
|
|
2240 @item
|
2
|
2241 @code{stop} --- No more functions from the list are called, but no
|
0
|
2242 newline is inserted.
|
|
2243
|
|
2244 @item
|
2
|
2245 @code{nil} --- No determination is made, and the next function in the
|
0
|
2246 list is called.
|
|
2247
|
|
2248 @end itemize
|
|
2249
|
|
2250 If every function in the list is called without a determination being
|
|
2251 made, then no newline is added. The default value for this variable is a
|
|
2252 list containing a single function which inserts newlines only after
|
|
2253 semi-colons which do not appear inside parenthesis lists (i.e. those
|
|
2254 that separate @code{for}-clause statements).
|
|
2255
|
2
|
2256 Here's an example of a criteria function that will prevent newlines from
|
|
2257 being inserted after semicolons when there is a non-blank following
|
110
|
2258 line. Otherwise, it makes no determination. To use, add this to the
|
|
2259 front of the @code{c-hanging-semi&comma-criteria} list.
|
2
|
2260
|
|
2261 @example
|
|
2262 @group
|
|
2263
|
|
2264 (defun my-semicolon-criteria ()
|
|
2265 (save-excursion
|
177
|
2266 (if (and (eq last-command-char ?\;)
|
2
|
2267 (zerop (forward-line 1))
|
|
2268 (not (looking-at "^[ \t]*$")))
|
|
2269 'stop
|
|
2270 nil)))
|
|
2271
|
|
2272 @end group
|
|
2273 @end example
|
|
2274
|
|
2275
|
0
|
2276 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
2277 @node Other Special Indentations, , Customizing Semi-colons and Commas, Advanced Customizations
|
|
2278 @comment node-name, next, previous,up
|
|
2279
|
|
2280 @subsection Other Special Indentations
|
|
2281 @cindex Customizing Semi-colons and Commas
|
|
2282 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
2283
|
2
|
2284 @vindex c-label-minimum-indentation
|
|
2285 @vindex label-minimum-indentation (c-)
|
|
2286 In @samp{gnu} style (see @ref{Built-in Styles}), a minimum indentation
|
110
|
2287 is imposed on lines inside top-level constructs. This minimum
|
|
2288 indentation is controlled by the variable
|
2
|
2289 @code{c-label-minimum-indentation}. The default value for this variable
|
|
2290 is 1.
|
|
2291
|
0
|
2292 @vindex c-special-indent-hook
|
|
2293 @vindex special-indent-hook (c-)
|
110
|
2294 One other customization variable is available in @ccmode{}:
|
0
|
2295 @code{c-special-indent-hook}. This is a standard hook variable that is
|
110
|
2296 called after every line is indented by @ccmode{}. You can use it
|
0
|
2297 to do any special indentation or line adjustments your style dictates,
|
|
2298 such as adding extra indentation to constructors or destructor
|
|
2299 declarations in a class definition, etc. Note however, that you should
|
110
|
2300 not change point or mark inside your @code{c-special-indent-hook}
|
0
|
2301 functions (i.e. you'll probably want to wrap your function in a
|
|
2302 @code{save-excursion}).
|
|
2303
|
2
|
2304 Setting @code{c-special-indent-hook} in your style definition is handled
|
|
2305 slightly differently than other variables. In your style definition,
|
|
2306 you should set the value for
|
|
2307 @code{c-special-indent-hook} to a function or list of functions, which
|
|
2308 will be appended to @code{c-special-indent-hook} using @code{add-hook}.
|
|
2309 That way, the current setting for the buffer local value of
|
|
2310 @code{c-special-indent-hook} won't be overridden.
|
|
2311
|
175
|
2312 @kindex M-;
|
|
2313 @findex indent-for-comment
|
|
2314 @vindex c-indent-comments-syntactically-p
|
|
2315 @vindex indent-comments-syntactically-p (c-)
|
|
2316 @vindex comment-column
|
|
2317
|
|
2318 Normally, the standard Emacs command @kbd{M-;}
|
181
|
2319 (@code{indent-for-comment}) will indent comment only lines to
|
175
|
2320 @code{comment-column}. Some users however, prefer that @kbd{M-;} act
|
|
2321 just like @kbd{TAB} for purposes of indenting comment-only lines;
|
|
2322 i.e. they want the comments to always indent as they would for normal
|
|
2323 code, regardless of whether @kbd{TAB} or @kbd{M-;} were used. This
|
|
2324 behavior is controlled by the variable
|
|
2325 @code{c-indent-comments-syntactically-p}. When @code{nil} (the
|
|
2326 default), @kbd{M-;} indents comment-only lines to @code{comment-column},
|
|
2327 otherwise, they are indented just as they would be if @kbd{TAB} were
|
|
2328 typed.
|
0
|
2329
|
|
2330 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
2331 @node Syntactic Symbols, Performance Issues, Customizing Indentation, Top
|
|
2332 @comment node-name, next, previous,up
|
|
2333
|
|
2334 @chapter Syntactic Symbols
|
|
2335 @cindex Syntactic Symbols
|
|
2336 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
2337
|
|
2338 @vindex c-offsets-alist
|
|
2339 @vindex offsets-alist (c-)
|
2
|
2340
|
|
2341 Here is a complete list of the recognized syntactic symbols as described
|
|
2342 in the @code{c-offsets-alist} variable, along with a brief description.
|
|
2343 More detailed descriptions follow below.
|
|
2344
|
|
2345 @itemize @bullet
|
|
2346 @item
|
|
2347 @code{string} --- inside multi-line string
|
|
2348 @item
|
|
2349 @code{c} --- inside a multi-line C style block comment
|
|
2350 @item
|
|
2351 @code{defun-open} --- brace that opens a function definition
|
|
2352 @item
|
|
2353 @code{defun-close} --- brace that closes a function definition
|
|
2354 @item
|
|
2355 @code{defun-block-intro} --- the first line in a top-level defun
|
|
2356 @item
|
|
2357 @code{class-open} --- brace that opens a class definition
|
|
2358 @item
|
|
2359 @code{class-close} --- brace that closes a class definition
|
|
2360 @item
|
|
2361 @code{inline-open} --- brace that opens an in-class inline method
|
|
2362 @item
|
|
2363 @code{inline-close} --- brace that closes an in-class inline method
|
|
2364 @item
|
165
|
2365 @code{func-decl-cont} --- the region between a function definition's
|
|
2366 argument list and the function opening brace (excluding K&R argument
|
|
2367 declarations). In C, you cannot put anything but whitespace and comments
|
|
2368 between them; in C++ and Java, @code{throws} declarations and other
|
|
2369 things can appear in this context.
|
2
|
2370 @item
|
|
2371 @code{knr-argdecl-intro} --- first line of a K&R C argument declaration
|
|
2372 @item
|
|
2373 @code{knr-argdecl} --- subsequent lines in a K&R C argument declaration
|
|
2374 @item
|
110
|
2375 @code{topmost-intro} --- the first line in a topmost definition
|
2
|
2376 @item
|
|
2377 @code{topmost-intro-cont} --- topmost definition continuation lines
|
|
2378 @item
|
|
2379 @code{member-init-intro} --- first line in a member initialization list
|
|
2380 @item
|
|
2381 @code{member-init-cont} --- subsequent member initialization list lines
|
|
2382 @item
|
|
2383 @code{inher-intro} --- first line of a multiple inheritance list
|
|
2384 @item
|
|
2385 @code{inher-cont} --- subsequent multiple inheritance lines
|
|
2386 @item
|
|
2387 @code{block-open} --- statement block open brace
|
|
2388 @item
|
|
2389 @code{block-close} --- statement block close brace
|
|
2390 @item
|
|
2391 @code{brace-list-open} --- open brace of an enum or static array list
|
|
2392 @item
|
|
2393 @code{brace-list-close} --- close brace of an enum or static array list
|
|
2394 @item
|
|
2395 @code{brace-list-intro} --- first line in an enum or static array list
|
|
2396 @item
|
|
2397 @code{brace-list-entry} --- subsequent lines in an enum or static array list
|
|
2398 @item
|
110
|
2399 @code{statement} --- a C statement
|
2
|
2400 @item
|
110
|
2401 @code{statement-cont} --- a continuation of a C statement
|
2
|
2402 @item
|
|
2403 @code{statement-block-intro} --- the first line in a new statement block
|
|
2404 @item
|
|
2405 @code{statement-case-intro} --- the first line in a case `block'
|
|
2406 @item
|
|
2407 @code{statement-case-open} --- the first line in a case block starting
|
|
2408 with brace
|
|
2409 @item
|
110
|
2410 @code{substatement} --- the first line after a conditional
|
2
|
2411 @item
|
|
2412 @code{substatement-open} --- the brace that opens a substatement block
|
|
2413 @item
|
|
2414 @code{case-label} --- a case or default label
|
|
2415 @item
|
110
|
2416 @code{access-label} --- C++ access control label
|
2
|
2417 @item
|
110
|
2418 @code{label} --- any non-special C label
|
2
|
2419 @item
|
110
|
2420 @code{do-while-closure} --- the `while' that ends a
|
|
2421 @code{do}-@code{while} construct
|
2
|
2422 @item
|
110
|
2423 @code{else-clause} --- the `else' of an @code{if}-@code{else} construct
|
2
|
2424 @item
|
|
2425 @code{comment-intro} --- a line containing only a comment introduction
|
|
2426 @item
|
|
2427 @code{arglist-intro} --- the first line in an argument list
|
|
2428 @item
|
|
2429 @code{arglist-cont} --- subsequent argument list lines when no arguments
|
|
2430 follow on the same line as the the arglist opening paren
|
|
2431 @item
|
|
2432 @code{arglist-cont-nonempty} --- subsequent argument list lines when at
|
|
2433 least one argument follows on the same line as the arglist opening paren
|
|
2434 @item
|
|
2435 @code{arglist-close} --- the solo close paren of an argument list
|
|
2436 @item
|
110
|
2437 @code{stream-op} --- lines continuing a stream operator
|
2
|
2438 @item
|
110
|
2439 @code{inclass} --- the line is nested inside a class definition
|
2
|
2440 @item
|
|
2441 @code{cpp-macro} --- the start of a cpp macro
|
|
2442 @item
|
|
2443 @code{friend} --- a C++ friend declaration
|
|
2444 @item
|
|
2445 @code{objc-method-intro} --- the first line of an Objective-C method definition
|
|
2446 @item
|
|
2447 @code{objc-method-args-cont} --- lines continuing an Objective-C method
|
|
2448 definition
|
|
2449 @item
|
|
2450 @code{objc-method-call-cont} --- lines continuing an Objective-C method call
|
|
2451 @item
|
|
2452 @code{extern-lang-open} --- brace that opens an external language block
|
|
2453 @item
|
|
2454 @code{extern-lang-close} --- brace that closes an external language block
|
|
2455 @item
|
110
|
2456 @code{inextern-lang} --- analogous to `inclass' syntactic symbol, but
|
|
2457 for @code{extern} blocks.
|
181
|
2458 @item
|
|
2459 @code{template-args-cont} --- C++ template argument list continuations
|
2
|
2460 @end itemize
|
0
|
2461
|
|
2462 @cindex -open syntactic symbols
|
|
2463 @cindex -close syntactic symbols
|
|
2464 Most syntactic symbol names follow a general naming convention. When a
|
|
2465 line begins with an open or close brace, the syntactic symbol will
|
|
2466 contain the suffix @code{-open} or @code{-close} respectively.
|
|
2467
|
|
2468 @cindex -intro syntactic symbols
|
|
2469 @cindex -cont syntactic symbols
|
|
2470 @cindex -block-intro syntactic symbols
|
|
2471 Usually, a distinction is made between the first line that introduces a
|
|
2472 construct and lines that continue a construct, and the syntactic symbols
|
|
2473 that represent these lines will contain the suffix @code{-intro} or
|
|
2474 @code{-cont} respectively. As a sub-classification of this scheme, a
|
|
2475 line which is the first of a particular brace block construct will
|
|
2476 contain the suffix @code{-block-intro}.
|
|
2477
|
|
2478 @kindex C-c C-s
|
|
2479 Let's look at some examples to understand how this works. Remember that
|
|
2480 you can check the syntax of any line by using @kbd{C-c C-s}.
|
|
2481 @example
|
|
2482 @group
|
|
2483
|
|
2484 1: void
|
|
2485 2: swap( int& a, int& b )
|
|
2486 3: @{
|
|
2487 4: int tmp = a;
|
|
2488 5: a = b;
|
|
2489 6: b = tmp;
|
|
2490 7: int ignored =
|
|
2491 8: a + b;
|
|
2492 9: @}
|
|
2493
|
|
2494 @end group
|
|
2495 @end example
|
|
2496
|
2
|
2497 @cindex topmost-intro syntactic symbol
|
|
2498 @cindex topmost-intro-cont syntactic symbol
|
|
2499 @cindex defun-open syntactic symbol
|
|
2500 @cindex defun-close syntactic symbol
|
|
2501 @cindex defun-block-intro syntactic symbol
|
0
|
2502 Line 1 shows a @code{topmost-intro} since it is the first line that
|
|
2503 introduces a top-level construct. Line 2 is a continuation of the
|
|
2504 top-level construct introduction so it has the syntax
|
|
2505 @code{topmost-intro-cont}. Line 3 shows a @code{defun-open} since it is
|
|
2506 the brace that opens a top-level function definition. Line 9 is a
|
|
2507 @code{defun-close} since it contains the brace that closes the top-level
|
|
2508 function definition. Line 4 is a @code{defun-block-intro}, i.e. it is
|
177
|
2509 the first line of a brace-block, enclosed in a
|
0
|
2510 top-level function definition.
|
|
2511
|
2
|
2512 @cindex statement syntactic symbol
|
|
2513 @cindex statement-cont syntactic symbol
|
0
|
2514 Lines 5, 6, and 7 are all given @code{statement} syntax since there
|
|
2515 isn't much special about them. Note however that line 8 is given
|
|
2516 @code{statement-cont} syntax since it continues the statement begun
|
|
2517 on the previous line.
|
|
2518
|
|
2519 Here's another example, which illustrates some C++ class syntactic
|
|
2520 symbols:
|
|
2521 @example
|
|
2522 @group
|
|
2523
|
|
2524 1: class Bass
|
|
2525 2: : public Guitar,
|
|
2526 3: public Amplifiable
|
|
2527 4: @{
|
|
2528 5: public:
|
|
2529 6: Bass()
|
|
2530 7: : eString( new BassString( 0.105 )),
|
|
2531 8: aString( new BassString( 0.085 )),
|
|
2532 9: dString( new BassString( 0.065 )),
|
|
2533 10: gString( new BassString( 0.045 ))
|
|
2534 11: @{
|
|
2535 12: eString.tune( 'E' );
|
|
2536 13: aString.tune( 'A' );
|
|
2537 14: dString.tune( 'D' );
|
|
2538 15: gString.tune( 'G' );
|
|
2539 16: @}
|
2
|
2540 17: friend class Luthier;
|
|
2541 18: @}
|
0
|
2542
|
|
2543 @end group
|
|
2544 @end example
|
|
2545
|
2
|
2546 @cindex class-open syntactic symbol
|
|
2547 @cindex class-close syntactic symbol
|
0
|
2548 As in the previous example, line 1 has the @code{topmost-intro} syntax.
|
|
2549 Here however, the brace that opens a C++ class definition on line 4 is
|
2
|
2550 assigned the @code{class-open} syntax. Note that in C++, classes,
|
|
2551 structs, and unions are essentially equivalent syntactically (and are
|
|
2552 very similar semantically), so replacing the @code{class} keyword in the
|
|
2553 example above with @code{struct} or @code{union} would still result in a
|
|
2554 syntax of @code{class-open} for line 4 @footnote{This is the case even
|
|
2555 for C and Objective-C. For consistency, structs in all supported
|
|
2556 languages are syntactically equivalent to classes. Note however that
|
|
2557 the keyword @code{class} is meaningless in C and Objective-C.}.
|
|
2558 Similarly, line 18 is assigned @code{class-close} syntax.
|
|
2559
|
|
2560 @cindex inher-intro syntactic symbol
|
|
2561 @cindex inher-cont syntactic symbol
|
0
|
2562 Line 2 introduces the inheritance list for the class so it is assigned
|
|
2563 the @code{inher-intro} syntax, and line 3, which continues the
|
|
2564 inheritance list is given @code{inher-cont} syntax.
|
|
2565
|
2
|
2566 @cindex access-label syntactic symbol
|
|
2567 @cindex inclass syntactic symbol
|
|
2568 Hitting @kbd{C-c C-s} on line 5 shows the following analysis:
|
|
2569
|
|
2570 @example
|
|
2571 @group
|
|
2572
|
|
2573 @code{((inclass . 1) (access-label . 67))}
|
|
2574
|
|
2575 @end group
|
|
2576 @end example
|
|
2577
|
|
2578 @noindent
|
|
2579 The primary syntactic symbol for this line is @code{access-label} as
|
|
2580 this a label keyword that specifies access protection in C++. However,
|
|
2581 because this line is also a top-level construct inside a class
|
|
2582 definition, the analysis actually shows two syntactic symbols. The
|
|
2583 other syntactic symbol assigned to this line is @code{inclass}.
|
|
2584 Similarly, line 6 is given both @code{inclass} and @code{topmost-intro}
|
|
2585 syntax:
|
|
2586
|
|
2587 @example
|
|
2588 @group
|
|
2589
|
|
2590 @code{((inclass . 58) (topmost-intro . 60))}
|
|
2591
|
|
2592 @end group
|
|
2593 @end example
|
|
2594
|
|
2595 @cindex member-init-intro syntactic symbol
|
|
2596 @cindex member-init-cont syntactic symbol
|
0
|
2597 Line 7 introduces a C++ member initialization list and as such is given
|
|
2598 @code{member-init-intro} syntax. Note that in this case it is
|
|
2599 @emph{not} assigned @code{inclass} since this is not considered a
|
|
2600 top-level construct. Lines 8 through 10 are all assigned
|
|
2601 @code{member-init-cont} since they continue the member initialization
|
|
2602 list started on line 7.
|
|
2603
|
|
2604 @cindex in-class inline methods
|
2
|
2605 @cindex inline-open syntactic symbol
|
|
2606 @cindex inline-close syntactic symbol
|
177
|
2607 Line 11's analysis is a bit more complicated:
|
2
|
2608
|
|
2609 @example
|
|
2610 @group
|
|
2611
|
|
2612 @code{((inclass . 1) (inline-open))}
|
|
2613
|
|
2614 @end group
|
|
2615 @end example
|
|
2616
|
|
2617 This line is assigned a syntax of both @code{inline-open} and
|
|
2618 @code{inclass} because it opens an @dfn{in-class} C++ inline method
|
|
2619 definition. This is distinct from, but related to, the C++ notion of an
|
|
2620 inline function in that its definition occurs inside an enclosing class
|
|
2621 definition, which in C++ implies that the function should be inlined.
|
177
|
2622 If though, the definition of the @code{Bass} constructor appeared
|
|
2623 outside the class definition, the construct would be given the
|
2
|
2624 @code{defun-open} syntax, even if the keyword @code{inline} appeared
|
|
2625 before the method name, as in:
|
0
|
2626 @example
|
|
2627 @group
|
|
2628
|
|
2629 class Bass
|
|
2630 : public Guitar,
|
|
2631 public Amplifiable
|
|
2632 @{
|
|
2633 public:
|
|
2634 Bass();
|
|
2635 @}
|
|
2636
|
|
2637 inline
|
|
2638 Bass::Bass()
|
|
2639 : eString( new BassString( 0.105 )),
|
|
2640 aString( new BassString( 0.085 )),
|
|
2641 dString( new BassString( 0.065 )),
|
|
2642 gString( new BassString( 0.045 ))
|
|
2643 @{
|
|
2644 eString.tune( 'E' );
|
|
2645 aString.tune( 'A' );
|
|
2646 dString.tune( 'D' );
|
|
2647 gString.tune( 'G' );
|
|
2648 @}
|
|
2649
|
|
2650 @end group
|
|
2651 @end example
|
|
2652
|
2
|
2653 @cindex friend syntactic symbol
|
|
2654 Returning to the previous example, line 16 is given @code{inline-close}
|
|
2655 syntax, while line 12 is given @code{defun-block-open} syntax, and lines
|
|
2656 13 through 15 are all given @code{statement} syntax. Line 17 is
|
165
|
2657 interesting in that its syntactic analysis list contains three
|
2
|
2658 elements:
|
|
2659
|
|
2660 @example
|
|
2661
|
|
2662 @code{((friend) (inclass . 58) (topmost-intro . 380))}
|
|
2663
|
|
2664 @end example
|
|
2665
|
|
2666 The @code{friend} syntactic symbol is a modifier that typically does not
|
|
2667 have a relative buffer position.
|
0
|
2668
|
181
|
2669 Template definitions introduce yet another syntactic symbol:
|
|
2670
|
|
2671 @example
|
|
2672 @group
|
|
2673
|
|
2674 1: ThingManager <int,
|
|
2675 2: Framework::Callback *,
|
|
2676 3: Mutex> framework_callbacks;
|
|
2677
|
|
2678 @end group
|
|
2679 @end example
|
|
2680
|
|
2681 Here, line 1 is analyzed as a @code{topmost-intro}, but lines 2 and 3
|
|
2682 are both analyzed as @code{template-args-cont} lines.
|
|
2683
|
0
|
2684 Here is another (totally contrived) example which illustrates how syntax
|
|
2685 is assigned to various conditional constructs:
|
|
2686 @example
|
|
2687 @group
|
|
2688
|
|
2689 1: void spam( int index )
|
|
2690 2: @{
|
|
2691 3: for( int i=0; i<index; i++ )
|
|
2692 4: @{
|
|
2693 5: if( i == 10 )
|
|
2694 6: @{
|
|
2695 7: do_something_special();
|
|
2696 8: @}
|
|
2697 9: else
|
|
2698 10: do_something( i );
|
|
2699 11: @}
|
|
2700 12: do @{
|
|
2701 13: another_thing( i-- );
|
|
2702 14: @}
|
|
2703 15: while( i > 0 );
|
|
2704 16: @}
|
|
2705
|
|
2706
|
|
2707 @end group
|
|
2708 @end example
|
|
2709
|
|
2710 @noindent
|
|
2711 Only the lines that illustrate new syntactic symbols will be discussed.
|
|
2712
|
2
|
2713 @cindex substatement-open syntactic symbol
|
|
2714 @cindex substatement-block-intro syntactic symbol
|
|
2715 @cindex block-close syntactic symbol
|
0
|
2716 Line 4 has a brace which opens a conditional's substatement block. It
|
|
2717 is thus assigned @code{substatement-open} syntax, and since line 5 is
|
|
2718 the first line in the substatement block, it is assigned
|
|
2719 @code{substatement-block-intro} syntax. Lines 6 and 7 are assigned
|
|
2720 similar syntax. Line 8 contains the brace that closes the inner
|
2
|
2721 substatement block. It is given the syntax @code{block-close},
|
0
|
2722 as are lines 11 and 14.
|
|
2723
|
2
|
2724 @cindex else-clause syntactic symbol
|
|
2725 @cindex substatement syntactic symbol
|
|
2726 Line 9 is a little different --- since it contains the keyword
|
|
2727 @code{else} matching the @code{if} statement introduced on line 5, it is
|
0
|
2728 given the @code{else-clause} syntax. Note also that line 10 is slightly
|
|
2729 different too. Because @code{else} is considered a conditional
|
|
2730 introducing keyword @footnote{The list of conditional keywords are (in
|
2
|
2731 C, C++, Objective-C, and Java): @code{for}, @code{if}, @code{do},
|
|
2732 @code{else}, @code{while}, and @code{switch}. C++ and Java have two
|
|
2733 additional conditional keywords: @code{try} and @code{catch}. Java also
|
|
2734 has the @code{finally} and @code{synchronized} keywords.}, and because
|
|
2735 the following substatement is not a brace block, line 10 is assigned the
|
0
|
2736 @code{substatement} syntax.
|
|
2737
|
2
|
2738 @cindex do-while-closure syntactic symbol
|
0
|
2739 One other difference is seen on line 15. The @code{while} construct
|
|
2740 that closes a @code{do} conditional is given the special syntax
|
|
2741 @code{do-while-closure} if it appears on a line by itself. Note that if
|
|
2742 the @code{while} appeared on the same line as the preceding close brace,
|
|
2743 that line would have been assigned @code{block-close} syntax instead.
|
|
2744
|
|
2745 Switch statements have their own set of syntactic symbols. Here's an
|
|
2746 example:
|
|
2747 @example
|
|
2748 @group
|
|
2749
|
|
2750 1: void spam( enum Ingredient i )
|
|
2751 2: @{
|
|
2752 3: switch( i ) @{
|
|
2753 4: case Ham:
|
|
2754 5: be_a_pig();
|
|
2755 6: break;
|
|
2756 7: case Salt:
|
|
2757 8: drink_some_water();
|
|
2758 9: break;
|
|
2759 10: default:
|
|
2760 11: @{
|
|
2761 12: what_is_it();
|
|
2762 13: break;
|
|
2763 14: @}
|
|
2764 15: @}
|
|
2765 14: @}
|
|
2766
|
|
2767 @end group
|
|
2768 @end example
|
|
2769
|
2
|
2770 @cindex case-label syntactic symbol
|
|
2771 @cindex statement-case-intro syntactic symbol
|
|
2772 @cindex statement-case-open syntactic symbol
|
0
|
2773 Here, lines 4, 7, and 10 are all assigned @code{case-label} syntax,
|
|
2774 while lines 5 and 8 are assigned @code{statement-case-intro}. Line 11
|
|
2775 is treated slightly differently since it contains a brace that opens a
|
2
|
2776 block --- it is given @code{statement-case-open} syntax.
|
0
|
2777
|
|
2778 @cindex brace lists
|
|
2779 There are a set of syntactic symbols that are used to recognize
|
|
2780 constructs inside of brace lists. A brace list is defined as an
|
|
2781 @code{enum} or aggregate initializer list, such as might statically
|
|
2782 initialize an array of structs. For example:
|
|
2783 @example
|
|
2784 @group
|
|
2785
|
|
2786 1: static char* ingredients[] =
|
|
2787 2: @{
|
|
2788 3: "Ham",
|
|
2789 4: "Salt",
|
|
2790 5: NULL
|
|
2791 6: @}
|
|
2792
|
|
2793 @end group
|
|
2794 @end example
|
|
2795
|
2
|
2796 @cindex brace-list-open syntactic symbol
|
|
2797 @cindex brace-list-intro syntactic symbol
|
|
2798 @cindex brace-list-close syntactic symbol
|
|
2799 @cindex brace-list-entry syntactic symbol
|
0
|
2800 Following convention, line 2 in this example is assigned
|
|
2801 @code{brace-list-open} syntax, and line 3 is assigned
|
|
2802 @code{brace-list-intro} syntax. Likewise, line 6 is assigned
|
|
2803 @code{brace-list-close} syntax. Lines 4 and 5 however, are assigned
|
|
2804 @code{brace-list-entry} syntax, as would all subsequent lines in this
|
|
2805 initializer list.
|
|
2806
|
2
|
2807 External language definition blocks also have their own syntactic
|
|
2808 symbols. In this example:
|
|
2809 @example
|
|
2810 @group
|
|
2811
|
|
2812 1: extern "C"
|
|
2813 2: @{
|
|
2814 3: int thing_one( int );
|
|
2815 4: int thing_two( double );
|
|
2816 5: @}
|
|
2817
|
|
2818 @end group
|
|
2819 @end example
|
|
2820
|
|
2821 @cindex extern-lang-open syntactic symbol
|
|
2822 @cindex extern-lang-close syntactic symbol
|
|
2823 @cindex inextern-lang syntactic symbol
|
|
2824 @cindex inclass syntactic symbol
|
|
2825 @noindent
|
|
2826 line 2 is given the @code{extern-lang-open} syntax while line 5 is given
|
|
2827 the @code{extern-lang-close} syntax. The analysis for line 3 yields:
|
|
2828 @code{((inextern-lang) (topmost-intro . 14))}, where
|
|
2829 @code{inextern-lang} is a modifier similar in purpose to @code{inclass}.
|
|
2830
|
0
|
2831 A number of syntactic symbols are associated with parenthesis lists,
|
|
2832 a.k.a argument lists, as found in function declarations and function
|
|
2833 calls. This example illustrates these:
|
|
2834 @example
|
|
2835 @group
|
|
2836
|
|
2837 1: void a_function( int line1,
|
|
2838 2: int line2 );
|
|
2839 3:
|
|
2840 4: void a_longer_function(
|
|
2841 5: int line1,
|
|
2842 6: int line2
|
|
2843 7: );
|
|
2844 8:
|
|
2845 9: void call_them( int line1, int line2 )
|
|
2846 10: @{
|
|
2847 11: a_function(
|
|
2848 12: line1,
|
|
2849 13: line2
|
|
2850 14: );
|
|
2851 15:
|
|
2852 16: a_longer_function( line1,
|
|
2853 17: line2 );
|
|
2854 18: @}
|
|
2855
|
|
2856 @end group
|
|
2857 @end example
|
|
2858
|
2
|
2859 @cindex arglist-intro syntactic symbol
|
|
2860 @cindex arglist-close syntactic symbol
|
0
|
2861 Lines 5 and 12 are assigned @code{arglist-intro} syntax since they are
|
|
2862 the first line following the open parenthesis, and lines 7 and 14 are
|
|
2863 assigned @code{arglist-close} syntax since they contain the parenthesis
|
|
2864 that closes the argument list.
|
|
2865
|
2
|
2866 @cindex arglist-cont-nonempty syntactic symbol
|
|
2867 @cindex arglist-cont syntactic symbol
|
|
2868 Lines that continue argument lists can be assigned one of two syntactic
|
|
2869 symbols. For example, Lines 2 and 17
|
|
2870 are assigned @code{arglist-cont-nonempty} syntax. What this means
|
0
|
2871 is that they continue an argument list, but that the line containing the
|
2
|
2872 parenthesis that opens the list is @emph{not empty} following the open
|
0
|
2873 parenthesis. Contrast this against lines 6 and 13 which are assigned
|
|
2874 @code{arglist-cont} syntax. This is because the parenthesis that opens
|
110
|
2875 their argument lists is the last character on that line.
|
0
|
2876
|
|
2877 Note that there is no @code{arglist-open} syntax. This is because any
|
|
2878 parenthesis that opens an argument list, appearing on a separate line,
|
|
2879 is assigned the @code{statement-cont} syntax instead.
|
|
2880
|
|
2881 A few miscellaneous syntactic symbols that haven't been previously
|
110
|
2882 covered are illustrated by this C++ example:
|
0
|
2883 @example
|
|
2884 @group
|
|
2885
|
|
2886 1: void Bass::play( int volume )
|
|
2887 2: const
|
|
2888 3: @{
|
|
2889 4: /* this line starts a multi-line
|
|
2890 5: * comment. This line should get `c' syntax */
|
|
2891 6:
|
110
|
2892 7: char* a_multiline_string = "This line starts a multi-line \
|
0
|
2893 8: string. This line should get `string' syntax.";
|
|
2894 9:
|
|
2895 10: note:
|
|
2896 11: @{
|
|
2897 12: #ifdef LOCK
|
|
2898 13: Lock acquire();
|
|
2899 14: #endif // LOCK
|
|
2900 15: slap_pop();
|
|
2901 16: cout << "I played "
|
|
2902 17: << "a note\n";
|
|
2903 18: @}
|
|
2904 19: @}
|
|
2905
|
|
2906 @end group
|
|
2907 @end example
|
|
2908
|
|
2909 @cindex modifier syntactic symbol
|
|
2910 The lines to note in this example include:
|
|
2911
|
|
2912 @itemize @bullet
|
|
2913
|
110
|
2914 @cindex func-decl-cont syntactic symbol
|
0
|
2915 @item
|
110
|
2916 line 2, assigned the @code{func-decl-cont} syntax;
|
2
|
2917
|
|
2918 @cindex comment-intro syntactic symbol
|
0
|
2919 @item
|
2
|
2920 line 4, assigned both @code{defun-block-intro} @emph{and}
|
110
|
2921 @code{comment-intro} syntax;
|
2
|
2922
|
|
2923 @cindex c syntactic symbol
|
0
|
2924 @item
|
2
|
2925 line 5, assigned @code{c} syntax;
|
0
|
2926
|
|
2927 @item
|
|
2928 @cindex syntactic whitespace
|
|
2929 line 6 which, even though it contains nothing but whitespace, is
|
|
2930 assigned @code{defun-block-intro}. Note that the appearance of the
|
|
2931 comment on lines 4 and 5 do not cause line 6 to be assigned
|
|
2932 @code{statement} syntax because comments are considered to be
|
2
|
2933 @dfn{syntactic whitespace}, which are ignored when analyzing
|
0
|
2934 code;
|
|
2935
|
2
|
2936 @cindex string syntactic symbol
|
0
|
2937 @item
|
2
|
2938 line 8, assigned @code{string} syntax;
|
|
2939
|
|
2940 @cindex label syntactic symbol
|
0
|
2941 @item
|
2
|
2942 line 10, assigned @code{label} syntax;
|
|
2943
|
|
2944 @cindex block-open syntactic symbol
|
0
|
2945 @item
|
2
|
2946 line 11, assigned @code{block-open} syntax;
|
|
2947
|
|
2948 @cindex cpp-macro syntactic symbol
|
0
|
2949 @item
|
2
|
2950 lines 12 and 14, assigned @code{cpp-macro} syntax;
|
|
2951
|
|
2952 @cindex stream-op syntactic symbol
|
0
|
2953 @item
|
110
|
2954 line 17, assigned @code{stream-op} syntax.
|
0
|
2955
|
|
2956 @end itemize
|
|
2957
|
|
2958 In Objective-C buffers, there are three additional syntactic symbols
|
|
2959 assigned to various message calling constructs. Here's an example
|
|
2960 illustrating these:
|
|
2961 @example
|
|
2962 @group
|
|
2963
|
|
2964 1: - (void)setDelegate:anObject
|
|
2965 2: withStuff:stuff
|
|
2966 3: @{
|
|
2967 4: [delegate masterWillRebind:self
|
|
2968 5: toDelegate:anObject
|
|
2969 6: withExtraStuff:stuff];
|
|
2970 7: @}
|
|
2971
|
|
2972 @end group
|
|
2973 @end example
|
|
2974
|
2
|
2975 @cindex objc-method-intro syntactic symbol
|
|
2976 @cindex objc-method-args-cont syntactic symbol
|
|
2977 @cindex objc-method-call-cont syntactic symbol
|
0
|
2978 Here, line 1 is assigned @code{objc-method-intro} syntax, and line 2 is
|
|
2979 assigned @code{objc-method-args-cont} syntax. Lines 5 and 6 are both
|
|
2980 assigned @code{objc-method-call-cont} syntax.
|
|
2981
|
2
|
2982 @cindex knr-argdecl-intro
|
|
2983 @cindex knr-argdecl
|
|
2984 Two other syntactic symbols can appear in old style, non-prototyped C
|
|
2985 code @footnote{a.k.a. K&R C, or Kernighan & Ritchie C}:
|
|
2986 @example
|
|
2987 @group
|
|
2988
|
|
2989 1: int add_three_integers(a, b, c)
|
|
2990 2: int a;
|
|
2991 3: int b;
|
|
2992 4: int c;
|
|
2993 5: @{
|
|
2994 6: return a + b + c;
|
|
2995 7: @}
|
|
2996
|
|
2997 @end group
|
|
2998 @end example
|
|
2999
|
|
3000 Here, line 2 is the first line in an argument declaration list and so is
|
|
3001 given the @code{knr-argdecl-intro} syntactic symbol. Subsequent lines
|
|
3002 (i.e. lines 3 and 4 in this example), are given @code{knr-argdecl}
|
|
3003 syntax.
|
0
|
3004
|
|
3005 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
3006 @node Performance Issues, Frequently Asked Questions, Syntactic Symbols, Top
|
|
3007 @comment node-name, next, previous,up
|
|
3008
|
|
3009 @chapter Performance Issues
|
|
3010 @cindex Performance Issues
|
|
3011 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
3012
|
165
|
3013 C and its derivative languages are highly complex creatures. Often,
|
110
|
3014 ambiguous code situations arise that require @ccmode{} to scan
|
2
|
3015 large portions of the buffer to determine syntactic context. Such
|
|
3016 pathological code@footnote{such as the output of @code{lex(1)}!}
|
110
|
3017 can cause @ccmode{} to perform fairly badly.
|
0
|
3018 This section identifies some of the coding styles to watch out for, and
|
|
3019 suggests some workarounds that you can use to improve performance.
|
|
3020
|
110
|
3021 Because @ccmode{} has to scan the buffer backwards from the current
|
0
|
3022 insertion point, and because C's syntax is fairly difficult to parse in
|
110
|
3023 the backwards direction, @ccmode{} often tries to find the nearest
|
0
|
3024 position higher up in the buffer from which to begin a forward scan.
|
|
3025 The farther this position is from the current insertion point, the
|
110
|
3026 slower the mode gets. Some coding styles can even force @ccmode{}
|
177
|
3027 to scan from the beginning of the buffer for every line of code!
|
0
|
3028
|
|
3029 @findex beginning-of-defun
|
|
3030 @findex defun-prompt-regexp
|
|
3031 One of the simplest things you can do to reduce scan time, is make sure
|
|
3032 any brace that opens a top-level block construct always appears in the
|
|
3033 leftmost column. This is actually an Emacs constraint, as embodied in
|
110
|
3034 the @code{beginning-of-defun} function which @ccmode{} uses
|
0
|
3035 heavily. If you insist on hanging top-level open braces on the right
|
|
3036 side of the line, then you should set the variable
|
|
3037 @code{defun-prompt-regexp} to something reasonable @footnote{Note that
|
|
3038 this variable is only defined in Emacs 19.}, however that ``something
|
110
|
3039 reasonable'' is difficult to define, so @ccmode{} doesn't do it
|
0
|
3040 for you.
|
|
3041
|
110
|
3042 @vindex c-Java-defun-prompt-regexp
|
|
3043 @vindex Java-defun-prompt-regexp (c-)
|
|
3044 A special note about @code{defun-prompt-regexp} in Java mode: while much
|
|
3045 of the early sample Java code seems to encourage a style where the brace
|
|
3046 that opens a class is hung on the right side of the line, this is not a
|
|
3047 good style to pursue in Emacs. @ccmode{} comes with a variable
|
|
3048 @code{c-Java-defun-prompt-regexp} which tries to define a regular
|
|
3049 expression usable for this style, but there are problems with it. In
|
|
3050 some cases it can cause @code{beginning-of-defun} to hang@footnote{This
|
|
3051 has been observed in Emacs 19.34 and XEmacs 19.15.}. For this reason,
|
|
3052 it is not used by default, but if you feel adventurous, you can set
|
|
3053 @code{defun-prompt-regexp} to it in your mode hook. In any event,
|
|
3054 setting and rely on @code{defun-prompt-regexp} will definitely slow
|
|
3055 things down!
|
|
3056
|
|
3057 You will probably notice pathological behavior from @ccmode{} when
|
0
|
3058 working in files containing large amounts of cpp macros. This is
|
177
|
3059 because Emacs cannot be made to quickly skip backwards over these lines.
|
0
|
3060
|
|
3061 @vindex c-recognize-knr-p
|
|
3062 @vindex recognize-knr-p (c-)
|
110
|
3063 Previous versions of @ccmode{} had potential performance problems
|
|
3064 when recognizing K&R style function argument declarations. This was
|
2
|
3065 because there are ambiguities in the C syntax when K&R style argument
|
110
|
3066 lists are used@footnote{It is hard to distinguish them from top-level
|
|
3067 declarations.}. @ccmode{} has adopted BOCM's convention for
|
2
|
3068 limiting the search: it assumes that argdecls are indented at least one
|
|
3069 space, and that the function headers are not indented at all. With
|
110
|
3070 current versions of @ccmode{}, user customization of
|
|
3071 @code{c-recognize-knr-p} is deprecated. Just don't put argdecls in
|
|
3072 column zero!
|
2
|
3073
|
|
3074 @cindex @file{cc-lobotomy.el} file
|
0
|
3075 @vindex cc-lobotomy-pith-list
|
110
|
3076 You might want to investigate the speed-ups contained in the
|
165
|
3077 file @file{cc-lobotomy.el}, which comes as part of the @ccmode{}
|
|
3078 distribution, but is completely unsupported.
|
110
|
3079 As mentioned previous, @ccmode{} always trades accuracy for speed,
|
|
3080 however it is recognized that sometimes you need speed and can sacrifice
|
|
3081 some accuracy in indentation. The file @file{cc-lobotomy.el} contains
|
|
3082 hacks that will ``dumb down'' @ccmode{} in some specific ways, making
|
|
3083 that trade-off of speed for accuracy. I won't go into details of its
|
|
3084 use here; you should read the comments at the top of the file, and look
|
|
3085 at the variable @code{cc-lobotomy-pith-list} for details.
|
0
|
3086
|
|
3087
|
|
3088 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
110
|
3089 @node Frequently Asked Questions, Getting the latest CC Mode release, Performance Issues, Top
|
0
|
3090 @comment node-name, next, previous,up
|
|
3091
|
|
3092 @chapter Frequently Asked Questions
|
|
3093 @cindex Frequently Asked Questions
|
2
|
3094 @comment FAQ
|
0
|
3095 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
3096
|
|
3097 @kindex C-x h
|
|
3098 @kindex ESC C-\
|
|
3099 @kindex ESC C-x
|
|
3100 @kindex C-c C-q
|
|
3101 @kindex ESC C-q
|
|
3102 @kindex ESC C-u
|
|
3103 @kindex RET
|
165
|
3104 @kindex C-j
|
0
|
3105 @findex newline-and-indent
|
|
3106 @quotation
|
|
3107
|
|
3108 @strong{Q.} @emph{How do I re-indent the whole file?}
|
|
3109
|
|
3110 @strong{A.} Visit the file and hit @kbd{C-x h} to mark the whole
|
|
3111 buffer. Then hit @kbd{@key{ESC} C-\}.
|
2
|
3112 @sp 1
|
0
|
3113
|
|
3114 @strong{Q.} @emph{How do I re-indent the entire function?
|
|
3115 @kbd{@key{ESC} C-x} doesn't work.}
|
|
3116
|
|
3117 @strong{A.} @kbd{@key{ESC} C-x} is reserved for future Emacs use.
|
|
3118 To re-indent the entire function hit @kbd{C-c C-q}.
|
2
|
3119 @sp 1
|
0
|
3120
|
|
3121 @strong{Q.} @emph{How do I re-indent the current block?}
|
|
3122
|
|
3123 @strong{A.} First move to the brace which opens the block with
|
|
3124 @kbd{@key{ESC} C-u}, then re-indent that expression with
|
|
3125 @kbd{@key{ESC} C-q}.
|
2
|
3126 @sp 1
|
0
|
3127
|
|
3128 @strong{Q.} @emph{Why doesn't the @key{RET} key indent the line to
|
|
3129 where the new text should go after inserting the newline?}
|
|
3130
|
|
3131 @strong{A.} Emacs' convention is that @key{RET} just adds a newline,
|
165
|
3132 and that @key{C-j} adds a newline and indents it. You can make
|
0
|
3133 @key{RET} do this too by adding this to your
|
|
3134 @code{c-mode-common-hook} (see the sample @file{.emacs} file
|
|
3135 @ref{Sample .emacs File}):
|
|
3136 @example
|
|
3137
|
181
|
3138 (define-key c-mode-base-map "\C-m" 'newline-and-indent)
|
0
|
3139
|
|
3140 @end example
|
|
3141
|
110
|
3142 This is a very common question. If you want this to be the default
|
|
3143 behavior, don't lobby me, lobby RMS! @code{:-)}
|
2
|
3144 @sp 1
|
0
|
3145
|
|
3146 @strong{Q.} @emph{I put @code{(c-set-offset 'substatement-open 0)}
|
|
3147 in my @file{.emacs} file but I get an error saying that
|
|
3148 @code{c-set-offset}'s function definition is void.}
|
|
3149
|
110
|
3150 @strong{A.} This means that @ccmode{} wasn't loaded into your
|
0
|
3151 Emacs session by the time the @code{c-set-offset} call was reached,
|
110
|
3152 mostly likely because @ccmode{} is being autoloaded. Instead
|
0
|
3153 of putting the @code{c-set-offset} line in your top-level
|
|
3154 @file{.emacs} file, put it in your @code{c-mode-common-hook}, or
|
|
3155 simply add the following to the top of your @file{.emacs} file:
|
|
3156 @example
|
|
3157
|
|
3158 (require 'cc-mode)
|
|
3159
|
|
3160 @end example
|
|
3161
|
|
3162 See the sample @file{.emacs} file @ref{Sample .emacs File} for
|
|
3163 details.
|
|
3164
|
2
|
3165 @sp 1
|
0
|
3166 @strong{Q.} @emph{How do I make strings, comments, keywords, and other
|
|
3167 constructs appear in different colors, or in bold face, etc.?}
|
|
3168
|
177
|
3169 @strong{A.} ``Syntax Colorization'' is a standard Emacs feature,
|
|
3170 controlled by @code{font-lock-mode}. It is not part of @ccmode{}.
|
0
|
3171
|
|
3172 @end quotation
|
|
3173
|
|
3174
|
|
3175 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
110
|
3176 @node Getting the latest CC Mode release, Sample .emacs File, Frequently Asked Questions, Top
|
0
|
3177 @comment node-name, next, previous,up
|
|
3178
|
110
|
3179 @chapter Getting the latest CC Mode release
|
|
3180 @cindex Getting the latest CC Mode release
|
0
|
3181 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
3182
|
177
|
3183 @ccmode{} is now standard with later versions Emacs 19 and XEmacs 19.
|
|
3184 It is also the standard for XEmacs 20, and will be the standard for
|
|
3185 Emacs 20 (unreleased as of this writing). You would typically just use
|
|
3186 the version that comes with your X/Emacs. These may be slightly out of
|
|
3187 date due to release schedule skew, so you should always check the
|
|
3188 canonical site for the latest version.
|
0
|
3189
|
|
3190 @example
|
2
|
3191 @group
|
|
3192
|
|
3193 World Wide Web:
|
|
3194
|
|
3195 @code{http://www.python.org/ftp/emacs/}
|
|
3196
|
|
3197 Anonymous FTP:
|
|
3198
|
|
3199 @code{ftp://ftp.python.org/pub/emacs/}
|
|
3200
|
|
3201 @end group
|
0
|
3202 @end example
|
|
3203
|
2
|
3204 There are many files under these directories; you can pick up the entire
|
|
3205 distribution (named @code{cc-mode.tar.gz}; a gzip'd tar file), or any of
|
|
3206 the individual files, including PostScript documentation.
|
0
|
3207
|
110
|
3208 If you do not have World Wide Web, or anonymous ftp access, you can get
|
|
3209 the distribution through an anonymous ftp-to-mail gateway, such as the
|
|
3210 one run by DEC at:
|
|
3211 @example
|
|
3212
|
|
3213 @code{ftpmail@@decwrl.dec.com}
|
|
3214
|
|
3215 @end example
|
|
3216 To get @ccmode{} via email, send the following message in the body of
|
|
3217 your mail to that address:
|
0
|
3218 @example
|
|
3219
|
|
3220 reply <a valid net address back to you>
|
|
3221 connect ftp.python.org
|
|
3222 binary
|
|
3223 uuencode
|
|
3224 chdir pub/emacs
|
|
3225 get cc-mode.tar.gz
|
|
3226
|
|
3227 @end example
|
|
3228 @noindent
|
|
3229 or just send the message "help" for more information on ftpmail.
|
2
|
3230 Response times will vary with the number of requests in the queue. I am
|
|
3231 in no way connected to this service, so I make no claims or guarantees
|
|
3232 about its availability!
|
0
|
3233
|
|
3234 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
110
|
3235 @node Sample .emacs File, Limitations and Known Bugs, Getting the latest CC Mode release, Top
|
0
|
3236 @comment node-name, next, previous,up
|
|
3237
|
110
|
3238 @chapter Sample .emacs file
|
|
3239 @cindex Sample .emacs file
|
0
|
3240 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
3241
|
|
3242 @example
|
|
3243 ;; Here's a sample .emacs file that might help you along the way. Just
|
|
3244 ;; copy this region and paste it into your .emacs file. You may want to
|
|
3245 ;; change some of the actual values.
|
|
3246
|
|
3247 (defconst my-c-style
|
110
|
3248 '((c-tab-always-indent . t)
|
|
3249 (c-comment-only-line-offset . 4)
|
|
3250 (c-hanging-braces-alist . ((substatement-open after)
|
|
3251 (brace-list-open)))
|
|
3252 (c-hanging-colons-alist . ((member-init-intro before)
|
|
3253 (inher-intro)
|
|
3254 (case-label after)
|
|
3255 (label after)
|
|
3256 (access-label after)))
|
|
3257 (c-cleanup-list . (scope-operator
|
|
3258 empty-defun-braces
|
|
3259 defun-close-semi))
|
|
3260 (c-offsets-alist . ((arglist-close . c-lineup-arglist)
|
|
3261 (substatement-open . 0)
|
|
3262 (case-label . 4)
|
|
3263 (block-open . 0)
|
|
3264 (knr-argdecl-intro . -)))
|
0
|
3265 (c-echo-syntactic-information-p . t)
|
|
3266 )
|
|
3267 "My C Programming Style")
|
|
3268
|
|
3269 ;; Customizations for all of c-mode, c++-mode, and objc-mode
|
|
3270 (defun my-c-mode-common-hook ()
|
|
3271 ;; add my personal style and set it for the current buffer
|
|
3272 (c-add-style "PERSONAL" my-c-style t)
|
|
3273 ;; offset customizations not in my-c-style
|
|
3274 (c-set-offset 'member-init-intro '++)
|
|
3275 ;; other customizations
|
|
3276 (setq tab-width 8
|
|
3277 ;; this will make sure spaces are used instead of tabs
|
|
3278 indent-tabs-mode nil)
|
|
3279 ;; we like auto-newline and hungry-delete
|
|
3280 (c-toggle-auto-hungry-state 1)
|
2
|
3281 ;; keybindings for all supported languages. We can put these in
|
177
|
3282 ;; c-mode-base-map because c-mode-map, c++-mode-map, objc-mode-map,
|
|
3283 ;; java-mode-map, and idl-mode-map inherit from it.
|
|
3284 (define-key c-mode-base-map "\C-m" 'newline-and-indent)
|
0
|
3285 )
|
|
3286
|
|
3287 (add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
|
|
3288 @end example
|
|
3289
|
|
3290 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
2
|
3291 @node Limitations and Known Bugs, Mailing Lists and Submitting Bug Reports, Sample .emacs File, Top
|
0
|
3292 @comment node-name, next, previous,up
|
|
3293 @chapter Limitations and Known Bugs
|
|
3294 @cindex Limitations and Known Bugs
|
|
3295 @comment * Limitations and Known Bugs
|
|
3296 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
3297
|
|
3298 @itemize @bullet
|
|
3299 @item
|
|
3300 Multi-line macros are not handled properly.
|
|
3301
|
|
3302 @item
|
|
3303 Re-indenting large regions or expressions can be slow.
|
|
3304
|
|
3305 @item
|
110
|
3306 Add-on fill packages may not work as well as @ccmode{}'s built-in
|
|
3307 filling routines. I no longer recommend you use @code{filladapt} to
|
|
3308 fill comments.
|
2
|
3309
|
|
3310 @cindex c-indent-exp
|
|
3311 @cindex indent-exp (c-)
|
0
|
3312 @item
|
2
|
3313 @code{c-indent-exp} has not been fully optimized. It essentially
|
|
3314 equivalent to hitting @kbd{TAB} (@code{c-indent-command}) on every
|
|
3315 line. Some information is cached from line to line, but such caching
|
|
3316 invariable causes inaccuracies in analysis in some bizarre situations.
|
0
|
3317
|
|
3318 @end itemize
|
|
3319
|
|
3320 @c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
3321 @node Mailing Lists and Submitting Bug Reports, Concept Index, Limitations and Known Bugs, Top
|
|
3322 @comment node-name, next, previous,up
|
|
3323 @chapter Mailing Lists and Submitting Bug Reports
|
|
3324 @cindex Mailing Lists and Submitting Bug Reports
|
|
3325 @c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
3326
|
|
3327 @kindex C-c C-b
|
|
3328 @findex c-submit-bug-report
|
|
3329 @findex submit-bug-report (c-)
|
|
3330 @cindex beta testers mailing list
|
|
3331 @cindex announcement mailing list
|
|
3332 To report bugs, use the @kbd{C-c C-b} (@code{c-submit-bug-report})
|
|
3333 command. This provides vital information I need to reproduce your
|
|
3334 problem. Make sure you include a concise, but complete code example.
|
|
3335 Please try to boil your example down to just the essential code needed
|
|
3336 to reproduce the problem, and include an exact recipe of steps needed to
|
|
3337 expose the bug. Be especially sure to include any code that appears
|
2
|
3338 @emph{before} your bug example, if you think it might affect my ability
|
|
3339 to reproduce it.
|
|
3340
|
|
3341 Bug reports are now sent to the following email addresses:
|
|
3342 @code{cc-mode-help@@python.org} and
|
110
|
3343 @code{bug-gnu-emacs@@prep.ai.mit.edu}; the latter is mirrored on the
|
177
|
3344 Usenet newsgroup @code{gnu.emacs.bug}. You can send other questions and
|
|
3345 suggestions (kudos? @code{;-)} to @code{cc-mode-help@@python.org}, or
|
110
|
3346 @code{help-gnu-emacs@@prep.ai.mit.edu} which is mirrored on newsgroup
|
0
|
3347 @code{gnu.emacs.help}.
|
|
3348
|
177
|
3349 If you want to get announcements of new CC Mode releases, send the
|
|
3350 word @emph{subscribe} in the body of a message to
|
|
3351 @code{cc-mode-announce-request@@python.org}. Announcements will also be
|
|
3352 posted to the Usenet newsgroups @code{gnu.emacs.sources},
|
|
3353 @code{comp.emacs}, @code{comp.emacs.xemacs}, and possibly some of the
|
|
3354 language oriented newsgroups. Note that the
|
|
3355 @code{cc-mode-victims@@python.org} mailing list was recently
|
|
3356 decommissioned.
|
0
|
3357
|
|
3358 @c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
3359 @node Concept Index, Command Index, Mailing Lists and Submitting Bug Reports, Top
|
|
3360 @comment node-name, next, previous, up
|
|
3361 @unnumbered Concept Index
|
|
3362 @c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
3363
|
|
3364 @printindex cp
|
|
3365
|
|
3366
|
|
3367 @c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
3368 @node Command Index, Key Index, Concept Index, Top
|
|
3369 @comment node-name, next, previous, up
|
|
3370 @unnumbered Command Index
|
|
3371 @c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
3372
|
|
3373 @ifinfo
|
|
3374
|
|
3375 @end ifinfo
|
110
|
3376 Since all @ccmode{} commands are prepended with the string
|
2
|
3377 @samp{c-}, each appears under its @code{c-@var{<thing>}} name and its
|
|
3378 @code{@var{<thing>} (c-)} name.
|
0
|
3379 @iftex
|
|
3380 @sp 2
|
|
3381 @end iftex
|
|
3382 @printindex fn
|
|
3383
|
|
3384
|
|
3385 @c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
3386 @node Key Index, Variable Index, Command Index, Top
|
|
3387 @comment node-name, next, previous, up
|
|
3388 @unnumbered Key Index
|
|
3389 @c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
3390
|
|
3391 @printindex ky
|
|
3392
|
|
3393
|
|
3394 @c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
3395 @node Variable Index, , Key Index, Top
|
|
3396 @comment node-name, next, previous, up
|
|
3397 @unnumbered Variable Index
|
|
3398 @c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
3399
|
181
|
3400 @ifinfo
|
|
3401
|
|
3402 @end ifinfo
|
110
|
3403 Since all @ccmode{} variables are prepended with the string
|
2
|
3404 @samp{c-}, each appears under its @code{c-@var{<thing>}} name and its
|
|
3405 @code{@var{<thing>} (c-)} name.
|
0
|
3406 @iftex
|
|
3407 @sp 2
|
|
3408 @end iftex
|
|
3409 @printindex vr
|
181
|
3410 @page
|
0
|
3411 @summarycontents
|
|
3412 @contents
|
|
3413 @bye
|