annotate man/cc-mode.texi @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children ac2d302a0011
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 \input texinfo @c -*- texinfo -*-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 @comment %**start of header (This is for running Texinfo on a region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 @setfilename ../info/cc-mode.info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 @settitle CC-MODE Version 4 Documentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 @footnotestyle end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 @comment @setchapternewpage odd !! we don't want blank pages !!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 @comment %**end of header (This is for running Texinfo on a region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 @comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 @comment texinfo manual for @file{cc-mode.el} version 4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 @comment manual version: 2.35
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 @comment generated from the original README file by Krishna Padmasola
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 @comment <krishna@earth-gw.njit.edu>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 @comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 @comment Barry A. Warsaw <bwarsaw@cnri.reston.va.us>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 @comment Last modification: 1996/01/19 20:50:48
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 @comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 @comment The following line inserts the copyright notice
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 @comment into the Info file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 @ifinfo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 Copyright @copyright{} 1995 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 @end ifinfo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 @comment !!!The titlepage section does not appear in the Info file.!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 @titlepage
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 @sp 10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 @comment The title is printed in a large font.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 @center @titlefont{CC-MODE Version 4}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 @sp 2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 @center A GNU Emacs mode for editing C, C++, and Objective-C code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 @center (manual revision: 2.35)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 @sp 2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 @center Barry A. Warsaw
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 @comment The following two commands start the copyright page
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 @comment for the printed manual. This will not appear in the Info file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 @page
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 @vskip 0pt plus 1filll
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 Copyright @copyright{} 1995 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 @end titlepage
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 @comment The Top node contains the master menu for the Info file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 @comment This appears only in the Info file, not the printed manual.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 @node Top, Introduction, (dir), (dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 @comment node-name, next, previous, up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 * Introduction::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 * Getting Connected::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 * New Indentation Engine::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 * Minor Modes::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 * Indentation Commands::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 * Customizing Indentation::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 * Syntactic Symbols::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 * Performance Issues::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 * Frequently Asked Questions::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 * Getting the latest cc-mode release::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 * Sample .emacs File::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 * Requirements::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 * Limitations and Known Bugs::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 * Mailing Lists and Submitting Bug Reports::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 * Concept Index::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 * Command Index:: Command Index
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 * Key Index:: Key Index
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 * Variable Index:: Variable Index
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 @node Introduction, Getting Connected, Top, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 @comment node-name, next, previous, up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 @chapter Introduction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 @cindex Introduction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 @cindex BOCM
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 Welcome to @code{cc-mode}, version 4. This is a GNU Emacs mode for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 editing files containing C, C++, Objective-C, and Java code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 This incarnation of the mode is descendant from @file{c-mode.el} (also
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 called "Boring Old C Mode" or BOCM @code{:-)}, and @file{c++-mode.el}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 version 2, which I have been maintaining since 1992. @code{cc-mode}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 represents a significant milestone in the mode's life. It has been
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 fully merged back with Emacs 19's @file{c-mode.el}. Also a new, more
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 intuitive and flexible mechanism for controlling indentation has been
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 developed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 @code{cc-mode} version 4 supports the editing of K&R and ANSI C,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 @dfn{ARM} @footnote{i.e. ``The Annotated C++ Reference Manual'', by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 Ellis and Stroustrup.} C++, Objective-C, and Java files. In this way,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 you can easily set up consistent coding styles for use in editing all C,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 C++, Objective-C, and Java programs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 This manual will describe the following:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 @itemize @bullet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 How to get started using @code{cc-mode}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 How the new indentation engine works.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 How to customize the new indentation engine.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 @end itemize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 Note that the name of this file is @file{cc-mode.el}, and I'll often
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 refer to the package as @code{cc-mode}, but there really is no top level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 @code{cc-mode} entry point. I call it @code{cc-mode} simply to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 differentiate it from @file{c-mode.el}. All of the variables, commands,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 and functions in @code{cc-mode} are prefixed with @code{c-<thing>}, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 @code{c-mode}, @code{c++-mode}, @code{objc-mode}, and @code{java-mode}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 entry points are provided. This file is intended to be a replacement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 for @file{c-mode.el} and @file{c++-mode.el}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 @findex c-version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 The major version number was incremented to 4 with the addition of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 @code{objc-mode}. To find the minor revision number of this release, use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 @kbd{M-x c-version RET}. Work has already begun on @code{cc-mode}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 version 5, in which Emacs 18 will not be supported.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 As of this writing (19-Jan-1996), both Emacs 19.30 and XEmacs 19.13 are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 distributed with @code{cc-mode}. Emacs 19.31 and XEmacs 19.14 will both
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 contain the latest version of cc-mode when it is released. If you are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 running older versions of these Emacsen, you may want to upgrade your
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 copy of @code{cc-mode}. See @ref{Getting the latest cc-mode release}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 @cindex @file{cc-compat.el} file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 This distribution also contains a file called @file{cc-compat.el}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 which should ease your transition from BOCM to @code{cc-mode}. It
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 currently comes unguaranteed and unsupported, but this may change for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 future versions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 A special word of thanks goes to Krishna Padmasola for his work in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 converting the original @file{README} file to texinfo format.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 @code{cc-mode} users have been clamoring for a manual for a long time,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 and thanks to Krishna, it is now available <clap> <clap> <clap>!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 @code{:-)}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 @node Getting Connected, New Indentation Engine, Introduction, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 @comment node-name, next, previous, up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 @chapter Getting Connected
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 @cindex Getting Connected
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 @file{cc-mode.el} works well with the 2 main branches of Emacs 19:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 XEmacs and the Emacs 19 maintained by the FSF. Emacs 19 users will want
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 to use Emacs version 19.21 or better, XEmacs users will want 19.6 or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 better. Earlier versions of these Emacsen have deficiencies and/or bugs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 which will adversely affect the performance and usability of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 @code{cc-mode}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 @cindex @file{cc-mode-18.el} file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 Similarly if you use the @file{cc-mode-18.el} compatibility file,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 @file{cc-mode.el} will work with Emacs 18, but only moderately well. A
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 word of warning though, @emph{Emacs 18 lacks some fundamental
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 functionality and that ultimately means using Emacs 18 is a losing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 battle}. Hence @code{cc-mode} under Emacs 18 is no longer supported and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 it is highly recommended that you upgrade to Emacs 19. If you use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 @code{cc-mode} under Emacs 18, you're on your own. With @code{cc-mode}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 version 5, Emacs 18 support will be dropped altogether.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 Note that as of XEmacs 19.13 and Emacs 19.30, your Emacs already comes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 with @code{cc-mode} version 4 preconfigured for your use. You should be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 able to safely skip the rest of the setup information in this chapter.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 @cindex @file{.emacs} file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 The first thing you will want to do is put @file{cc-mode.el} somewhere
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 on your @code{load-path} so Emacs can find it. Do a @kbd{C-h v
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 load-path RET} to see all the directories Emacs looks at when loading a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 file. If none of these directories are appropriate, create a new
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 directory and add it to your @code{load-path}:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 @emph{[in the shell]}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 % cd
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 % mkdir mylisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 % mv cc-mode.el mylisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 % cd mylisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 @emph{[in your .emacs file add]}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (setq load-path (cons "~/mylisp" load-path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 @cindex byte compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 Next you want to @dfn{byte compile} @file{cc-mode.el}. The mode uses a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 lot of macros so if you don't byte compile it, things will be unbearably
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 slow. @emph{You can ignore all byte-compiler warnings!} They are the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 result of the supporting different versions of Emacs, and none of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 warnings have any effect on operation. Let me say this again:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 @strong{You really can ignore all byte-compiler warnings!}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 Here's what to do to byte-compile the file [in emacs]:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 M-x byte-compile-file RET ~/mylisp/cc-mode.el RET
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 If you are running a version of Emacs or XEmacs that comes with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 @code{cc-mode} by default, you can simply add the following to your
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 @file{.emacs} file in order to upgrade to the latest version of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 @code{cc-mode}:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (load "cc-mode")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 Users of even older versions of Emacs 19, Emacs 18, or of the older
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 Lucid Emacs will probably be running an Emacs that has BOCM
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 @file{c-mode.el} and possible @file{c++-mode.el} pre-dumped. If your
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 Emacs is dumped with either of these files you first need to make Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 ``forget'' about those older modes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 If you can do a @kbd{C-h v c-mode-map RET} without getting an error, you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 need to add these lines at the top of your @file{.emacs} file:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (fmakunbound 'c-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (makunbound 'c-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (fmakunbound 'c++-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (makunbound 'c++-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (makunbound 'c-style-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 After those lines you will want to add the following autoloads to your
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 @file{.emacs} file so that @code{cc-mode} gets loaded at the right time:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (autoload 'c++-mode "cc-mode" "C++ Editing Mode" t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (autoload 'c-mode "cc-mode" "C Editing Mode" t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (autoload 'objc-mode "cc-mode" "Objective-C Editing Mode" t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (autoload 'java-mode "cc-mode" "Java Editing Mode" t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 Alternatively, if you want to make sure @code{cc-mode} is loaded when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 Emacs starts up, you could use this line instead of the three autoloads
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 above:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (require 'cc-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 Next, you will want to set up Emacs so that it edits C files in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 @code{c-mode}, C++ files in @code{c++-mode}, and Objective-C files in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 @code{objc-mode}. All users should add the following to their
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 @file{.emacs} file. Note that this assumes you'll be editing @code{.h}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 and @code{.c} files as C, @code{.hh}, @code{.cc}, @code{.H}, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 @code{.C} files as C++, @code{.m} files as Objective-C, and @code{.java}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 files as Java code. YMMV:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (setq auto-mode-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (append
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 '(("\\.C$" . c++-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 ("\\.H$" . c++-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 ("\\.cc$" . c++-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 ("\\.hh$" . c++-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 ("\\.c$" . c-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 ("\\.h$" . c-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 ("\\.m$" . objc-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 ("\\.java$" . java-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 ) auto-mode-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 You may already have some or all of these settings on your
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 @code{auto-mode-alist}, but it won't hurt to put them on there again.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 That's all you need -- I know, I know, it sounds like a lot @code{:-)},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 but after you've done all this, you should only need to quit and restart
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 Emacs. The next time you visit a C, C++, Objective-C, or Java file you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 should be using @code{cc-mode}. You can check this easily by hitting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 @kbd{M-x c-version RET} in the @code{c-mode}, @code{c++-mode}, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 @code{objc-mode} buffer. You should see this message in the echo area:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 Using @code{cc-mode} version 4.@var{xxx}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 Where @var{xxx} is the latest release minor number.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 * Syntactic Analysis::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 * Indentation Calculation::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 @node New Indentation Engine, Minor Modes, Getting Connected, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 @chapter New Indentation Engine
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 @cindex New Indentation Engine
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 @code{cc-mode} has a new indentation engine, providing a simplified, yet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 flexible and general mechanism for customizing indentation. It breaks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 indentation calculation into two steps. First for the line of code being
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 indented, @code{cc-mode} analyzes what kind of language construct it's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 looking at, then it applies user defined offsets to the current line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 based on this analysis.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 This section will briefly cover how indentation is calculated in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 @code{cc-mode}. It is important to understand the indentation model
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 being used so that you will know how to customize @code{cc-mode} for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 your personal coding style.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 * Syntactic Analysis::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 * Indentation Calculation::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 @node Syntactic Analysis, Indentation Calculation, , New Indentation Engine
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 @section Syntactic Analysis
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 @cindex Syntactic Analysis
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 @vindex c-offsets-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 @vindex offsets-alist (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 @cindex relative buffer position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 @cindex syntactic symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 @cindex syntactic component
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 @cindex syntactic component list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 @cindex relative buffer position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 The first thing @code{cc-mode} does when indenting a line of code, is to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 analyze the line, determining the @dfn{syntactic component list} of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 construct on that line. A @dfn{syntactic component} consists of a pair
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 of information (in lisp parlance, a @emph{cons cell}), where the first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 part is a @dfn{syntactic symbol}, and the second part is a @dfn{relative
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 buffer position}. Syntactic symbols describe elements of C code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 @footnote{or C++, Objective-C, or Java code. In general, for the rest
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 of this manual I'll use the term ``C code'' to refer to all the C-like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 dialects, unless otherwise noted.}, e.g. @code{statement},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 @code{substatement}, @code{class-open}, @code{class-close}, etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 @xref{Syntactic Symbols}, for a complete list of currently recognized
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 syntactic symbols and their semantics. The variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 @code{c-offsets-alist} also contains the list of currently supported
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 syntactic symbols.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 Conceptually, a line of C code is always indented relative to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 indentation of some line higher up in the buffer. This is represented
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 by the relative buffer position in the syntactic component.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 It might help to see an example. Suppose we had the following code as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 the only thing in a @code{c++-mode} buffer @footnote{The line numbers in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 this and future examples don't actually appear in the buffer, of course!}:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 1: void swap( int& a, int& b )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 2: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 3: int tmp = a;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 4: a = b;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 5: b = tmp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 6: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 @kindex C-c C-s
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 @findex c-show-syntactic-information
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 @findex show-syntactic-information (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 We can use the command @kbd{C-c C-s}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (@code{c-show-syntactic-information}) to simply report what the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 syntactic analysis is for the current line. Running this command on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 line 4 this example, we'd see in the echo area:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 ((statement . 35))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 This tells us that the line is a statement and it is indented relative
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 to buffer position 35, which happens to be the @samp{i} in @code{int} on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 line 3. If you were to move point to line 3 and hit @kbd{C-c C-s}, you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 would see:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 ((defun-block-intro . 29))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 This indicates that the @samp{int} line is the first statement in a top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 level function block, and is indented relative to buffer position 29,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 which is the brace just after the function header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 Here's another example:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 1: int add( int val, int incr, int doit )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 2: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 3: if( doit )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 4: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 5: return( val + incr );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 6: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 7: return( val );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 8: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 Hitting @kbd{C-c C-s} on line 4 gives us:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 ((substatement-open . 46))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 @cindex substatement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 @cindex substatment block
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 which tells us that this is a brace that @emph{opens} a substatement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 block. @footnote{A @dfn{substatement} indicates the line after an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 @code{if}, @code{else}, @code{while}, @code{do}, @code{switch}, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 @code{for} statement, and a @dfn{substatement block} is a brace block
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 following one of those constructs.}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 @cindex comment only line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 Syntactic component lists can contain more than one component, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 individual syntactic components need not have relative buffer positions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 The most common example of this is a line that contains a @dfn{comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 only line}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 1: void draw_list( List<Drawables>& drawables )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 2: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 3: // call the virtual draw() method on each element in list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 4: for( int i=0; i < drawables.count(), ++i )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 5: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 6: drawables[i].draw();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 7: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 8: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 Hitting @kbd{C-c C-s} on line 3 of example 3 gives us:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 ((comment-intro) (defun-block-intro . 46))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 so you can see that the syntactic component list contains two syntactic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 components. Also notice that the first component,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 @samp{(comment-intro)} has no relative buffer position.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 @node Indentation Calculation, , Syntactic Analysis, New Indentation Engine
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 @section Indentation Calculation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 @cindex Indentation Calculation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 @vindex c-offsets-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 @vindex offsets-alist (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 Indentation for the current line is calculated using the syntactic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 component list derived in step 1 above (see @ref{Syntactic Analysis}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 Each component contributes to the final total indentation of the line in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 two ways.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 First, the syntactic symbols are looked up in the @code{c-offsets-alist}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 variable, which is an association list of syntactic symbols and the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 offsets to apply for those symbols. These offsets are added to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 running total.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 Second, if the component has a relative buffer position, @code{cc-mode}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 adds the column number of that position to the running total. By adding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 up the offsets and columns for every syntactic component on the list,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 the final total indentation for the current line is computed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 Let's use our two code examples above to see how this works. Here is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 our first example again:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 1: void swap( int& a, int& b )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 2: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 3: int tmp = a;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 4: a = b;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 5: b = tmp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 6: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 @kindex TAB
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 Let's say point is on line 3 and we hit the @key{TAB} key to re-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 the line. Remember that the syntactic component list for that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 line is:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 ((defun-block-intro . 29))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 @code{cc-mode} looks up @code{defun-block-intro} in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 @code{c-offsets-alist} variable. Let's say it finds the value @samp{4};
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 it adds this to the running total (initialized to zero), yielding a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 running total indentation of 4 spaces.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 Next @code{cc-mode} goes to buffer position 29 and asks for the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 column. Since the brace at buffer position 29 is in column zero, it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 adds @samp{0} to the running total. Since there is only one syntactic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 component on the list for this line, indentation calculation is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 complete, and the total indentation for the line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 is 4 spaces.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 Here's another example:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 1: int add( int val, int incr, int doit )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 2: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 3: if( doit )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 4: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 5: return( val + incr );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 6: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 7: return( val );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 8: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 If we were to hit @kbd{TAB} on line 4 in the above example, the same
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 basic process is performed, despite the differences in the syntactic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 component list. Remember that the list for this line is:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 ((substatement-open . 46))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 Here, @code{cc-mode} first looks up the @code{substatement-open} symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 in @code{c-offsets-alist}. Let's say it finds the value @samp{4}. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 yields a running total of 4. @code{cc-mode} then goes to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 buffer position 46, which is the @samp{i} in @code{if} on line 3. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 character is in the fourth column on that line so adding this to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 running total yields an indentation for the line of 8 spaces.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 Simple, huh?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 Actually, the mode usually just does The Right Thing without you having
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 to think about it in this much detail. But when customizing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 indentation, it's helpful to understand the general indentation model
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 being used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 @vindex c-echo-syntactic-information-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 @vindex echo-syntactic-information-p (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 @cindex TAB
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 To help you configure @code{cc-mode}, you can set the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 @code{c-echo-syntactic-information-p} to non-@code{nil} so that the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 syntactic component list and calculated offset will always be echoed in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 the minibuffer when you hit @kbd{TAB}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 @node Minor Modes, Indentation Commands, New Indentation Engine, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 @chapter Minor Modes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 @cindex Minor Modes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 @code{cc-mode} contains two minor-mode-like features that you should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 find useful while you enter new C code. The first is called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 @dfn{auto-newline} mode, and the second is called @dfn{hungry-delete}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 mode. These minor modes can be toggled on and off independently, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 @code{cc-mode} can be configured so that it comes up with any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 combination of these minor modes. By default, both of these minor modes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 are turned off.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 The state of the minor modes is always reflected in the minor mode list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 on the modeline of the @code{cc-mode} buffer. When auto-newline mode is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 enabled, you will see @samp{C/a} on the mode line @footnote{Remember
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 that the @samp{C} would be replaced with @samp{C++} or @samp{ObjC} if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 you were editing C++ or Objective-C code.}. When hungry delete mode is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 enabled you would see @samp{C/h} and when both modes are enabled, you'd
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 see @samp{C/ah}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 @kindex C-c C-a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 @kindex C-c C-d
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 @kindex C-c C-t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 @findex c-toggle-hungry-state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 @findex c-toggle-auto-state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 @findex c-toggle-auto-hungry-state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 @findex toggle-hungry-state (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 @findex toggle-auto-state (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 @findex toggle-auto-hungry-state (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 @code{cc-mode} provides keybindings which allow you to toggle the minor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 modes while editing code on the fly. To toggle just the auto-newline
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 state, hit @kbd{C-c C-a} (@code{c-toggle-auto-state}). When you do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 this, you should see the @samp{a} indicator either appear or disappear
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 on the modeline. Similarly, to toggle just the hungry-delete state, use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 @kbd{C-c C-d} (@code{c-toggle-hungry-state}), and to toggle both states
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 together, use @kbd{C-c C-t} (@code{c-toggle-auto-hungry-state}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 To set up the auto-newline and hungry-delete states to your preferred
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 values, you would need to add some lisp to your @file{.emacs} file that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 called one of the @code{c-toggle-*-state} functions directly. When
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 called programmatically, each function takes a numeric value, where
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 a positive number enables the minor mode, a negative number disables the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 mode, and zero toggles the current state of the mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 So for example, if you wanted to enable both auto-newline and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 hungry-delete for all your C file editing, you could add the following
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 to your @file{.emacs} file:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 (add-hook 'c-mode-common-hook '(lambda () (c-toggle-auto-hungry-state 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 @cindex electric characters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 * Auto-newline insertion::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 * Hungry-deletion of whitespace::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 @node Auto-newline insertion, Hungry-deletion of whitespace, , Minor Modes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 @section Auto-newline insertion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 @cindex Auto-newline insertion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 @cindex electric commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 Auto-newline minor mode works by enabling certain @dfn{electric
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 commands}. Electric commands are typically bound to special characters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 such as the left and right braces, colons, semi-colons, etc., which when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 typed, perform some magic formatting in addition to inserting the typed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 character. As a general rule, electric commands are only electric when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 the following conditions apply:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 @itemize @bullet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 Auto-newline minor mode is enabled, as evidenced by a @samp{C/a} or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 @samp{C/ah} indicator on the modeline.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 @cindex literal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 @cindex syntactic whitespace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 The character was not typed inside of a literal @footnote{A
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 @dfn{literal} is defined in @code{cc-mode} as any comment,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 string, or cpp macro definition. These constructs are also known as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 @dfn{syntactic whitespace} since they are usually ignored when scanning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 C code.}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 @kindex C-u
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 No numeric argument was supplied to the command (i.e. it was typed as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 normal, with no @kbd{C-u} prefix).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 @end itemize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 Certain other conditions may apply on a language specific basis. For
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 example, the second slash (@kbd{/}) of a C++ style line comment is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 electric in @code{c++-mode}, @code{objc-mode}, and @code{java-mode}, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 not in @code{c-mode}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 * Hanging Braces::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 * Hanging Colons::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 * Hanging Semi-colons and commas::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 * Other electric commands::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 * Clean-ups::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 @node Hanging Braces, Hanging Colons, , Auto-newline insertion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 @subsection Hanging Braces
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 @cindex Hanging Braces
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 @findex c-electric-brace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 @findex electric-brace (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 @vindex c-hanging-braces-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 @vindex hanging-braces-alist (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 @vindex c-offsets-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 @vindex offsets-alist (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 When you type either an open or close brace (i.e. @kbd{@{} or @kbd{@}}),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 the electric command @code{c-electric-brace} gets run. This command has
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 two electric formatting behaviors. First, it will perform some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 re-indentation of the line the brace was typed on, and second, it will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 add various newlines before and/or after the typed brace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 Re-indentation occurs automatically whenever the electric behavior is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 enabled. If the brace ends up on a line other than the one it was typed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 on, then that line is on is also indented according to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 @code{c-offsets-alist}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 @cindex class-open syntactic symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 @cindex class-close syntactic symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 @cindex defun-open syntactic symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 @cindex defun-close syntactic symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 @cindex inline-open syntactic symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 @cindex inline-close syntactic symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 @cindex brace-list-open syntactic symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 @cindex brace-list-close syntactic symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 @cindex brace-list-intro syntactic symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 @cindex brace-list-entry syntactic symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 @cindex block-open syntactic symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 @cindex block-close syntactic symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 @cindex substatement-open syntactic symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 @cindex statement-case-open syntactic symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 The insertion of newlines is controlled by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 @code{c-hanging-braces-alist} variable. This variable contains a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 mapping between syntactic symbols related to braces, and a list of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 places to insert a newline. The syntactic symbols that are useful for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 this list are: @code{class-open}, @code{class-close}, @code{defun-open},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 @code{defun-close}, @code{inline-open}, @code{inline-close},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 @code{brace-list-open}, @code{brace-list-close},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 @code{brace-list-intro}, @code{brace-list-entry}, @code{block-open},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 @code{block-close}, @code{substatement-open}, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 @code{statement-case-open}. @xref{Syntactic Symbols} for a more
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 detailed description of these syntactic symbols.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 @cindex custom indentation function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 The value associated with each syntactic symbol in this association list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 is called an @var{ACTION} which can be either a function or a list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 @xref{Custom Brace and Colon Hanging} for a more detailed discussion of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 using a function as a brace hanging @var{ACTION}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 When @var{ACTION} is a list, it can contain any combination of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 symbols @code{before} or @code{after}, directing @code{cc-mode} where to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 put newlines in relationship to the brace being inserted. Thus, if the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 list contains only the symbol @code{after}, then the brace is said to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 @dfn{hang} on the right side of the line, as in:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 // here, open braces always `hang'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 void spam( int i ) @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 if( i == 7 ) @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 dosomething(i);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 When the list contains both @code{after} and @code{before}, the braces
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 will appear on a line by themselves, as shown by the close braces in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 above example. The list can also be empty, in which case no newlines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 are added either before or after the brace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 For example, the default value of @code{c-hanging-braces-alist} is:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 (defvar c-hanging-braces-alist '((brace-list-open)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 (substatement-open after)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 (block-close . c-snug-do-while)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 which says that @code{brace-list-open} braces should both hang on the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 right side, and allow subsequent text to follow on the same line as the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 brace. Also, @code{substatement-open} braces should hang on the right
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 side, but subsequent text should follow on the next line. Here, in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 @code{block-close} entry, you also see an example of using a function as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 an @var{ACTION}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 @node Hanging Colons, Hanging Semi-colons and commas, Hanging Braces, Auto-newline insertion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 @subsection Hanging Colons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 @cindex Hanging Colons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 @vindex hanging-colons-alist (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 @vindex c-hanging-colons-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 Using a mechanism similar to brace hanging (see @ref{Hanging Braces}),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 colons can also be made to hang using the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 @code{c-hanging-colons-alist}. The syntactic symbols appropriate for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 this assocation list are: @code{case-label}, @code{label},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 @code{access-label}, @code{member-init-intro}, and @code{inher-intro}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 @xref{Hanging Braces} and @ref{Custom Brace and Colon Hanging} for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 details. Note however, that @code{c-hanging-colons-alist} does not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 implement functions as @var{ACTION}s.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 @cindex clean-ups
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 In C++, double-colons are used as a scope operator but because these
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 colons always appear right next to each other, newlines before and after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 them are controlled by a different mechanism, called @dfn{clean-ups} in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 @code{cc-mode}. @xref{Clean-ups} for details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 @node Hanging Semi-colons and commas, Other electric commands, Hanging Colons, Auto-newline insertion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 @subsection Hanging Semi-colons and commas
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 @cindex Hanging Semi-colons and commas
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 Semicolons and commas are also electric in @code{cc-mode}, but since
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 these characters do not correspond directly to syntactic symbols, a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 different mechanism is used to determine whether newlines should be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 automatically inserted after these characters. @xref{Customizing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 Semi-colons and Commas} for details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 @node Other electric commands, Clean-ups, Hanging Semi-colons and commas, Auto-newline insertion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 @subsection Other electric commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 @cindex Other electric commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 @kindex #
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 @findex c-electric-pound
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 @vindex c-electric-pound-behavior
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 @findex electric-pound (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 @vindex electric-pound-behavior (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 @vindex c-offsets-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 @vindex offsets-alist (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 A few other keys also provide electric behavior. For example the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 @kbd{#} key (@code{c-electric-pound}) is electric when it is typed as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 the first non-whitespace character on a line. In this case, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 variable @code{c-electric-pound-behavior} is consulted for the electric
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 behavior. This variable takes a list value, although the only element
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 currently defined is @code{alignleft}, which tells this command to force
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 the @samp{#} character into column zero. This is useful for entering
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 cpp macro definitions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 @findex c-electric-star
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 @findex c-electric-slash
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 @findex electric-star (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 @findex electric-slash (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 @cindex comment-only line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 Stars and slashes (i.e. @kbd{*} and @kbd{/}) are also electric under
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 certain circumstances. If a star is inserted as the second character of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 a C style block comment on a @dfn{comment-only} line, then the comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 delimiter is indented as defined by @code{c-offsets-alist}. A
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 comment-only line is defined as a line which contains only a comment, as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 in:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 void spam( int i )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 // this is a comment-only line...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 if( i == 7 ) // but this is not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 dosomething(i);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 Likewise, if a slash is inserted as the second slash in a C++ style line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 comment (also only on a comment-only line), then the line is indented as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 defined by @code{c-offsets-alist}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 @node Clean-ups, , Other electric commands, Auto-newline insertion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 @subsection Clean-ups
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 @cindex Clean-ups
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 @dfn{Clean-ups} are a mechanism complementary to colon and brace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 hanging. On the surface, it would seem that clean-ups overlap the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 functionality provided by the @code{c-hanging-*-alist} variables, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 similarly, clean-ups are only enabled when auto-newline minor mode is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 enabled. Clean-ups are used however to adjust code ``after-the-fact'',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 i.e. to eliminate some whitespace that isn't inserted by electric
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 commands, or whitespace that contains intervening constructs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 @cindex literal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 You can configure @code{cc-mode}'s clean-ups by setting the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 @code{c-cleanup-list}, which is a list of clean-up symbols. By default,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 @code{cc-mode} cleans up only the @code{scope-operator} construct, which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 is necessary for proper C++ support. Note that clean-ups are only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 performed when the construct does not occur within a literal (see
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 @ref{Auto-newline insertion}), and when there is nothing but whitespace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 appearing between the individual components of the construct.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 @vindex c-cleanup-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 @vindex cleanup-list (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 There are currently only five specific constructs that @code{cc-mode}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 can clean up, as indicated by these symbols:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 @itemize @bullet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 @code{brace-else-brace} -- cleans up @samp{@} else @{} constructs by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 placing the entire construct on a single line. Clean-up occurs when the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 open brace after the @samp{else} is typed. So for example, this:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 void spam(int i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 if( i==7 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 dosomething();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 appears like this after the open brace is typed:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 void spam(int i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 if( i==7 ) @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 dosomething();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 @} else @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 @code{empty-defun-braces} -- cleans up braces following a top-level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 function or class definition that contains no body. Clean up occurs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 when the closing brace is typed. Thus the following:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 class Spam
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 is transformed into this when the close brace is typed:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 class Spam
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 @{@}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 @code{defun-close-semi} -- cleans up the terminating semi-colon on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 top-level function or class definitions when they follow a close
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 brace. Clean up occurs when the semi-colon is typed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 So for example, the following:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 class Spam
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 is transformed into this when the semi-colon is typed:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 class Spam
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 @};
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 @code{list-close-comma} -- cleans up commas following braces in array
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 and aggregate initializers. Clean up occurs when the comma is typed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 @code{scope-operator} -- cleans up double colons which may designate a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064 C++ scope operator split across multiple lines@footnote{Certain C++
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 constructs introduce ambiguous situations, so @code{scope-operator}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 clean-ups may not always be correct. This usually only occurs when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 scoped identifiers appear in switch label tags.}. Clean up occurs when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068 the second colon is typed. You will always want @code{scope-operator}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069 in the @code{c-cleanup-list} when you are editing C++ code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 @end itemize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 @node Hungry-deletion of whitespace, , Auto-newline insertion, Minor Modes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 @section Hungry-deletion of whitespace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079 @cindex Hungry-deletion of whitespace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 Hungry deletion of whitespace, or as it more commonly called,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 @dfn{hungry-delete mode}, is a simple feature that some people find
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 extremely useful. In fact, you might find yourself wanting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085 hungry-delete in @strong{all} your editing modes!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 @kindex DEL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 In a nutshell, when hungry-delete mode is enabled, hitting the @kbd{DEL}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 character will consume all preceding whitespace, including newlines and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 tabs. This can really cut down on the number of @kbd{DEL}'s you have to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091 type if, for example you made a mistake on the preceding line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 @findex c-electric-delete
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094 @findex electric-delete (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095 @vindex c-delete-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096 @vindex delete-function (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097 @cindex literal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098 By default, @code{cc-mode} actually runs the command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 @code{c-electric-delete} when you hit @kbd{DEL}. When this command is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 used to delete a single character (i.e. when it is called interactively
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 with no numeric argument), it really runs the function contained in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102 variable @code{c-delete-function}. This function is called with a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103 single argument, which is the number of characters to delete.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104 @code{c-delete-function} is also called when the @kbd{DEL} key is typed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 inside a literal (see @ref{Auto-newline insertion}. Inside a literal,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106 @code{c-electric-delete} is not electric, which is typical of all the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107 so-called electric commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111 @node Indentation Commands, Customizing Indentation, Minor Modes, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114 @chapter Indentation Commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115 @cindex Indentation Commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118 @findex c-set-style
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119 @findex set-style (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 Various commands are provided which allow you to conveniently re-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121 C constructs, and these are outlined below. There are several things to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122 note about these indentation commands. First, when you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 change your programming style, either though @code{c-set-style} or some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 other means, your file does @emph{not} automatically get re-indented.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125 When you change style parameters, you will typically need to reformat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126 the line, expression, or buffer to see the effects of your changes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128 @cindex c-hanging- functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 @findex c-hanging-braces-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 @findex hanging-braces-alist (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131 Second, changing some variables have no effect on existing code, even
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 when you do re-indent. For example, the @code{c-hanging-*} variables and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 @code{c-cleanup-list} only affect newly entered code. So for example,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 changing @code{c-hanging-braces-alist} and re-indenting the buffer will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 not adjust placement of braces already in the file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137 @vindex c-progress-interval
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 @vindex progress-interval (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 Third, re-indenting large portions of code is currently rather
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140 inefficient. Improvements have been made since previous releases of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 @code{cc-mode}, and much more radical improvements will be made for the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142 next release, but for now you need to be aware of this @footnote{In
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 particular, I have had people complain about the speed that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 @code{cc-mode} re-indents @code{lex(1)} output. Lex, yacc, and other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 code generators usually output some pretty perverse code. @emph{Don't}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146 try to indent this stuff with @code{cc-mode}!}. Some provision has been
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 made to at least inform you as to the progress of your large
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 re-indentation command. The variable @code{c-progress-interval}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 controls how often a progress message is displayed. Set this variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150 to @code{nil} to inhibit progress messages. Note that this feature only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151 works with Emacs 19.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153 Also, except as noted below, re-indentation is always driven by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 same mechanisms that control on-the-fly indentation of code. @xref{New
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 Indentation Engine} for details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 @findex c-indent-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 @findex indent-command (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 @vindex c-tab-always-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 @vindex tab-always-indent (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 @kindex TAB
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 @cindex literal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 To indent a single line of code, use @kbd{TAB}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164 (@code{c-indent-command}). The behavior of this command is controlled
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165 by the variable @code{c-tab-always-indent}. When this variable is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 @code{t}, @kbd{TAB} always just indents the current line. When
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 @code{nil}, the line is indented only if point is at the left
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 margin, or on or before the first non-whitespace character on the line,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 otherwise a real tab character is inserted. If this variable's value is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 something other that @code{t} or @code{nil} (e.g. @code{'other}), then a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 real tab character is inserted only when point is inside a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172 literal (see @ref{Auto-newline insertion}), otherwise the line is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173 indented.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175 @kindex M-C-q
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 @findex c-indent-exp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177 @findex indent-exp (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178 To indent an entire balanced brace or parenthesis expression, use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179 @kbd{M-C-q} (@code{c-indent-exp}). Note that point should be on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180 the opening brace or parenthesis of the expression you want to indent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182 @kindex C-c C-q
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 @findex c-indent-defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184 @findex indent-defun (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 Another very convenient keystroke is @kbd{C-c C-q}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186 (@code{c-indent-defun}) when re-indents the entire top-level function or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 class definition that encompases point. It leaves point at the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188 same position within the buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 @kindex M-C-\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 @findex indent-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192 To indent any arbitrary region of code, use @kbd{M-C-\}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 (@code{indent-region}). This is a standard Emacs command, specially
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194 tailored for C code in a @code{cc-mode} buffer. Note that of course,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 point and mark must delineate the region you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196 want to indent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198 @kindex M-C-h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199 @findex c-mark-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200 @findex mark-function (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201 While not strictly an indentation function, @kbd{M-C-h}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202 (@code{c-mark-function}) is useful for marking the current top-level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203 function or class definition as the current region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207 @node Customizing Indentation, Syntactic Symbols, Indentation Commands, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1208 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210 @chapter Customizing Indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211 @cindex Customizing Indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 @cindex c-set-offset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215 @cindex set-offset (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 The @code{c-offsets-alist} variable is where you customize all your
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217 indentations. You simply need to decide what additional offset you want
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218 to add for every syntactic symbol. You can use the command @kbd{C-c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219 C-o} (@code{c-set-offset}) as the way to set offsets, both interactively
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220 and from your mode hook. Also, you can set up @emph{styles} of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221 indentation just like in BOCM. Most likely, you'll
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 find one of the pre-defined styles will suit your needs, but if not,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223 this section will describe how to set up basic editing configurations.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224 @xref{Styles} for an explanation of how to set up named styles.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 @cindex c-basic-offset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227 @cindex basic-offset (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228 As mentioned previously, the variable @code{c-offsets-alist} is an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 association list between syntactic symbols and the offsets to be applied
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230 for those symbols. In fact, these offset values can be an integer, a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 function or variable name, or one of the following symbols: @code{+},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 @code{-}, @code{++}, @code{--}, @code{*}, or @code{/}. These symbols
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233 describe offset in multiples of the value of the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 @code{c-basic-offset}. By defining a style's indentation in terms of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235 this fundamental variable, you can change the amount of whitespace given
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236 to an indentation level while leaving the same relationship between
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237 levels. Here are multiples of @code{c-basic-offset} that the special
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238 symbols correspond to:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 @itemize @bullet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 @code{+ } = @code{c-basic-offset} times 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 @code{- } = @code{c-basic-offset} times -1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247 @code{++} = @code{c-basic-offset} times 2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249 @code{--} = @code{c-basic-offset} times -2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251 @code{* } = @code{c-basic-offset} times 0.5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253 @code{/ } = @code{c-basic-offset} times -0.5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255 @end itemize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 So, for example, because most of the default offsets are defined in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259 terms of @code{+}, @code{-}, and @code{0}, if you like the general
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260 indentation style, but you use 4 spaces instead of 2 spaces per level,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261 you can probably achieve your style just by changing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262 @code{c-basic-offset} like so (in your @file{.emacs} file)@footnote{The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1263 reason you need to use @code{setq-default} instead of @code{setq} is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264 that @code{c-basic-offset} is a buffer local variable, as are most of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1265 the @code{cc-mode} configuration variables. If you were to put this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1266 code in, e.g. your @code{c-mode-common-hook} function, you could use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267 @code{setq}.}:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1270 (setq-default c-basic-offset 4)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275 This would change
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1276 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1279 int add( int val, int incr, int doit )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1280 @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281 if( doit )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282 @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1283 return( val + incr );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1284 @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1285 return( val );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1286 @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1287
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1288 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1289 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1290
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1291 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1292 to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1293 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1294 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1295
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1296 int add( int val, int incr, int doit )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1297 @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1298 if( doit )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1299 @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1300 return( val + incr );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1301 @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1302 return( val );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1303 @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1304
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1305 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1306 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1307
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1308 To change indentation styles more radically, you will want to change the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1309 value associated with the syntactic symbols in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1310 @code{c-offsets-alist} variable. First, I'll show you how to do that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1311 interactively, then I'll describe how to make changes to your
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1312 @file{.emacs} file so that your changes are more permanent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1313
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1314 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1315 * Interactive Customization::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1316 * Permanent Customization::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1317 * Styles::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1318 * Advanced Customizations::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1319 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1320
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1321 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1322 @node Interactive Customization, Permanent Customization, , Customizing Indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1323 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1324
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1325 @section Interactive Customization
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1326 @cindex Interactive Customization
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1327 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1328
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1329 As an example of how to customize indentation, let's change the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1330 style of example 2 above from:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1331 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1332 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1333
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1334 1: int add( int val, int incr, int doit )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1335 2: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1336 3: if( doit )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1337 4: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1338 5: return( val + incr );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1339 6: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1340 7: return( val );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1341 8: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1342
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1343 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1344 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1345 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1346 to:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1347 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1348 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1349
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1350 1: int add( int val, int incr, int doit )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1351 2: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1352 3: if( doit )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1353 4: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1354 5: return( val + incr );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1355 6: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1356 7: return( val );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1357 8: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1358
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1359 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1360 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1361
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1362 In other words, we want to change the indentation of braces that open a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1363 block following a condition so that the braces line up under the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1364 conditional, instead of being indented. Notice that the construct we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1365 want to change starts on line 4. To change the indentation of a line,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1366 we need to see which syntactic component affect the offset calculations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1367 for that line. Hitting @kbd{C-c C-s} on line 4 yields:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1368 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1369
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1370 ((substatement-open . 46))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1371
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1372 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1373
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1374 @findex c-set-offset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1375 @findex set-offset (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1376 @kindex C-c C-o
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1377 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1378 so we know that to change the offset of the open brace, we need to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1379 change the indentation for the @code{substatement-open} syntactic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1380 symbol. To do this interactively, just hit @kbd{C-c C-o}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1381 (@code{c-set-offset}). This prompts you for the syntactic symbol to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1382 change, providing a reasonable default. In this case, the default is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1383 @code{substatement-open}, which is just the syntactic symbol we want to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1384 change!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1385
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1386 After you hit return, @code{cc-mode} will then prompt you for the new
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1387 offset value, with the old value as the default. The default in this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1388 case is @samp{+}, so hit backspace to delete the @samp{+}, then hit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1389 @samp{0} and @kbd{RET}. This will associate the offset 0 with the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1390 syntactic symbol @code{substatement-open} in the @code{c-offsets-alist}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1391 variable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1392
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1393 @findex c-indent-defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1394 @findex indent-defun (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1395 @kindex C-c C-q
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1396 To check your changes quickly, just hit @kbd{C-c C-q}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1397 (@code{c-indent-defun}) to reindent the entire function. The example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1398 should now look like:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1399 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1400 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1401
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1402 1: int add( int val, int incr, int doit )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1403 2: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1404 3: if( doit )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1405 4: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1406 5: return( val + incr );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1407 6: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1408 7: return( val );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1409 8: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1410
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1411 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1412 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1413
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1414 Notice how just changing the open brace offset on line 4 is all we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1415 needed to do. Since the other affected lines are indented relative to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1416 line 4, they are automatically indented the way you'd expect. For more
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1417 complicated examples, this may not always work. The general approach to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1418 take is to always start adjusting offsets for lines higher up in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1419 file, then re-indent and see if any following lines need further
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1420 adjustments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1421
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1422 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1423 @node Permanent Customization, Styles, Interactive Customization, Customizing Indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1424 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1425
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1426 @section Permanent Indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1427 @cindex Permanent Indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1428 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1429
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1430 @vindex c-mode-common-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1431 @vindex c-mode-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1432 @vindex c++-mode-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1433 @vindex objc-mode-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1434 @vindex java-mode-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1435 @cindex hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1436 To make this change permanent, you need to add some lisp code to your
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1437 @file{.emacs} file. @code{cc-mode} provides four hooks that you can use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1438 to customize your language editing styles. Four language specific hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1439 are provided, according to Emacs major mode conventions:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1440 @code{c-mode-hook}, @code{c++-mode-hook}, @code{objc-mode-hook}, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1441 @code{java-mode-hook}. These get run as the last thing when you enter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1442 @code{c-mode}, @code{c++-mode}, @code{objc-mode}, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1443 @code{java-mode-hook} respectively. @code{cc-mode} also provides a hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1444 called @code{c-mode-common-hook} which is run by all three modes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1445 @emph{before} the language specific hook. Thus, to make changes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1446 consistently across all supported @code{cc-mode} modes, use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1447 @code{c-mode-common-hook}. Most of the examples in this section will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1448 assume you are using the common hook.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1449
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1450 Here's a simplified example of what you can add to your @file{.emacs}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1451 file to make the changes described in the previous section
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1452 (@ref{Interactive Customization}) more permanent. See the Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1453 manuals for more information on customizing Emacs via hooks.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1454 @xref{Sample .emacs File} for a more complete sample @file{.emacs} file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1455 @footnote{The use of @code{add-hook} in this example only works for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1456 Emacs 19. Workarounds are available if you are using Emacs 18.}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1457 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1458 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1459
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1460 (defun my-c-mode-common-hook ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1461 ;; my customizations for all of c-mode, c++-mode, objc-mode, java-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1462 (c-set-offset 'substatement-open 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1463 ;; other customizations can go here
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1464 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1465 (add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1466
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1467 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1468 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1469
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1470 For complex customizations, you will probably want to set up a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1471 @emph{style} that groups all your customizations under a single
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1472 name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1473
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1474 The offset value can also be a function, and this is how power users
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1475 gain enormous flexibility in customizing indentation. @xref{Advanced
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1476 Customizations} for details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1477
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1478 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1479 @node Styles, Advanced Customizations, Permanent Customization, Customizing Indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1480 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1481
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1482 @section Styles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1483 @cindex Styles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1484 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1485
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1486 Most people only need to edit code formatted in just a few well-defined
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1487 and consistent styles. For example, their organization might impose a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1488 ``blessed'' style that all its programmers must conform to. Similarly,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1489 people who work on GNU software will have to use the GNU coding style on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1490 C code. Some shops are more lenient, allowing some variety of coding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1491 styles, and as programmers come and go, there could be a number of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1492 styles in use. For this reason, @code{cc-mode} makes it convenient for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1493 you to set up logical groupings of customizations called @dfn{styles},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1494 associate a single name for any particular style, and pretty easily
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1495 start editing new or existing code using these styles. This chapter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1496 describes how to set up styles and how to edit your C code using styles.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1497
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1498 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1499 * Built-in Styles::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1500 * Adding Styles::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1501 * File Styles::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1502 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1503
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1504
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1505 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1506 @node Built-in Styles, Adding Styles, , Styles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1507 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1508
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1509 @subsection Built-in Styles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1510 @cindex Built-in Styles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1511 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1512
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1513 If you're lucky, one of @code{cc-mode}'s built-in styles might be just
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1514 what you're looking for. Some of the most common C and C++ styles are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1515 already built-in. These include:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1516
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1517 @itemize @bullet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1518 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1519 @cindex GNU style
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1520 @code{gnu} -- coding style blessed by the Free Software Foundation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1521 for C code in GNU programs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1522
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1523 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1524 @cindex K&R style
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1525 @code{k&r} -- The classic Kernighan and Ritchie style for C code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1526
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1527 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1528 @cindex BSD style
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1529 @code{bsd} -- @strong{<TBD> Anybody know anything about the history of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1530 this style?}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1531
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1532 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1533 @cindex Stroustrup style
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1534 @code{stroustrup} -- The classic Stroustrup style for C++ code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1535
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1536 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1537 @cindex Whitesmith style
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1538 @code{whitesmith} -- @strong{<TBD> Anybody know anything about the history of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1539 this style?}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1540
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1541 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1542 @cindex Ellemtel style
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1543 @code{ellemtel} -- Popular C++ coding standards as defined by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1544 ``Programming in C++, Rules and Recommendations'', Erik Nyquist and Mats
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1545 Henricson, Ellemtel @footnote{This document is ftp'able from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1546 @code{euagate.eua.ericsson.se}}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1547
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1548 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1549 @cindex Java style
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1550 @cindex java-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1551 @code{java} -- The style for editing Java code. Note that this style is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1552 automatically installed when you enter @code{java-mode}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1553
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1554 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1555 @cindex CC-MODE style
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1556 @code{CC-MODE} -- Style that encapsulates the default values of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1557 @code{cc-mode} variables. See below for details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1558
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1559 @end itemize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1560
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1561 @findex c-set-style
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1562 @findex set-style (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1563 If you'd like to experiment with these built-in styles you can simply
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1564 type the following in a @code{cc-mode} buffer:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1565 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1566 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1567
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1568 @kbd{M-x c-set-style RET @var{STYLE-NAME} RET}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1569
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1570 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1571 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1572 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1573 Note that all style names are case insensitive, even the ones you define.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1574
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1575 Setting a style in this way does @emph{not} automatically re-indent your
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1576 file. For commands that you can use to view the effect of your changes,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1577 see @ref{Indentation Commands}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1578
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1579 Once you find a built-in style you like, you can make the change
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1580 permanent by adding a call to your @file{.emacs} file. Let's say for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1581 example that you want to use the @code{ellemtel} style in all your
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1582 files. You would add this:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1583 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1584 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1585
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1586 (defun my-c-mode-common-hook ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1587 ;; use Ellemtel style for all C, C++, and Objective-C code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1588 (c-set-style "ellemtel")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1589 ;; other customizations can go here
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1590 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1591 (add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1592
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1593 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1594 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1595
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1596 There is one other special style you can use, called @code{CC-MODE}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1597 This is a style that is calculated by @code{cc-mode} when it starts up.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1598 The @code{CC-MODE} style is also special because all other styles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1599 implicitly inherit from it; in other words, whenever you set a style,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1600 @code{cc-mode} first re-instates the @code{CC-MODE} style, then applies
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1601 your new style configurations.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1602
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1603 The @code{CC-MODE} style exists because once @code{cc-mode} initializes,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1604 it institutes the @code{gnu} style for compatibility with BOCM's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1605 defaults. Any customizations you make in mode hooks will be based on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1606 the @code{gnu} style, unless you first do a @code{c-set-style} to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1607 @code{CC-MODE} or some other built-in style.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1608
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1609
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1610 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1611 @node Adding Styles, File Styles, Built-in Styles, Styles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1612 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1613
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1614 @subsection Adding Styles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1615 @cindex Adding Styles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1616 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1617
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1618 @vindex c-style-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1619 @vindex style-alist (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1620 @findex c-add-style
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1621 @findex add-style (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1622 If none of the built-in styles is appropriate, you'll probably want to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1623 add a new style definition. Styles are kept in the @code{c-style-alist}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1624 variable, but you probably won't want to modify this variable directly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1625 @code{cc-mode} provides a function, called @code{c-add-style}, that you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1626 can use to easily add new styles or update existing styles. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1627 function takes two arguments, a @var{stylename} string, and an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1628 association list @var{description} of style customizations. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1629 @var{stylename} is not already in @code{c-style-alist}, the new style is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1630 added, otherwise the style already associated with @var{stylename} is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1631 changed to the new @var{description}. This function also takes an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1632 optional third argument, which if non-@code{nil}, automatically
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1633 institutes the new style in the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1634
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1635 The sample @file{.emacs} file provides a concrete example of how a new
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1636 style can be added and automatically set. @xref{Sample .emacs File}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1637
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1638 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1639 @node File Styles, , Adding Styles, Styles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1640 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1641
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1642 @subsection File Styles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1643 @cindex File Styles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1644 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1645
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1646 @cindex local variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1647 The Emacs manual describes how you can customize certain variables on a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1648 per-file basis by including a @dfn{Local Variable} block at the end of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1649 the file. So far, you've only seen a functional interface to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1650 @code{cc-mode}, which is highly inconvenient for use in a Local Variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1651 block. @code{cc-mode} provides two variables that make it easier for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1652 you to customize your style on a per-file basis.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1653
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1654 @vindex c-file-style
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1655 @vindex file-style (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1656 @vindex c-file-offsets
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1657 @vindex file-offsets (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1658
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1659 The variable @code{c-file-style} can be set to a style name string as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1660 described in @ref{Built-in Styles}. When the file is visited,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1661 @code{cc-mode} will automatically set the file's style to this style
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1662 using @code{c-set-style}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1663
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1664 @vindex c-offsets-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1665 @vindex offsets-alist (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1666 @findex c-set-offset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1667 @findex set-offset (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1668 Another variable, @code{c-file-offsets}, takes an association list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1669 similar to what is allowed in @code{c-offsets-alist}. When the file is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1670 visited, @code{cc-mode} will automatically institute these offets using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1671 @code{c-set-offset}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1672
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1673 Note that file style settings (i.e. @code{c-file-style}) are applied
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1674 before file offset settings (i.e. @code{c-file-offsets}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1675
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1676
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1677 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1678 @node Advanced Customizations, , Styles, Customizing Indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1679 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1680
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1681 @section Advanced Customizations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1682 @cindex Advanced Customizations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1683 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1684
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1685 @vindex c-style-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1686 @vindex style-alist (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1687 @vindex c-basic-offset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1688 @vindex basic-offset (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1689 For most users, @code{cc-mode} will support their coding styles with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1690 very little need for customizations. Usually, one of the standard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1691 styles defined in @code{c-style-alist} will do the trick. At most,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1692 perhaps one of the syntactic symbol offsets will need to be tweaked
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1693 slightly, or maybe @code{c-basic-offset} will need to be changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1694 However, some styles require a more advanced ability for customization,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1695 and one of the real strengths of @code{cc-mode} is that the syntactic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1696 analysis model provides a very flexible framework for customizing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1697 indentation. This allows you to perform special indentation calculations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1698 for situations not handled by the mode directly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1699
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1700 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1701 * Custom Indentation Functions::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1702 * Custom Brace and Colon Hanging::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1703 * Customizing Semi-colons and Commas::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1704 * Other Special Indentations::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1705 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1706
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1707 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1708 @node Custom Indentation Functions, Custom Brace and Colon Hanging, , Advanced Customizations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1709 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1710
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1711 @subsection Custom Indentation Functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1712 @cindex Custom Indentation Functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1713 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1714
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1715 @cindex custom indentation functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1716 One of the most common ways to customize @code{cc-mode} is by writing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1717 @dfn{custom indentation functions} and associating them with specific
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1718 syntactic symbols (see @ref{Syntactic Symbols}). @code{cc-mode} itself
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1719 uses custom indentation functions to provide more sophisticated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1720 indentation, for example when lining up C++ stream operator blocks:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1721 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1722 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1723
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1724 1: void main(int argc, char**)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1725 2: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1726 3: cout << "There were "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1727 4: << argc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1728 5: << "arguments passed to the program"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1729 6: << endl;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1730 7: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1731
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1732 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1733 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1734
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1735 In this example, lines 4 through 6 are assigned the @code{stream-op}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1736 syntactic symbol. If @code{stream-op} had an offset of @code{+}, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1737 @code{c-basic-offset} was 2, lines 4 through 6 would simply be indented
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1738 two spaces to the right of line 3. But perhaps we'd like @code{cc-mode}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1739 to be a little more intelligent so that it offsets the stream operators
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1740 under the operator in line 3. To do this, we have to write a custom
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1741 indentation function which finds the column of first stream operator on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1742 the first line of the statement. Here is the lisp code (from the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1743 @file{cc-mode.el} source file) that implements this:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1744 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1745 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1746
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1747 (defun c-lineup-streamop (langelem)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1748 ;; lineup stream operators
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1749 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1750 (let* ((relpos (cdr langelem))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1751 (curcol (progn (goto-char relpos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1752 (current-column))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1753 (re-search-forward "<<\\|>>" (c-point 'eol) 'move)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1754 (goto-char (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1755 (- (current-column) curcol))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1756
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1757 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1758 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1759 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1760 Custom indent functions take a single argument, which is a syntactic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1761 component cons cell (see @ref{Syntactic Analysis}). The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1762 function returns an integer offset value that will be added to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1763 running total indentation for the lne. Note that what actually gets
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1764 returned is the difference between the column that the first stream
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1765 operator is on, and the column of the buffer relative position passed in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1766 the function's argument. Remember that @code{cc-mode} automatically
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1767 adds in the column of the component's relative buffer position and we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1768 don't want that value added into the final total twice.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1769
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1770 @cindex stream-op syntactic symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1771 @findex c-lineup-streamop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1772 @findex lineup-streamop (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1773 Now, to associate the function @code{c-lineup-streamop} with the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1774 @code{stream-op} syntactic symbol, we can add something like the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1775 following to our @code{c++-mode-hook}@footnote{It probably makes more
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1776 sense to add this to @code{c++-mode-hook} than @code{c-mode-common-hook}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1777 since stream operators are only relevent for C++.}:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1778 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1779
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1780 (c-set-offset 'stream-op 'c-lineup-streamop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1781
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1782 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1783
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1784 @kindex C-c C-q
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1785 Now the function looks like this after re-indenting (using @kbd{C-c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1786 C-q}):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1787 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1788 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1789
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1790 1: void main(int argc, char**)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1791 2: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1792 3: cout << "There were "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1793 4: << argc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1794 5: << "arguments passed to the program"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1795 6: << endl;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1796 7: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1797
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1798 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1799 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1800
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1801 @vindex c-offsets-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1802 @vindex offsets-alist (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1803 Custom indentation functions can be as simple or as complex as you like,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1804 and any syntactic symbol that appears in @code{c-offsets-alist} can have
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1805 a custom indentation function associated with it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1806
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1807 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1808 @node Custom Brace and Colon Hanging, Customizing Semi-colons and Commas, Custom Indentation Functions, Advanced Customizations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1809 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1810
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1811 @subsection Custom Brace and Colon Hanging
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1812 @cindex Custom Brace and Colon Hanging
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1813 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1814
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1815 @vindex c-hanging-braces-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1816 @vindex hanging-braces-alist (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1817 Syntactic symbols aren't the only place where you can customize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1818 @code{cc-mode} with the lisp equivalent of callback functions. Brace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1819 hanginess can also be determined by custom functions associated with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1820 syntactic symbols on the @code{c-hanging-braces-alist} variable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1821 Remember that @var{ACTION}'s are typically a list containing some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1822 combination of the symbols @code{before} and @code{after} (see
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1823 @ref{Hanging Braces}). However, an @var{ACTION} can also be a function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1824 symbol which gets called when a brace matching that syntactic symbol is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1825 typed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1826
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1827 @cindex customizing brace hanging
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1828 These @var{ACTION} functions are called with two arguments: the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1829 syntactic symbol for the brace, and the buffer position at which the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1830 brace was inserted. The @var{ACTION} function is expected to return a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1831 list containing some combination of @code{before} and @code{after}. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1832 function can also return @code{nil}. This return value has the normal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1833 brace hanging semantics described in @ref{Hanging Braces}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1834
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1835 As an example, @code{cc-mode} itself uses this feature to dynamically
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1836 determine the hanginess of braces which close @samp{do-while}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1837 constructs:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1838 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1839 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1840
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1841 void do_list( int count, char** atleast_one_string )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1842 @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1843 int i=0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1844 do @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1845 handle_string( atleast_one_string( i ));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1846 i++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1847 @} while( i < count );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1848 @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1849
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1850 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1851 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1852
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1853 @findex c-snug-do-while
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1854 @findex snug-do-while (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1855 @code{cc-mode} assigns the @code{block-close} syntactic symbol to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1856 brace that closes the @code{do} construct, and normally we'd like the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1857 line that follows a @code{block-close} brace to begin on a separate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1858 line. However, with @samp{do-while} constructs, we want the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1859 @code{while} clause to follow the closing brace. To do this, we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1860 associate the @code{block-close} symbol with the @var{ACTION} function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1861 @code{c-snug-do-while}:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1862 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1863
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1864 (defun c-snug-do-while (syntax pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1865 "Dynamically calculate brace hanginess for do-while statements.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1866 Using this function, `while' clauses that end a `do-while' block will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1867 remain on the same line as the brace that closes that block.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1868
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1869 See `c-hanging-braces-alist' for how to utilize this function as an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1870 ACTION associated with `block-close' syntax."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1871 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1872 (let (langelem)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1873 (if (and (eq syntax 'block-close)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1874 (setq langelem (assq 'block-close c-syntactic-context))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1875 (progn (goto-char (cdr langelem))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1876 (if (= (following-char) ?@{)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1877 (forward-sexp -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1878 (looking-at "\\<do\\>[^_]")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1879 '(before)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1880 '(before after)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1881
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1882 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1883
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1884 This function simply looks to see if the brace closes a @samp{do-while}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1885 clause and if so, returns the list @samp{@code{(before)}} indicating
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1886 that a newline should be inserted before the brace, but not after it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1887 In all other cases, it returns the list @samp{@code{(before after)}} so
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1888 that the brace appears on a line by itself.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1889
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1890 @vindex c-syntactic-context
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1891 @vindex syntactic-context (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1892 During the call to the brace hanging @var{ACTION} function, the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1893 @code{c-syntactic-context} is bound to the full syntactic analysis list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1894
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1895 @cindex customizing colon hanging
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1896 @vindex c-hanging-colon-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1897 @vindex hanging-colon-alist (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1898 Note that for symmetry, colon hanginess should be customizable by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1899 allowing function symbols as @var{ACTION}s on the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1900 @code{c-hanging-colon-alist} variable. Since no use has actually been
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1901 found for this feature, it isn't currently implemented.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1902
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1903 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1904 @node Customizing Semi-colons and Commas, Other Special Indentations, Custom Brace and Colon Hanging, Advanced Customizations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1905 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1906
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1907 @subsection Customizing Semi-colons and Commas
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1908 @cindex Customizing Semi-colons and Commas
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1909 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1910
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1911 @cindex customizing semi-colons and commas
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1912 @vindex c-hanging-semi&comma-criteria
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1913 @vindex hanging-semi&comma-criteria (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1914 You can also customize the insertion of newlines after semi-colons and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1915 commas, when the auto-newline minor mode is enabled (see @ref{Minor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1916 Modes}). This is controlled by the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1917 @code{c-hanging-semi&comma-criteria}, which contains a list of functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1918 that are called in the order they appear. Each function is called with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1919 zero arguments, and is expected to return one of the following values:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1920
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1921 @itemize @bullet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1922 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1923 non-@code{nil} -- A newline is inserted, and no more functions from the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1924 list are called.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1925
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1926 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1927 @code{stop} -- No more functions from the list are called, but no
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1928 newline is inserted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1929
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1930 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1931 @code{nil} -- No determination is made, and the next function in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1932 list is called.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1933
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1934 @end itemize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1935
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1936 If every function in the list is called without a determination being
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1937 made, then no newline is added. The default value for this variable is a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1938 list containing a single function which inserts newlines only after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1939 semi-colons which do not appear inside parenthesis lists (i.e. those
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1940 that separate @code{for}-clause statements).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1941
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1942 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1943 @node Other Special Indentations, , Customizing Semi-colons and Commas, Advanced Customizations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1944 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1945
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1946 @subsection Other Special Indentations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1947 @cindex Customizing Semi-colons and Commas
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1948 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1949
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1950 @vindex c-special-indent-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1951 @vindex special-indent-hook (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1952 One other customization variable is available in @code{cc-mode}:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1953 @code{c-special-indent-hook}. This is a standard hook variable that is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1954 called after every line is indented by @code{cc-mode}. You can use it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1955 to do any special indentation or line adjustments your style dictates,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1956 such as adding extra indentation to constructors or destructor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1957 declarations in a class definition, etc. Note however, that you should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1958 not change point or mark inside your @code{c-special-indent-hook}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1959 functions (i.e. you'll probably want to wrap your function in a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1960 @code{save-excursion}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1961
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1962
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1963 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1964 @node Syntactic Symbols, Performance Issues, Customizing Indentation, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1965 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1966
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1967 @chapter Syntactic Symbols
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1968 @cindex Syntactic Symbols
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1969 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1970
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1971 @vindex c-offsets-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1972 @vindex offsets-alist (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1973 The complete list of recognized syntactic symbols is described in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1974 @code{c-offsets-alist} variable. This chapter will provide some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1975 examples to help clarify these symbols.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1976
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1977 @cindex -open syntactic symbols
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1978 @cindex -close syntactic symbols
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1979 Most syntactic symbol names follow a general naming convention. When a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1980 line begins with an open or close brace, the syntactic symbol will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1981 contain the suffix @code{-open} or @code{-close} respectively.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1982
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1983 @cindex -intro syntactic symbols
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1984 @cindex -cont syntactic symbols
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1985 @cindex -block-intro syntactic symbols
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1986 Usually, a distinction is made between the first line that introduces a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1987 construct and lines that continue a construct, and the syntactic symbols
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1988 that represent these lines will contain the suffix @code{-intro} or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1989 @code{-cont} respectively. As a sub-classification of this scheme, a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1990 line which is the first of a particular brace block construct will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1991 contain the suffix @code{-block-intro}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1992
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1993 @kindex C-c C-s
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1994 Let's look at some examples to understand how this works. Remember that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1995 you can check the syntax of any line by using @kbd{C-c C-s}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1996 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1997 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1998
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1999 1: void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2000 2: swap( int& a, int& b )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2001 3: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2002 4: int tmp = a;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2003 5: a = b;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2004 6: b = tmp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2005 7: int ignored =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2006 8: a + b;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2007 9: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2008
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2009 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2010 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2011
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2012 Line 1 shows a @code{topmost-intro} since it is the first line that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2013 introduces a top-level construct. Line 2 is a continuation of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2014 top-level construct introduction so it has the syntax
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2015 @code{topmost-intro-cont}. Line 3 shows a @code{defun-open} since it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2016 the brace that opens a top-level function definition. Line 9 is a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2017 @code{defun-close} since it contains the brace that closes the top-level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2018 function definition. Line 4 is a @code{defun-block-intro}, i.e. it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2019 the first line of a brace-block, which happens to be enclosed in a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2020 top-level function definition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2021
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2022 Lines 5, 6, and 7 are all given @code{statement} syntax since there
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2023 isn't much special about them. Note however that line 8 is given
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2024 @code{statement-cont} syntax since it continues the statement begun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2025 on the previous line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2026
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2027 Here's another example, which illustrates some C++ class syntactic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2028 symbols:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2029 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2030 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2031
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2032 1: class Bass
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2033 2: : public Guitar,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2034 3: public Amplifiable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2035 4: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2036 5: public:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2037 6: Bass()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2038 7: : eString( new BassString( 0.105 )),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2039 8: aString( new BassString( 0.085 )),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2040 9: dString( new BassString( 0.065 )),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2041 10: gString( new BassString( 0.045 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2042 11: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2043 12: eString.tune( 'E' );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2044 13: aString.tune( 'A' );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2045 14: dString.tune( 'D' );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2046 15: gString.tune( 'G' );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2047 16: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2048 17: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2049
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2050 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2051 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2052
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2053 As in the previous example, line 1 has the @code{topmost-intro} syntax.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2054 Here however, the brace that opens a C++ class definition on line 4 is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2055 assigned the @code{class-open} syntax. Note that in C++, structs and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2056 unions are essentially equivalent syntactically (and are very similar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2057 semantically), so replacing the @code{class} keyword in the example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2058 above with @code{struct} or @code{union} would still result in a syntax
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2059 of @code{class-open} for line 4 @footnote{This is the case even for C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2060 and Objective-C. For consistency, structs in all three languages are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2061 syntactically equivalent to classes. Note however that the keyword
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2062 @code{class} is meaningless in C and Objective-C.}. Similarly, line 17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2063 is assigned @code{class-close} syntax.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2064
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2065 Line 2 introduces the inheritance list for the class so it is assigned
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2066 the @code{inher-intro} syntax, and line 3, which continues the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2067 inheritance list is given @code{inher-cont} syntax.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2068
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2069 Things get interesting at line 5. The primary syntactic symbol for this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2070 line is @code{access-label} since this a label keyword that specifies
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2071 access protection in C++. However, this line actually shows two
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2072 syntactic symbols when you hit @kbd{C-c C-s}. This is because it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2073 also a top-level construct inside a class definition. Thus the other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2074 syntactic symbol assigned to this line is @code{inclass}. Similarly,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2075 line 6 is given both @code{inclass} and @code{topmost-intro} syntax.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2076
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2077 Line 7 introduces a C++ member initialization list and as such is given
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2078 @code{member-init-intro} syntax. Note that in this case it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2079 @emph{not} assigned @code{inclass} since this is not considered a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2080 top-level construct. Lines 8 through 10 are all assigned
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2081 @code{member-init-cont} since they continue the member initialization
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2082 list started on line 7.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2083
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2084 @cindex in-class inline methods
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2085 Line 11 is assigned @code{inline-open} because it opens an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2086 @dfn{in-class} C++ inline method definition. This is distinct from, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2087 related to, the C++ notion of an inline function in that its definition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2088 occurs inside an enclosing class definition, which in C++ implies that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2089 the function should be inlined. For example, if the definition of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2090 @code{Bass} constructor appeared outside the class definition, line 11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2091 would be given the @code{defun-open} syntax, even if the keyword
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2092 @code{inline} appeared before the method name, as in:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2093 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2094 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2095
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2096 class Bass
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2097 : public Guitar,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2098 public Amplifiable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2099 @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2100 public:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2101 Bass();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2102 @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2103
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2104 inline
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2105 Bass::Bass()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2106 : eString( new BassString( 0.105 )),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2107 aString( new BassString( 0.085 )),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2108 dString( new BassString( 0.065 )),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2109 gString( new BassString( 0.045 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2110 @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2111 eString.tune( 'E' );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2112 aString.tune( 'A' );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2113 dString.tune( 'D' );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2114 gString.tune( 'G' );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2115 @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2116
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2117 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2118 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2120 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2121 Similarly, line 16 is given @code{inline-close} syntax.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2122
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2123 As in the first example above, line 12 is given @code{defun-block-open}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2124 syntax and lines 13 through 15 are all given @code{statement} syntax.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2125
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2126 Here is another (totally contrived) example which illustrates how syntax
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2127 is assigned to various conditional constructs:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2128 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2129 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2130
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2131 1: void spam( int index )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2132 2: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2133 3: for( int i=0; i<index; i++ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2134 4: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2135 5: if( i == 10 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2136 6: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2137 7: do_something_special();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2138 8: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2139 9: else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2140 10: do_something( i );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2141 11: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2142 12: do @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2143 13: another_thing( i-- );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2144 14: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2145 15: while( i > 0 );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2146 16: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2147
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2148
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2149 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2150 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2151
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2152 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2153 Only the lines that illustrate new syntactic symbols will be discussed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2154
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2155 Line 4 has a brace which opens a conditional's substatement block. It
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2156 is thus assigned @code{substatement-open} syntax, and since line 5 is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2157 the first line in the substatement block, it is assigned
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2158 @code{substatement-block-intro} syntax. Lines 6 and 7 are assigned
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2159 similar syntax. Line 8 contains the brace that closes the inner
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2160 substatement block. It is given the generic syntax @code{block-close},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2161 as are lines 11 and 14.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2162
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2163 Line 9 is a little different -- since it contains the keyword
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2164 @code{else} matching the @code{if} statement introduced on line 5; it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2165 given the @code{else-clause} syntax. Note also that line 10 is slightly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2166 different too. Because @code{else} is considered a conditional
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2167 introducing keyword @footnote{The list of conditional keywords are (in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2168 C, Objective-C and C++): @code{for}, @code{if}, @code{do}, @code{else},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2169 @code{while}, and @code{switch}. C++ has two additional conditional
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2170 keywords: @code{try} and @code{catch}.}, and because the following
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2171 substatement is not a brace block, line 10 is assigned the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2172 @code{substatement} syntax.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2173
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2174 One other difference is seen on line 15. The @code{while} construct
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2175 that closes a @code{do} conditional is given the special syntax
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2176 @code{do-while-closure} if it appears on a line by itself. Note that if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2177 the @code{while} appeared on the same line as the preceding close brace,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2178 that line would have been assigned @code{block-close} syntax instead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2179
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2180 Switch statements have their own set of syntactic symbols. Here's an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2181 example:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2182 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2183 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2184
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2185 1: void spam( enum Ingredient i )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2186 2: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2187 3: switch( i ) @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2188 4: case Ham:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2189 5: be_a_pig();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2190 6: break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2191 7: case Salt:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2192 8: drink_some_water();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2193 9: break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2194 10: default:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2195 11: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2196 12: what_is_it();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2197 13: break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2198 14: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2199 15: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2200 14: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2201
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2202 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2203 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2204
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2205 Here, lines 4, 7, and 10 are all assigned @code{case-label} syntax,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2206 while lines 5 and 8 are assigned @code{statement-case-intro}. Line 11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2207 is treated slightly differently since it contains a brace that opens a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2208 block -- it is given @code{statement-case-open} syntax.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2209
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2210 @cindex brace lists
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2211 There are a set of syntactic symbols that are used to recognize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2212 constructs inside of brace lists. A brace list is defined as an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2213 @code{enum} or aggregate initializer list, such as might statically
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2214 initialize an array of structs. For example:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2215 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2216 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2217
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2218 1: static char* ingredients[] =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2219 2: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2220 3: "Ham",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2221 4: "Salt",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2222 5: NULL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2223 6: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2224
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2225 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2226 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2227
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2228 Following convention, line 2 in this example is assigned
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2229 @code{brace-list-open} syntax, and line 3 is assigned
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2230 @code{brace-list-intro} syntax. Likewise, line 6 is assigned
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2231 @code{brace-list-close} syntax. Lines 4 and 5 however, are assigned
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2232 @code{brace-list-entry} syntax, as would all subsequent lines in this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2233 initializer list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2234
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2235 A number of syntactic symbols are associated with parenthesis lists,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2236 a.k.a argument lists, as found in function declarations and function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2237 calls. This example illustrates these:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2238 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2239 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2240
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2241 1: void a_function( int line1,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2242 2: int line2 );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2243 3:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2244 4: void a_longer_function(
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2245 5: int line1,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2246 6: int line2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2247 7: );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2248 8:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2249 9: void call_them( int line1, int line2 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2250 10: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2251 11: a_function(
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2252 12: line1,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2253 13: line2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2254 14: );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2255 15:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2256 16: a_longer_function( line1,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2257 17: line2 );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2258 18: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2259
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2260 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2261 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2262
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2263 Lines 5 and 12 are assigned @code{arglist-intro} syntax since they are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2264 the first line following the open parenthesis, and lines 7 and 14 are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2265 assigned @code{arglist-close} syntax since they contain the parenthesis
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2266 that closes the argument list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2267
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2268 The other lines with relevant syntactic symbols include lines 2 and 17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2269 which are assigned @code{arglist-cont-nonempty} syntax. What this means
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2270 is that they continue an argument list, but that the line containing the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2271 parenthesis that opens the list is @emph{non-empty} following the open
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2272 parenthesis. Contrast this against lines 6 and 13 which are assigned
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2273 @code{arglist-cont} syntax. This is because the parenthesis that opens
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2274 their argument lists is the last character on that line @footnote{The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2275 need for this somewhat confusing arrangement is that the typical
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2276 indentation desired for these lines is calculated very differently.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2277 This should be simplified in version 5 of @code{cc-mode}, along with the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2278 added distinction between argument lists in function declarations, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2279 argument lists in function calls.}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2280
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2281 Note that there is no @code{arglist-open} syntax. This is because any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2282 parenthesis that opens an argument list, appearing on a separate line,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2283 is assigned the @code{statement-cont} syntax instead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2284
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2285 A few miscellaneous syntactic symbols that haven't been previously
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2286 covered are illustrated by this example:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2287 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2288 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2289
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2290 1: void Bass::play( int volume )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2291 2: const
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2292 3: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2293 4: /* this line starts a multi-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2294 5: * comment. This line should get `c' syntax */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2295 6:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2296 7: char* a_long_multiline_string = "This line starts a multi-line \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2297 8: string. This line should get `string' syntax.";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2298 9:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2299 10: note:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2300 11: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2301 12: #ifdef LOCK
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2302 13: Lock acquire();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2303 14: #endif // LOCK
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2304 15: slap_pop();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2305 16: cout << "I played "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2306 17: << "a note\n";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2307 18: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2308 19: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2309
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2310 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2311 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2312
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2313 @cindex modifier syntactic symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2314 The lines to note in this example include:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2315
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2316 @itemize @bullet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2317
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2318 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2319 line 2 which is assigned the @code{ansi-funcdecl-cont} syntax;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2320
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2321 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2322 line 4 which is assigned both @code{defun-block-intro} @emph{and}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2323 @code{comment-intro} syntax @footnote{The @code{comment-intro} syntactic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2324 symbol is known generically as a @dfn{modifier} since it always appears
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2325 on a syntactic analysis list with other symbols, and never has a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2326 relative buffer position.};
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2327
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2328 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2329 line 5 which is assigned @code{c} syntax;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2330
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2331 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2332 @cindex syntactic whitespace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2333 line 6 which, even though it contains nothing but whitespace, is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2334 assigned @code{defun-block-intro}. Note that the appearance of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2335 comment on lines 4 and 5 do not cause line 6 to be assigned
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2336 @code{statement} syntax because comments are considered to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2337 @dfn{syntactic whitespace}, which are essentially ignored when analyzing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2338 code;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2339
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2340 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2341 line 8 which is assigned @code{string} syntax;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2342
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2343 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2344 line 10 which is assigned @code{label} syntax;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2345
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2346 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2347 line 11 which is assigned @code{block-open} syntax;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2348
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2349 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2350 lines 12 and 14 which are assigned @code{cpp-macro} syntax;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2351
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2352 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2353 line 17 which is assigned @code{stream-op} syntax @footnote{In C++ only.}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2354
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2355 @end itemize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2356
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2357 In Objective-C buffers, there are three additional syntactic symbols
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2358 assigned to various message calling constructs. Here's an example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2359 illustrating these:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2360 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2361 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2362
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2363 1: - (void)setDelegate:anObject
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2364 2: withStuff:stuff
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2365 3: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2366 4: [delegate masterWillRebind:self
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2367 5: toDelegate:anObject
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2368 6: withExtraStuff:stuff];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2369 7: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2370
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2371 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2372 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2373
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2374 Here, line 1 is assigned @code{objc-method-intro} syntax, and line 2 is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2375 assigned @code{objc-method-args-cont} syntax. Lines 5 and 6 are both
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2376 assigned @code{objc-method-call-cont} syntax.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2377
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2378 Other syntactic symbols may be recognized by @code{cc-mode}, but these
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2379 are more obscure and so I haven't included examples of them. These
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2380 include: @code{knr-argdecl-intro}, @code{knr-argdecl}, and the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2381 @code{friend} modifier.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2382
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2383 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2384 @node Performance Issues, Frequently Asked Questions, Syntactic Symbols, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2385 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2386
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2387 @chapter Performance Issues
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2388 @cindex Performance Issues
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2389 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2390
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2391 C and it's derivative languages are highly complex creatures. Often,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2392 ambiguous code situations arise that require @code{cc-mode} to scan
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2393 large portions of the buffer to determine syntactic context. Some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2394 pathological code can cause @code{cc-mode} to slow down considerably.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2395 This section identifies some of the coding styles to watch out for, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2396 suggests some workarounds that you can use to improve performance.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2397
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2398 Note that this is an area that will get a lot of attention in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2399 @code{cc-mode} version 5. The mode should end up being much faster, at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2400 the expense of dropping Emacs 18 support, owing to the implementation of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2401 syntactic analysis caching. This is the last release of @code{cc-mode}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2402 that will be compatible with Emacs 18.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2403
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2404 Because @code{cc-mode} has to scan the buffer backwards from the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2405 insertion point, and because C's syntax is fairly difficult to parse in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2406 the backwards direction, @code{cc-mode} often tries to find the nearest
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2407 position higher up in the buffer from which to begin a forward scan.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2408 The farther this position is from the current insertion point, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2409 slower the mode gets. Some coding styles can even force @code{cc-mode}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2410 to scan from the beginning of the buffer!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2411
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2412 @findex beginning-of-defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2413 @findex defun-prompt-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2414 One of the simplest things you can do to reduce scan time, is make sure
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2415 any brace that opens a top-level block construct always appears in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2416 leftmost column. This is actually an Emacs constraint, as embodied in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2417 the @code{beginning-of-defun} function which @code{cc-mode} uses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2418 heavily. If you insist on hanging top-level open braces on the right
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2419 side of the line, then you should set the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2420 @code{defun-prompt-regexp} to something reasonable @footnote{Note that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2421 this variable is only defined in Emacs 19.}, however that ``something
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2422 reasonable'' is difficult to define, so @code{cc-mode} doesn't do it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2423 for you.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2424
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2425 @cindex @file{cc-lobotomy.el} file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2426 You will probably notice pathological behavior from @code{cc-mode} when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2427 working in files containing large amounts of cpp macros. This is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2428 because @code{cc-mode} cannot quickly skip backwards over these lines,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2429 which do not contribute to the syntactic calculations. You'll probably
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2430 also have problems if you are editing ``K&R'' C code, i.e. C code that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2431 does not use function prototypes. This is because there are ambiguities
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2432 in the C syntax when K&R style argument lists are used, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2433 @code{cc-mode} has to use a slower scan to determine what it's looking
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2434 at.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2435
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2436 @vindex c-recognize-knr-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2437 @vindex recognize-knr-p (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2438 For the latter problem, I would suggest converting to ANSI style
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2439 protocols, and turning the variable @code{c-recognize-knr-p} to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2440 @code{nil} (this is it's default value for all modes).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2441
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2442 @vindex cc-lobotomy-pith-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2443 For the former problem, you might want to investigate some of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2444 speed-ups provided for you in the file @file{cc-lobotomy.el}, which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2445 is part of the canonical @code{cc-mode} distribution. As mentioned
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2446 previous, @code{cc-mode} always trades accuracy for speed, however it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2447 recognized that sometimes you need speed and can sacrifice some accuracy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2448 in indentation. The file @file{cc-lobotomy.el} contains hacks that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2449 will ``dumb down'' @code{cc-mode} in some specific ways, making that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2450 trade-off of speed for accuracy. I won't go into details of its use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2451 here; you should read the comments at the top of the file, and look at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2452 the variable @code{cc-lobotomy-pith-list} for details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2453
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2454
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2455 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2456 @node Frequently Asked Questions, Getting the latest cc-mode release, Performance Issues, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2457 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2458
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2459 @chapter Frequently Asked Questions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2460 @cindex Frequently Asked Questions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2461 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2462
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2463 @kindex C-x h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2464 @kindex ESC C-\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2465 @kindex ESC C-x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2466 @kindex C-c C-q
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2467 @kindex ESC C-q
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2468 @kindex ESC C-u
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2469 @kindex RET
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2470 @kindex LFD
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2471 @findex newline-and-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2472 @quotation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2473
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2474 @strong{Q.} @emph{How do I re-indent the whole file?}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2475
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2476 @strong{A.} Visit the file and hit @kbd{C-x h} to mark the whole
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2477 buffer. Then hit @kbd{@key{ESC} C-\}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2478 @sp 2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2479
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2480 @strong{Q.} @emph{How do I re-indent the entire function?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2481 @kbd{@key{ESC} C-x} doesn't work.}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2482
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2483 @strong{A.} @kbd{@key{ESC} C-x} is reserved for future Emacs use.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2484 To re-indent the entire function hit @kbd{C-c C-q}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2485 @sp 2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2486
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2487 @strong{Q.} @emph{How do I re-indent the current block?}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2488
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2489 @strong{A.} First move to the brace which opens the block with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2490 @kbd{@key{ESC} C-u}, then re-indent that expression with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2491 @kbd{@key{ESC} C-q}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2492 @sp 2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2493
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2494 @strong{Q.} @emph{Why doesn't the @key{RET} key indent the line to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2495 where the new text should go after inserting the newline?}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2496
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2497 @strong{A.} Emacs' convention is that @key{RET} just adds a newline,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2498 and that @key{LFD} adds a newline and indents it. You can make
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2499 @key{RET} do this too by adding this to your
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2500 @code{c-mode-common-hook} (see the sample @file{.emacs} file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2501 @ref{Sample .emacs File}):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2502 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2503
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2504 (define-key c-mode-map "\C-m" 'newline-and-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2505
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2506 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2507
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2508 This is a very common question. @code{:-)} If you want this to be the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2509 default behavior, don't lobby me, lobby RMS!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2510 @sp 2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2511
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2512 @strong{Q.} @emph{I put @code{(c-set-offset 'substatement-open 0)}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2513 in my @file{.emacs} file but I get an error saying that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2514 @code{c-set-offset}'s function definition is void.}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2515
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2516 @strong{A.} This means that @code{cc-mode} wasn't loaded into your
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2517 Emacs session by the time the @code{c-set-offset} call was reached,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2518 mostly likely because @code{cc-mode} is being autoloaded. Instead
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2519 of putting the @code{c-set-offset} line in your top-level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2520 @file{.emacs} file, put it in your @code{c-mode-common-hook}, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2521 simply add the following to the top of your @file{.emacs} file:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2522 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2523
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2524 (require 'cc-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2525
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2526 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2527
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2528 See the sample @file{.emacs} file @ref{Sample .emacs File} for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2529 details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2530
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2531 @strong{Q.} @emph{How do I make strings, comments, keywords, and other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2532 constructs appear in different colors, or in bold face, etc.?}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2533
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2534 @strong{A.} ``Syntax Colorization'' is an Emacs 19 feature, controlled
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2535 by @code{font-lock-mode}. It is not part of @code{cc-mode}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2536
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2537 @end quotation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2538
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2539
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2540 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2541 @node Getting the latest cc-mode release, Sample .emacs File, Frequently Asked Questions, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2542 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2543
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2544 @chapter Getting the latest @code{cc-mode} release
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2545 @cindex Getting the latest @code{cc-mode} release
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2546 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2547
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2548 @code{cc-mode} is now distributed with both Emacs 19 and XEmacs 19, so
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2549 you would typically just use the version that comes with your Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2550 Users of older versions of Emacs can get the latest release from this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2551 URL:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2552
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2553 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2554
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2555 @code{ftp://ftp.python.org/pub/emacs/cc-mode.tar.gz}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2556
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2557 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2558
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2559 Note that this is a ``gzipped'' tar file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2560
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2561 If you do not have anonymous ftp access, you can get the distribution
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2562 through an anonymous ftp-to-mail gateway, such as the one run by DEC at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2563 @code{ftpmail@@decwrl.dec.com}. To get @code{cc-mode} via email, send
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2564 the following message in the body of your mail to that address:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2565 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2566
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2567 reply <a valid net address back to you>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2568 connect ftp.python.org
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2569 binary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2570 uuencode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2571 chdir pub/emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2572 get cc-mode.tar.gz
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2573
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2574 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2575 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2576 or just send the message "help" for more information on ftpmail.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2577 Response times will vary with the number of requests in the queue.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2578
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2579 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2580 @node Sample .emacs File, Requirements, Getting the latest cc-mode release, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2581 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2582
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2583 @chapter Sample @file{.emacs} file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2584 @cindex Sample @file{.emacs} file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2585 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2586
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2587 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2588 ;; Here's a sample .emacs file that might help you along the way. Just
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2589 ;; copy this region and paste it into your .emacs file. You may want to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2590 ;; change some of the actual values.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2591
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2592 (defconst my-c-style
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2593 '((c-tab-always-indent . t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2594 (c-comment-only-line-offset . 4)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2595 (c-hanging-braces-alist . ((substatement-open after)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2596 (brace-list-open)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2597 (c-hanging-colons-alist . ((member-init-intro before)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2598 (inher-intro)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2599 (case-label after)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2600 (label after)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2601 (access-label after)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2602 (c-cleanup-list . (scope-operator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2603 empty-defun-braces
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2604 defun-close-semi))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2605 (c-offsets-alist . ((arglist-close . c-lineup-arglist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2606 (substatement-open . 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2607 (case-label . 4)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2608 (block-open . 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2609 (knr-argdecl-intro . -)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2610 (c-echo-syntactic-information-p . t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2611 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2612 "My C Programming Style")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2613
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2614 ;; Customizations for all of c-mode, c++-mode, and objc-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2615 (defun my-c-mode-common-hook ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2616 ;; add my personal style and set it for the current buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2617 (c-add-style "PERSONAL" my-c-style t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2618 ;; offset customizations not in my-c-style
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2619 (c-set-offset 'member-init-intro '++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2620 ;; other customizations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2621 (setq tab-width 8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2622 ;; this will make sure spaces are used instead of tabs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2623 indent-tabs-mode nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2624 ;; we like auto-newline and hungry-delete
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2625 (c-toggle-auto-hungry-state 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2626 ;; keybindings for C, C++, and Objective-C. We can put these in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2627 ;; c-mode-map because c++-mode-map and objc-mode-map inherit it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2628 (define-key c-mode-map "\C-m" 'newline-and-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2629 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2630
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2631 ;; the following only works in Emacs 19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2632 ;; Emacs 18ers can use (setq c-mode-common-hook 'my-c-mode-common-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2633 (add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2634 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2635
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2636 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2637 @node Requirements, Limitations and Known Bugs, Sample .emacs File, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2638 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2639 @chapter Requirements
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2640 @cindex Requirements
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2641 @comment * Requirements
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2642 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2643
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2644 @cindex reporter.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2645 @file{cc-mode.el} requires @file{reporter.el} for submission of bug
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2646 reports. @file{reporter.el} is distributed with the latest Emacs 19s.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2647 Here is the Emacs Lisp Archive anonymous ftp'ing record for those of you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2648 who are using older Emacsen.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2649
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2650 @comment * Here's the Emacs Lisp Archive information for @file{reporter.el}:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2651 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2652
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2653 GNU Emacs Lisp Code Directory Apropos -- "reporter"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2654 "~/" refers to archive.cis.ohio-state.edu:/pub/gnu/emacs/elisp-archive/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2655
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2656 reporter (2.12) 06-Jul-1994
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2657 Barry A. Warsaw, <bwarsaw@@cnri.reston.va.us>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2658 ~/misc/reporter.el.Z
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2659 Customizable bug reporting of lisp programs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2660
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2661 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2662
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2663 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2664 @node Limitations and Known Bugs, Mailing Lists and Submitting Bug Reports, Requirements, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2665 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2666 @chapter Limitations and Known Bugs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2667 @cindex Limitations and Known Bugs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2668 @comment * Limitations and Known Bugs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2669 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2670
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2671 @itemize @bullet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2672 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2673 Multi-line macros are not handled properly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2674
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2675 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2676 Re-indenting large regions or expressions can be slow.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2677
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2678 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2679 Use with Emacs 18 can be slow and annoying. You should seriously
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2680 consider upgrading to Emacs 19.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2681
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2682 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2683 There is still some weird behavior when filling C block comments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2684 My suggestion is to check out add-on fill packages such as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2685 @code{filladapt}, available at the elisp archive.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2686
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2687 @cindex inline-close
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2688 @kindex TAB
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2689 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2690 Lines following @code{inline-close} braces which hang ``after'' do not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2691 line up correctly. Hit @kbd{TAB} to reindent the line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2692
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2693 @end itemize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2694
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2695 @c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2696 @node Mailing Lists and Submitting Bug Reports, Concept Index, Limitations and Known Bugs, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2697 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2698 @chapter Mailing Lists and Submitting Bug Reports
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2699 @cindex Mailing Lists and Submitting Bug Reports
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2700 @c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2701
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2702 @kindex C-c C-b
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2703 @findex c-submit-bug-report
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2704 @findex submit-bug-report (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2705 @cindex beta testers mailing list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2706 @cindex announcement mailing list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2707 To report bugs, use the @kbd{C-c C-b} (@code{c-submit-bug-report})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2708 command. This provides vital information I need to reproduce your
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2709 problem. Make sure you include a concise, but complete code example.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2710 Please try to boil your example down to just the essential code needed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2711 to reproduce the problem, and include an exact recipe of steps needed to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2712 expose the bug. Be especially sure to include any code that appears
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2713 @emph{before} your bug example.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2714
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2715 Bug reports are now to be sent to @code{bug-gnu-emacs@@prep.ai.mit.edu}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2716 which is mirrored on the Usenet newsgroup @code{gnu.emacs.bug}. Other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2717 questions and suggestions should be mailed to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2718 @code{help-gnu-emacs@@prep.ai.mit.edu} which is mirrored on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2719 @code{gnu.emacs.help}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2720
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2721 Note that the @code{cc-mode} Majordomo mailing lists have been
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2722 disbanded! With the inclusion of @code{cc-mode} in both of the latest
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2723 flavors of Emacs 19, the need for them has ended.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2724
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2725 @c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2726 @node Concept Index, Command Index, Mailing Lists and Submitting Bug Reports, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2727 @comment node-name, next, previous, up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2728 @unnumbered Concept Index
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2729 @c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2730
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2731 @printindex cp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2732
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2733
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2734 @c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2735 @node Command Index, Key Index, Concept Index, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2736 @comment node-name, next, previous, up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2737 @unnumbered Command Index
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2738 @c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2739
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2740 @ifinfo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2741
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2742 @end ifinfo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2743 Since all @code{cc-mode} commands are prepended with the string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2744 @samp{c-}, each appears under its @code{c-<thing>} name and its
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2745 @code{<thing> (c-)} name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2746 @iftex
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2747 @sp 2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2748 @end iftex
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2749 @printindex fn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2750
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2751
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2752 @c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2753 @node Key Index, Variable Index, Command Index, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2754 @comment node-name, next, previous, up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2755 @unnumbered Key Index
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2756 @c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2757
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2758 @printindex ky
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2759
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2760
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2761 @c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2762 @node Variable Index, , Key Index, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2763 @comment node-name, next, previous, up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2764 @unnumbered Variable Index
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2765 @c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2766
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2767 @ifinfo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2768
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2769 @end ifinfo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2770 Since all @code{cc-mode} variables are prepended with the string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2771 @samp{c-}, each appears under its @code{c-<thing>} name and its
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2772 @code{<thing> (c-)} name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2773 @iftex
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2774 @sp 2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2775 @end iftex
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2776 @printindex vr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2777 @summarycontents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2778 @contents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2779 @bye