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