annotate man/cc-mode.texi @ 26675:995b6841718b

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