Mercurial > emacs
annotate man/cc-mode.texi @ 26973:c270f9ecfecb
*** empty log message ***
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Wed, 22 Dec 1999 11:41:16 +0000 |
parents | 02eb743f6ab3 |
children | ce57565effde |
rev | line source |
---|---|
25829 | 1 \input texinfo |
2 | |
3 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
4 @comment %**start of header (This is for running Texinfo on a region) | |
5 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
6 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
7 @comment No overfull hbox marks in the dvi file. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
8 @finalout |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
9 |
26903
02eb743f6ab3
Set file name to ../info/ccmode, to avoid problems
Gerd Moellmann <gerd@gnu.org>
parents:
26819
diff
changeset
|
10 @setfilename ../info/ccmode |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
11 @settitle CC Mode Version 5 Documentation |
25829 | 12 @footnotestyle end |
13 | |
14 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
15 @comment @setchapternewpage odd !! we don't want blank pages !! | |
16 @comment %**end of header (This is for running Texinfo on a region) | |
17 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
18 | |
19 | |
20 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
21 @comment | |
22 @comment Texinfo manual for CC Mode | |
23 @comment Generated from the original README file by Krishna Padmasola | |
24 @comment <krishna@earth-gw.njit.edu> | |
25 @comment | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
26 @comment Maintained by Barry A. Warsaw and Martin Stjernholm |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
27 @comment <bug-cc-mode@gnu.org> (or <cc-mode-help@python.org>) |
25829 | 28 @comment |
29 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
30 | |
31 | |
32 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
33 @comment The following line inserts the copyright notice | |
34 @comment into the Info file. | |
35 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
36 | |
37 @ifinfo | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
38 Copyright @copyright{} 1995-1999 Free Software Foundation, Inc. |
25829 | 39 @end ifinfo |
40 | |
41 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
42 @comment !!!The titlepage section does not appear in the Info file.!!! | |
43 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
44 | |
45 @titlepage | |
46 @sp 10 | |
47 | |
48 | |
49 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
50 @comment The title is printed in a large font. | |
51 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
52 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
53 @center @titlefont{CC Mode 5.26} |
25829 | 54 @sp 2 |
55 @center @subtitlefont{A GNU Emacs mode for editing C and C-like languages} | |
56 @sp 2 | |
57 @center Barry A. Warsaw | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
58 @center Martin Stjernholm |
25829 | 59 |
60 | |
61 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
62 @comment The following two commands start the copyright page | |
63 @comment for the printed manual. This will not appear in the Info file. | |
64 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
65 | |
66 @page | |
67 @vskip 0pt plus 1filll | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
68 Copyright @copyright{} 1995-1999 Free Software Foundation, Inc. |
25829 | 69 @end titlepage |
70 | |
71 | |
72 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
73 @comment The Top node contains the master menu for the Info file. | |
74 @comment This appears only in the Info file, not the printed manual. | |
75 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
76 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
77 @node Top, Introduction, (dir), (dir) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
78 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
79 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
80 @macro ccmode |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
81 CC Mode |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
82 @end macro |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
83 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
84 @ifinfo |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
85 @top @ccmode{} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
86 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
87 @ccmode{} is a GNU Emacs mode for editing files containing C, C++, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
88 Objective-C, Java, CORBA IDL, and Pike code. It provides syntax-based |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
89 indentation and has several handy commands and some minor modes to make |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
90 the editing easier. Note that @ccmode{} does @emph{not} provide |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
91 font-locking; there are other Emacs packages for that. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
92 @end ifinfo |
25829 | 93 |
94 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
95 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
96 | |
97 @menu | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
98 * Introduction:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
99 * Getting Connected:: |
25829 | 100 * New Indentation Engine:: |
101 * Minor Modes:: | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
102 * Text Filling and Line Breaking:: |
25829 | 103 * Commands:: |
104 * Customizing Indentation:: | |
105 * Syntactic Symbols:: | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
106 * Indentation Functions:: |
25829 | 107 * Performance Issues:: |
108 * Frequently Asked Questions:: | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
109 * Getting the Latest CC Mode Release:: |
25829 | 110 * Sample .emacs File:: |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
111 * Limitations and Known Bugs:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
112 * Mailing Lists and Submitting Bug Reports:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
113 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
114 --- Indices --- |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
115 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
116 * Concept Index:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
117 * Command Index:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
118 * Key Index:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
119 * Variable Index:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
120 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
121 --- The Detailed Node Listing --- |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
122 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
123 New Indentation Engine |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
124 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
125 * Syntactic Analysis:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
126 * Indentation Calculation:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
127 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
128 Minor Modes |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
129 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
130 * Auto-newline Insertion:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
131 * Hungry-deletion of Whitespace:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
132 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
133 Auto-newline Insertion |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
134 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
135 * Hanging Braces:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
136 * Hanging Colons:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
137 * Hanging Semi-colons and Commas:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
138 * Other Electric Commands:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
139 * Clean-ups:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
140 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
141 Commands |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
142 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
143 * Indentation Commands:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
144 * Movement Commands:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
145 * Other Commands:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
146 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
147 Customizing Indentation |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
148 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
149 * Interactive Customization:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
150 * Permanent Customization:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
151 * Hooks:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
152 * Styles:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
153 * Advanced Customizations:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
154 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
155 Styles |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
156 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
157 * Built-in Styles:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
158 * Adding Styles:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
159 * File Styles:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
160 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
161 Advanced Customizations |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
162 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
163 * Custom Indentation Functions:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
164 * Custom Brace and Colon Hanging:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
165 * Customizing Semi-colons and Commas:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
166 * Other Special Indentations:: |
25829 | 167 @end menu |
168 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
169 |
25829 | 170 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
171 @node Introduction, Getting Connected, Top, Top |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
172 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
173 @chapter Introduction |
25829 | 174 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
175 | |
176 @cindex BOCM | |
177 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
178 Welcome to @ccmode{}, a GNU Emacs mode for editing files containing C, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
179 C++, Objective-C, Java, CORBA IDL, and Pike code. This incarnation of |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
180 the mode is descendant from @file{c-mode.el} (also called "Boring Old C |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
181 Mode" or BOCM @t{:-)}, and @file{c++-mode.el} version 2, which Barry has |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
182 been maintaining since 1992. @ccmode{} represents a significant |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
183 milestone in the mode's life. It has been fully merged back with Emacs |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
184 19's @file{c-mode.el}. Also a new, more intuitive and flexible mechanism |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
185 for controlling indentation has been developed. Late in 1997, Martin |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
186 joined the @ccmode{} Maintainers Team, and implemented the Pike support. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
187 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
188 This manual describes @ccmode{} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
189 @comment The following line must appear on its own, so that the automated |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
190 version 5.26. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
191 @comment Release.py script can update the version number automatically |
25829 | 192 |
193 @ccmode{} supports the editing of K&R and ANSI C, @dfn{ARM} | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
194 @footnote{@cite{The Annotated C++ Reference Manual}, by Ellis and |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
195 Stroustrup.} C++, Objective-C, Java, CORBA's Interface Definition |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
196 Language, and Pike@footnote{A C-like scripting language with its roots |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
197 in the LPC language used in some MUD engines. See |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
198 @uref{http://pike.idonex.se/}.} files. In this way, you can easily set |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
199 up consistent coding styles for use in editing all of these languages. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
200 @ccmode{} does @emph{not} handle font-locking (a.k.a. syntax coloring, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
201 keyword highlighting) or anything of that nature, for any of these |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
202 modes. Font-locking is handled by other Emacs packages. |
25829 | 203 |
204 This manual will describe the following: | |
205 | |
206 @itemize @bullet | |
207 @item | |
208 How to get started using @ccmode{}. | |
209 | |
210 @item | |
211 How the new indentation engine works. | |
212 | |
213 @item | |
214 How to customize the new indentation engine. | |
215 | |
216 @end itemize | |
217 | |
218 @findex c-mode | |
219 @findex c++-mode | |
220 @findex objc-mode | |
221 @findex java-mode | |
222 @findex idl-mode | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
223 @findex pike-mode |
25829 | 224 Note that the name of this package is ``@ccmode{}'', but there is no top |
225 level @code{cc-mode} entry point. All of the variables, commands, and | |
226 functions in @ccmode{} are prefixed with @code{c-@var{<thing>}}, and | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
227 @code{c-mode}, @code{c++-mode}, @code{objc-mode}, @code{java-mode}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
228 @code{idl-mode}, and @code{pike-mode} entry points are provided. This |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
229 package is intended to be a replacement for @file{c-mode.el} and |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
230 @file{c++-mode.el}. |
25829 | 231 |
232 @cindex @file{cc-compat.el} file | |
233 This distribution also contains a file | |
234 called @file{cc-compat.el} which should ease your transition from BOCM | |
235 to @ccmode{}. If you have a BOCM configuration you are really happy | |
236 with, and want to postpone learning how to configure @ccmode{}, take a | |
237 look at that file. It maps BOCM configuration variables to @ccmode{}'s | |
238 new indentation model. It is not actively supported so for the long | |
239 run, you should learn how to customize @ccmode{} to support your coding | |
240 style. | |
241 | |
242 A special word of thanks goes to Krishna Padmasola for his work in | |
243 converting the original @file{README} file to Texinfo format. I'd also | |
244 like to thank all the @ccmode{} victims who help enormously during the | |
245 early beta stages of @ccmode{}'s development. | |
246 | |
247 | |
248 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
249 @node Getting Connected, New Indentation Engine, Introduction, Top |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
250 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
251 @chapter Getting Connected |
25829 | 252 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
253 | |
254 If you got this version of @ccmode{} with Emacs or XEmacs, it should | |
255 work just fine right out of the box. Note however that you may not have | |
256 the latest @ccmode{} release and may want to upgrade your copy. | |
257 | |
258 If you are upgrading an existing @ccmode{} installation, please see the | |
259 @file{README} file for installation details. @ccmode{} may not work | |
260 with older versions of Emacs or XEmacs. See the @ccmode{} release notes | |
261 Web pages for the latest information on Emacs version and package | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
262 compatibility (@pxref{Getting the Latest CC Mode Release}). |
25829 | 263 |
264 @cindex @file{cc-mode-18.el} file | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
265 @emph{Note that @ccmode{} no longer |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
266 works with Emacs 18!}, so if you haven't upgraded from Emacs 18 by now, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
267 you are out of luck. |
25829 | 268 |
269 @findex c-version | |
270 @findex version (c-) | |
271 You can find out what version of @ccmode{} you are using by visiting a C | |
272 file and entering @kbd{M-x c-version RET}. You should see this message in | |
273 the echo area: | |
274 @example | |
275 | |
276 Using CC Mode version 5.XX | |
277 | |
278 @end example | |
279 | |
280 @noindent | |
281 where @samp{XX} is the minor release number. | |
282 | |
283 | |
284 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
285 @node New Indentation Engine, Minor Modes, Getting Connected, Top |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
286 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
287 @chapter New Indentation Engine |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
288 @cindex indentation engine |
25829 | 289 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
290 | |
291 @ccmode{} has a new indentation engine, providing a simplified, yet | |
292 flexible and general mechanism for customizing indentation. It separates | |
293 indentation calculation into two steps: first, @ccmode{} analyzes the | |
294 line of code being indented to determine the kind of language construct | |
295 it's looking at, then it applies user defined offsets to the current | |
296 line based on this analysis. | |
297 | |
298 This section will briefly cover how indentation is calculated in | |
299 @ccmode{}. It is important to understand the indentation model | |
300 being used so that you will know how to customize @ccmode{} for | |
301 your personal coding style. | |
302 | |
303 @menu | |
304 * Syntactic Analysis:: | |
305 * Indentation Calculation:: | |
306 @end menu | |
307 | |
308 | |
309 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
310 @node Syntactic Analysis, Indentation Calculation, , New Indentation Engine |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
311 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
312 @section Syntactic Analysis |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
313 @cindex syntactic analysis |
25829 | 314 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
315 | |
316 @cindex relative buffer position | |
317 @cindex syntactic symbol | |
318 @cindex syntactic component | |
319 @cindex syntactic component list | |
320 The first thing @ccmode{} does when indenting a line of code, is to | |
321 analyze the line, determining the @dfn{syntactic component list} of the | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
322 construct on that line. A syntactic component consists of a pair of |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
323 information (in lisp parlance, a @emph{cons cell}), where the first part |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
324 is a @dfn{syntactic symbol}, and the second part is a @dfn{relative |
25829 | 325 buffer position}. Syntactic symbols describe elements of C code |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
326 @footnote{Unless otherwise noted, the term ``C code'' to refers to all |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
327 the C-like languages.}, e.g. @code{statement}, @code{substatement}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
328 @code{class-open}, @code{class-close}, etc. @xref{Syntactic Symbols}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
329 for a complete list of currently recognized syntactic symbols and their |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
330 semantics. The style variable @code{c-offsets-alist} also contains the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
331 list of currently supported syntactic symbols. |
25829 | 332 |
333 Conceptually, a line of C code is always indented relative to the | |
334 indentation of some line higher up in the buffer. This is represented | |
335 by the relative buffer position in the syntactic component. | |
336 | |
337 Here is an example. Suppose we had the following code as the only thing | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
338 in a C++ buffer @footnote{The line numbers in this and future examples |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
339 don't actually appear in the buffer, of course!}: |
25829 | 340 @example |
341 @group | |
342 | |
343 1: void swap( int& a, int& b ) | |
344 2: @{ | |
345 3: int tmp = a; | |
346 4: a = b; | |
347 5: b = tmp; | |
348 6: @} | |
349 | |
350 @end group | |
351 @end example | |
352 | |
353 @kindex C-c C-s | |
354 @findex c-show-syntactic-information | |
355 @findex show-syntactic-information (c-) | |
356 We can use the command @kbd{C-c C-s} | |
357 (@code{c-show-syntactic-information}) to simply report what the | |
358 syntactic analysis is for the current line. Running this command on | |
359 line 4 of this example, we'd see in the echo area@footnote{With a universal | |
360 argument (i.e. @kbd{C-u C-c C-s}) the analysis is inserted into the | |
361 buffer as a comment | |
362 on the current line.}: | |
363 @example | |
364 | |
365 ((statement . 35)) | |
366 | |
367 @end example | |
368 | |
369 This tells us that the line is a statement and it is indented relative | |
370 to buffer position 35, which happens to be the @samp{i} in @code{int} on | |
371 line 3. If you were to move point to line 3 and hit @kbd{C-c C-s}, you | |
372 would see: | |
373 @example | |
374 | |
375 ((defun-block-intro . 29)) | |
376 | |
377 @end example | |
378 | |
379 This indicates that the @samp{int} line is the first statement in a top | |
380 level function block, and is indented relative to buffer position 29, | |
381 which is the brace just after the function header. | |
382 | |
383 Here's another example: | |
384 @example | |
385 @group | |
386 | |
387 1: int add( int val, int incr, int doit ) | |
388 2: @{ | |
389 3: if( doit ) | |
390 4: @{ | |
391 5: return( val + incr ); | |
392 6: @} | |
393 7: return( val ); | |
394 8: @} | |
395 | |
396 @end group | |
397 @end example | |
398 | |
399 @noindent | |
400 Hitting @kbd{C-c C-s} on line 4 gives us: | |
401 @example | |
402 | |
403 ((substatement-open . 46)) | |
404 | |
405 @end example | |
406 | |
407 @cindex substatement | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
408 @cindex substatement block |
25829 | 409 @noindent |
410 which tells us that this is a brace that @emph{opens} a substatement | |
411 block. @footnote{A @dfn{substatement} is the line after a | |
412 conditional statement, such as @code{if}, @code{else}, @code{while}, | |
413 @code{do}, @code{switch}, etc. A @dfn{substatement | |
414 block} is a brace block following one of these conditional statements.} | |
415 | |
416 @cindex comment-only line | |
417 Syntactic component lists can contain more than one component, and | |
418 individual syntactic components need not have relative buffer positions. | |
419 The most common example of this is a line that contains a @dfn{comment | |
420 only line}. | |
421 @example | |
422 @group | |
423 | |
424 1: void draw_list( List<Drawables>& drawables ) | |
425 2: @{ | |
426 3: // call the virtual draw() method on each element in list | |
427 4: for( int i=0; i < drawables.count(), ++i ) | |
428 5: @{ | |
429 6: drawables[i].draw(); | |
430 7: @} | |
431 8: @} | |
432 | |
433 @end group | |
434 @end example | |
435 | |
436 @noindent | |
437 Hitting @kbd{C-c C-s} on line 3 of this example gives: | |
438 @example | |
439 | |
440 ((comment-intro) (defun-block-intro . 46)) | |
441 | |
442 @end example | |
443 | |
444 @noindent | |
445 and you can see that the syntactic component list contains two syntactic | |
446 components. Also notice that the first component, | |
447 @samp{(comment-intro)} has no relative buffer position. | |
448 | |
449 | |
450 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
451 @node Indentation Calculation, , Syntactic Analysis, New Indentation Engine |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
452 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
453 @section Indentation Calculation |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
454 @cindex indentation calculation |
25829 | 455 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
456 | |
457 Indentation for a line is calculated using the syntactic | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
458 component list derived in step 1 above (@pxref{Syntactic Analysis}). |
25829 | 459 Each component contributes to the final total indentation of the line in |
460 two ways. | |
461 | |
462 First, the syntactic symbols are looked up in the @code{c-offsets-alist} | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
463 style variable, which is an association list of syntactic symbols and |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
464 the offsets to apply for those symbols. These offsets are added to a |
25829 | 465 running total. |
466 | |
467 Second, if the component has a relative buffer position, @ccmode{} | |
468 adds the column number of that position to the running total. By adding | |
469 up the offsets and columns for every syntactic component on the list, | |
470 the final total indentation for the current line is computed. | |
471 | |
472 Let's use our two code examples above to see how this works. Here is | |
473 our first example again: | |
474 @example | |
475 @group | |
476 | |
477 1: void swap( int& a, int& b ) | |
478 2: @{ | |
479 3: int tmp = a; | |
480 4: a = b; | |
481 5: b = tmp; | |
482 6: @} | |
483 | |
484 @end group | |
485 @end example | |
486 | |
487 Let's say point is on line 3 and we hit the @kbd{TAB} key to re-indent | |
488 the line. Remember that the syntactic component list for that | |
489 line is: | |
490 @example | |
491 | |
492 ((defun-block-intro . 29)) | |
493 | |
494 @end example | |
495 | |
496 @noindent | |
497 @ccmode{} looks up @code{defun-block-intro} in the | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
498 @code{c-offsets-alist} style variable. Let's say it finds the value |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
499 @samp{4}; it adds this to the running total (initialized to zero), |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
500 yielding a running total indentation of 4 spaces. |
25829 | 501 |
502 Next @ccmode{} goes to buffer position 29 and asks for the current | |
503 column. This brace is in column zero, so @ccmode{} | |
504 adds @samp{0} to the running total. Since there is only one syntactic | |
505 component on the list for this line, indentation calculation is | |
506 complete, and the total indentation for the line | |
507 is 4 spaces. | |
508 | |
509 Here's another example: | |
510 @example | |
511 @group | |
512 | |
513 1: int add( int val, int incr, int doit ) | |
514 2: @{ | |
515 3: if( doit ) | |
516 4: @{ | |
517 5: return( val + incr ); | |
518 6: @} | |
519 7: return( val ); | |
520 8: @} | |
521 | |
522 @end group | |
523 @end example | |
524 | |
525 If we were to hit @kbd{TAB} on line 4 in the above example, the same | |
526 basic process is performed, despite the differences in the syntactic | |
527 component list. Remember that the list for this line is: | |
528 @example | |
529 | |
530 ((substatement-open . 46)) | |
531 | |
532 @end example | |
533 | |
534 Here, @ccmode{} first looks up the @code{substatement-open} symbol | |
535 in @code{c-offsets-alist}. Let's say it finds the value @samp{4}. This | |
536 yields a running total of 4. @ccmode{} then goes to | |
537 buffer position 46, which is the @samp{i} in @code{if} on line 3. This | |
538 character is in the fourth column on that line so adding this to the | |
539 running total yields an indentation for the line of 8 spaces. | |
540 | |
541 Simple, huh? | |
542 | |
543 Actually, the mode usually just does The Right Thing without you having | |
544 to think about it in this much detail. But when customizing | |
545 indentation, it's helpful to understand the general indentation model | |
546 being used. | |
547 | |
548 @vindex c-echo-syntactic-information-p | |
549 @vindex echo-syntactic-information-p (c-) | |
550 As you configure @ccmode{}, you might want to set the variable | |
551 @code{c-echo-syntactic-information-p} to non-@code{nil} so that the | |
552 syntactic component list and calculated offset will always be echoed in | |
553 the minibuffer when you hit @kbd{TAB}. | |
554 | |
555 | |
556 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
557 @node Minor Modes, Text Filling and Line Breaking, New Indentation Engine, Top |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
558 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
559 @chapter Minor Modes |
25829 | 560 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
561 | |
562 @ccmode{} contains two minor-mode-like features that you should | |
563 find useful while you enter new C code. The first is called | |
564 @dfn{auto-newline} mode, and the second is called @dfn{hungry-delete} | |
565 mode. These minor modes can be toggled on and off independently, and | |
566 @ccmode{} can be configured so that it starts up with any | |
567 combination of these minor modes. By default, both of these minor modes | |
568 are turned off. | |
569 | |
570 The state of the minor modes is always reflected in the minor mode list | |
571 on the modeline of the @ccmode{} buffer. When auto-newline mode is | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
572 enabled, you will see @samp{C/a} on the mode line @footnote{The @samp{C} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
573 would be replaced with @samp{C++}, @samp{ObjC}, @samp{Java}, @samp{IDL}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
574 or @samp{Pike} for the respective languages.}. When hungry delete mode |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
575 is enabled you would see @samp{C/h} and when both modes are enabled, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
576 you'd see @samp{C/ah}. |
25829 | 577 |
578 @kindex C-c C-a | |
579 @kindex C-c C-d | |
580 @kindex C-c C-t | |
581 @findex c-toggle-hungry-state | |
582 @findex c-toggle-auto-state | |
583 @findex c-toggle-auto-hungry-state | |
584 @findex toggle-hungry-state (c-) | |
585 @findex toggle-auto-state (c-) | |
586 @findex toggle-auto-hungry-state (c-) | |
587 @ccmode{} provides keybindings which allow you to toggle the minor | |
588 modes on the fly while editing code. To toggle just the auto-newline | |
589 state, hit @kbd{C-c C-a} (@code{c-toggle-auto-state}). When you do | |
590 this, you should see the @samp{a} indicator either appear or disappear | |
591 on the modeline. Similarly, to toggle just the hungry-delete state, use | |
592 @kbd{C-c C-d} (@code{c-toggle-hungry-state}), and to toggle both states, | |
593 use @kbd{C-c C-t} (@code{c-toggle-auto-hungry-state}). | |
594 | |
595 To set up the auto-newline and hungry-delete states to your preferred | |
596 values, you would need to add some lisp to your @file{.emacs} file that | |
597 called one of the @code{c-toggle-*-state} functions directly. When | |
598 called programmatically, each function takes a numeric value, where | |
599 a positive number enables the minor mode, a negative number disables the | |
600 mode, and zero toggles the current state of the mode. | |
601 | |
602 So for example, if you wanted to enable both auto-newline and | |
603 hungry-delete for all your C file editing, you could add the following | |
604 to your @file{.emacs} file: | |
605 @example | |
606 | |
607 (add-hook 'c-mode-common-hook | |
608 '(lambda () (c-toggle-auto-hungry-state 1))) | |
609 | |
610 @end example | |
611 | |
612 | |
613 @cindex electric characters | |
614 | |
615 @menu | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
616 * Auto-newline Insertion:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
617 * Hungry-deletion of Whitespace:: |
25829 | 618 @end menu |
619 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
620 |
25829 | 621 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
622 @node Auto-newline Insertion, Hungry-deletion of Whitespace, , Minor Modes |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
623 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
624 @section Auto-newline Insertion |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
625 @cindex auto-newline insertion |
25829 | 626 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
627 | |
628 @cindex electric commands | |
629 Auto-newline minor mode works by enabling certain @dfn{electric | |
630 commands}. Electric commands are typically bound to special characters | |
631 such as the left and right braces, colons, semi-colons, etc., which when | |
632 typed, perform some magic formatting in addition to inserting the typed | |
633 character. As a general rule, electric commands are only electric when | |
634 the following conditions apply: | |
635 | |
636 @itemize @bullet | |
637 @item | |
638 Auto-newline minor mode is enabled, as evidenced by a @samp{C/a} or | |
639 @samp{C/ah} indicator on the modeline. | |
640 | |
641 @cindex literal | |
642 @cindex syntactic whitespace | |
643 @item | |
644 The character was not typed inside of a literal @footnote{A | |
645 @dfn{literal} is defined as any comment, string, or C preprocessor macro | |
646 definition. These constructs are also known as @dfn{syntactic | |
647 whitespace} since they are usually ignored when scanning C code.}. | |
648 | |
649 @item | |
650 @kindex C-u | |
651 No numeric argument was supplied to the command (i.e. it was typed as | |
652 normal, with no @kbd{C-u} prefix). | |
653 | |
654 @end itemize | |
655 | |
656 @menu | |
657 * Hanging Braces:: | |
658 * Hanging Colons:: | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
659 * Hanging Semi-colons and Commas:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
660 * Other Electric Commands:: |
25829 | 661 * Clean-ups:: |
662 @end menu | |
663 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
664 |
25829 | 665 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
666 @node Hanging Braces, Hanging Colons, , Auto-newline Insertion |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
667 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
668 @subsection Hanging Braces |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
669 @cindex hanging braces |
25829 | 670 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
671 | |
672 @findex c-electric-brace | |
673 @findex electric-brace (c-) | |
674 @vindex c-hanging-braces-alist | |
675 @vindex hanging-braces-alist (c-) | |
676 When you type either an open or close brace (i.e. @kbd{@{} or @kbd{@}}), | |
677 the electric command @code{c-electric-brace} gets run. This command has | |
678 two electric formatting behaviors. First, it will perform some | |
679 re-indentation of the line the brace was typed on, and second, it will | |
680 add various newlines before and/or after the typed brace. | |
681 Re-indentation occurs automatically whenever the electric behavior is | |
682 enabled. If the brace ends up on a line other than the one it was typed | |
683 on, then that line is also re-indented. | |
684 | |
685 @cindex class-open syntactic symbol | |
686 @cindex class-close syntactic symbol | |
687 @cindex defun-open syntactic symbol | |
688 @cindex defun-close syntactic symbol | |
689 @cindex inline-open syntactic symbol | |
690 @cindex inline-close syntactic symbol | |
691 @cindex brace-list-open syntactic symbol | |
692 @cindex brace-list-close syntactic symbol | |
693 @cindex brace-list-intro syntactic symbol | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
694 @cindex brace-entry-open syntactic symbol |
25829 | 695 @cindex block-open syntactic symbol |
696 @cindex block-close syntactic symbol | |
697 @cindex substatement-open syntactic symbol | |
698 @cindex statement-case-open syntactic symbol | |
699 @cindex extern-lang-open syntactic symbol | |
700 @cindex extern-lang-close syntactic symbol | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
701 @cindex namespace-open syntactic symbol |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
702 @cindex namespace-close syntactic symbol |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
703 @cindex inexpr-class-open symbol |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
704 @cindex inexpr-class-close symbol |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
705 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
706 The default in auto-newline mode is to insert newlines both before and |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
707 after a brace, but that can be controlled by the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
708 @code{c-hanging-braces-alist} style variable. This variable contains a |
25829 | 709 mapping between syntactic symbols related to braces, and a list of |
710 places to insert a newline. The syntactic symbols that are useful for | |
711 this list are: @code{class-open}, @code{class-close}, @code{defun-open}, | |
712 @code{defun-close}, @code{inline-open}, @code{inline-close}, | |
713 @code{brace-list-open}, @code{brace-list-close}, | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
714 @code{brace-list-intro}, @code{brace-entry-open}, @code{block-open}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
715 @code{block-close}, @code{substatement-open}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
716 @code{statement-case-open}, @code{extern-lang-open}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
717 @code{extern-lang-close}, @code{namespace-open}, @code{namespace-close}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
718 @code{inexpr-class-open}, and @code{inexpr-class-close}@footnote{Note |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
719 that the aggregate constructs in Pike mode, @samp{(@{}, @samp{@})}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
720 @samp{([}, @samp{])}, and @samp{(<}, @samp{>)}, do not count as brace |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
721 lists in this regard, even though they do for normal indentation |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
722 purposes. It's currently not possible to set automatic newlines on |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
723 these constructs.}. @xref{Syntactic Symbols}, for a more detailed |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
724 description of these syntactic symbols, except for |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
725 @code{inexpr-class-open} and @code{inexpr-class-close}, which aren't |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
726 actual syntactic symbols. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
727 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
728 The braces of anonymous inner classes in Java are given the special |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
729 symbols @code{inexpr-class-open} and @code{inexpr-class-close}, so that |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
730 they can be distinguished from the braces of normal classes@footnote{The |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
731 braces of anonymous classes produces a combination of |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
732 @code{inexpr-class}, and @code{class-open} or @code{class-close} in |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
733 normal indentation analysis.}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
734 |
25829 | 735 The value associated with each syntactic symbol in this association list |
736 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
|
737 @xref{Custom Brace and Colon Hanging}, for a more detailed discussion of |
25829 | 738 using a function as a brace hanging @var{ACTION}. |
739 | |
740 When the @var{ACTION} is a list, it can contain any combination of the | |
741 symbols @code{before} and @code{after}, directing @ccmode{} where to | |
742 put newlines in relationship to the brace being inserted. Thus, if the | |
743 list contains only the symbol @code{after}, then the brace is said to | |
744 @dfn{hang} on the right side of the line, as in: | |
745 @example | |
746 @group | |
747 | |
748 // here, open braces always `hang' | |
749 void spam( int i ) @{ | |
750 if( i == 7 ) @{ | |
751 dosomething(i); | |
752 @} | |
753 @} | |
754 | |
755 | |
756 @end group | |
757 @end example | |
758 | |
759 When the list contains both @code{after} and @code{before}, the braces | |
760 will appear on a line by themselves, as shown by the close braces in the | |
761 above example. The list can also be empty, in which case no newlines | |
762 are added either before or after the brace. | |
763 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
764 If a syntactic symbol is missing entirely from |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
765 @code{c-hanging-braces-alist}, it's treated in the same way as an |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
766 @var{ACTION} with a list containing @code{before} and @code{after}, so |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
767 that braces by default end up on their own line. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
768 |
25829 | 769 For example, the default value of @code{c-hanging-braces-alist} is: |
770 @example | |
771 @group | |
772 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
773 ((brace-list-open) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
774 (brace-entry-open) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
775 (substatement-open after) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
776 (block-close . c-snug-do-while) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
777 (extern-lang-open after) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
778 (inexpr-class-open after) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
779 (inexpr-class-close before)) |
25829 | 780 |
781 @end group | |
782 @end example | |
783 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
784 @noindent which says that @code{brace-list-open} and |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
785 @code{brace-entry-open} braces should both hang on the right side, and |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
786 allow subsequent text to follow on the same line as the brace. Also, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
787 @code{substatement-open}, @code{extern-lang-open}, and |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
788 @code{inexpr-class-open} braces should hang on the right side, but |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
789 subsequent text should follow on the next line. The opposite holds for |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
790 @code{inexpr-class-close} braces; they won't hang, but the following |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
791 text continues on the same line. Here, in the @code{block-close} entry, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
792 you also see an example of using a function as an @var{ACTION}. In all |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
793 other cases, braces are put on a line by themselves. |
25829 | 794 |
795 A word of caution: it is not a good idea to hang top-level construct | |
796 introducing braces, such as @code{class-open} or @code{defun-open}. | |
797 Emacs makes an assumption that such braces will always appear in column | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
798 zero, hanging them can introduce performance problems. |
26490
2b08d829af86
Fix complaints from makeinfo 4.0.
Eli Zaretskii <eliz@gnu.org>
parents:
25829
diff
changeset
|
799 @xref{Performance Issues}, for more information. |
25829 | 800 |
801 | |
802 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
803 @node Hanging Colons, Hanging Semi-colons and Commas, Hanging Braces, Auto-newline Insertion |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
804 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
805 @subsection Hanging Colons |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
806 @cindex hanging colons |
25829 | 807 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
808 | |
809 @vindex hanging-colons-alist (c-) | |
810 @vindex c-hanging-colons-alist | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
811 Using a mechanism similar to brace hanging (@pxref{Hanging Braces}), |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
812 colons can also be made to hang using the style variable |
25829 | 813 @code{c-hanging-colons-alist}. The syntactic symbols appropriate for |
814 this assocation list are: @code{case-label}, @code{label}, | |
815 @code{access-label}, @code{member-init-intro}, and @code{inher-intro}. | |
816 Note however that for @code{c-hanging-colons-alist}, @var{ACTION}s as | |
817 functions are not supported. See also @ref{Custom Brace and Colon | |
818 Hanging} for details. | |
819 | |
820 In C++, double-colons are used as a scope operator but because these | |
821 colons always appear right next to each other, newlines before and after | |
822 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
|
823 @ccmode{}. @xref{Clean-ups}, for details. |
25829 | 824 |
825 | |
826 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
827 @node Hanging Semi-colons and Commas, Other Electric Commands, Hanging Colons, Auto-newline Insertion |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
828 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
829 @subsection Hanging Semi-colons and Commas |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
830 @cindex hanging semi-colons |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
831 @cindex hanging commas |
25829 | 832 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
833 | |
834 Semicolons and commas are also electric in @ccmode{}, but since | |
835 these characters do not correspond directly to syntactic symbols, a | |
836 different mechanism is used to determine whether newlines should be | |
837 automatically inserted after these characters. @xref{Customizing | |
26490
2b08d829af86
Fix complaints from makeinfo 4.0.
Eli Zaretskii <eliz@gnu.org>
parents:
25829
diff
changeset
|
838 Semi-colons and Commas}, for details. |
25829 | 839 |
840 | |
841 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
842 @node Other Electric Commands, Clean-ups, Hanging Semi-colons and Commas, Auto-newline Insertion |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
843 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
844 @subsection Other Electric Commands |
25829 | 845 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
846 | |
847 @kindex # | |
848 @findex c-electric-pound | |
849 @vindex c-electric-pound-behavior | |
850 @findex electric-pound (c-) | |
851 @vindex electric-pound-behavior (c-) | |
852 A few other keys also provide electric behavior. For example | |
853 @kbd{#} (@code{c-electric-pound}) is electric when typed as | |
854 the first non-whitespace character on a line. In this case, the | |
855 variable @code{c-electric-pound-behavior} is consulted for the electric | |
856 behavior. This variable takes a list value, although the only element | |
857 currently defined is @code{alignleft}, which tells this command to force | |
858 the @samp{#} character into column zero. This is useful for entering | |
859 C preprocessor macro definitions. | |
860 | |
861 @findex c-electric-star | |
862 @findex c-electric-slash | |
863 @findex electric-star (c-) | |
864 @findex electric-slash (c-) | |
865 Stars and slashes (i.e. @kbd{*} and @kbd{/}, @code{c-electric-star} and | |
866 @code{c-electric-slash} respectively) are also electric under | |
867 certain circumstances. If a star is inserted as the second character of | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
868 a C style block comment on a comment-only line, then the comment |
25829 | 869 delimiter is indented as defined by @code{c-offsets-alist}. A |
870 comment-only line is defined as a line which contains only a comment, as | |
871 in: | |
872 @example | |
873 @group | |
874 | |
875 void spam( int i ) | |
876 @{ | |
877 // this is a comment-only line... | |
878 if( i == 7 ) // but this is not | |
879 @{ | |
880 dosomething(i); | |
881 @} | |
882 @} | |
883 | |
884 @end group | |
885 @end example | |
886 | |
887 Likewise, if a slash is inserted as the second slash in a C++ style line | |
888 comment (also only on a comment-only line), then the line is indented as | |
889 defined by @code{c-offsets-alist}. | |
890 | |
891 @findex c-electric-lt-gt | |
892 @findex electric-lt-gt (c-) | |
893 @kindex < | |
894 @kindex > | |
895 Less-than and greater-than signs (@code{c-electric-lt-gt}) are also | |
896 electric, but only in C++ mode. Hitting the second of two @kbd{<} or | |
897 @kbd{>} keys re-indents the line if it is a C++ style stream operator. | |
898 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
899 @findex c-electric-paren |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
900 @findex electric-paren (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
901 @kindex ( |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
902 @kindex ) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
903 The normal parenthesis characters @samp{(} and @samp{)} also reindent |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
904 the current line if they are used in normal code. This is useful for |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
905 getting the closing parenthesis of an argument list aligned |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
906 automatically. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
907 |
25829 | 908 |
909 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
910 @node Clean-ups, , Other Electric Commands, Auto-newline Insertion |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
911 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
912 @subsection Clean-ups |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
913 @cindex clean-ups |
25829 | 914 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
915 | |
916 @dfn{Clean-ups} are a mechanism complementary to colon and brace | |
917 hanging. On the surface, it would seem that clean-ups overlap the | |
918 functionality provided by the @code{c-hanging-*-alist} variables, and | |
919 similarly, clean-ups are only enabled when auto-newline minor mode is | |
920 enabled. Clean-ups are used however to adjust code ``after-the-fact'', | |
921 i.e. to eliminate some whitespace that is inserted by electric | |
922 commands, or whitespace that contains intervening constructs. | |
923 | |
924 @vindex c-cleanup-list | |
925 @vindex cleanup-list (c-) | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
926 @cindex literal |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
927 You can configure @ccmode{}'s clean-ups by setting the style variable |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
928 @code{c-cleanup-list}, which is a list of clean-up symbols. By default, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
929 @ccmode{} cleans up only the @code{scope-operator} construct, which is |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
930 necessary for proper C++ support. Note that clean-ups are only |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
931 performed when the construct does not occur within a literal |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
932 (@pxref{Auto-newline Insertion}), and when there is nothing but |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
933 whitespace appearing between the individual components of the construct. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
934 |
25829 | 935 There are currently only five specific constructs that @ccmode{} |
936 can clean up, as indicated by these symbols: | |
937 | |
938 @itemize @bullet | |
939 @item | |
940 @code{brace-else-brace} --- cleans up @samp{@} else @{} constructs by | |
941 placing the entire construct on a single line. Clean-up occurs when the | |
942 open brace after the @samp{else} is typed. So for example, this: | |
943 @example | |
944 @group | |
945 | |
946 void spam(int i) | |
947 @{ | |
948 if( i==7 ) | |
949 @{ | |
950 dosomething(); | |
951 @} | |
952 else | |
953 @{ | |
954 | |
955 @end group | |
956 @end example | |
957 @noindent | |
958 appears like this after the open brace is typed: | |
959 @example | |
960 @group | |
961 | |
962 void spam(int i) | |
963 @{ | |
964 if( i==7 ) @{ | |
965 dosomething(); | |
966 @} else @{ | |
967 | |
968 @end group | |
969 @end example | |
970 | |
971 @item | |
972 @code{brace-elseif-brace} --- similar to the @code{brace-else-brace} | |
973 clean-up, but this cleans up @samp{@} else if (...) @{} constructs. For | |
974 example: | |
975 @example | |
976 @group | |
977 | |
978 void spam(int i) | |
979 @{ | |
980 if( i==7 ) | |
981 @{ | |
982 dosomething(); | |
983 @} | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
984 else if( i==3 ) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
985 @{ |
25829 | 986 |
987 @end group | |
988 @end example | |
989 @noindent | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
990 appears like this after the open parenthesis is typed: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
991 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
992 @group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
993 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
994 void spam(int i) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
995 @{ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
996 if( i==7 ) @{ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
997 dosomething(); |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
998 @} else if( i==3 ) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
999 @{ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1000 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1001 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1002 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1003 @noindent |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1004 and like this after the open brace is typed: |
25829 | 1005 @example |
1006 @group | |
1007 | |
1008 void spam(int i) | |
1009 @{ | |
1010 if( i==7 ) @{ | |
1011 dosomething(); | |
1012 @} else if( i==3 ) @{ | |
1013 | |
1014 @end group | |
1015 @end example | |
1016 | |
1017 @item | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1018 @code{brace-catch-brace} --- analogous to @code{brace-elseif-brace}, but |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1019 cleans up @samp{@} catch (...) @{} in C++ and Java mode. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1020 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1021 @item |
25829 | 1022 @code{empty-defun-braces} --- cleans up braces following a top-level |
1023 function or class definition that contains no body. Clean up occurs | |
1024 when the closing brace is typed. Thus the following: | |
1025 @example | |
1026 @group | |
1027 | |
1028 class Spam | |
1029 @{ | |
1030 @} | |
1031 | |
1032 @end group | |
1033 @end example | |
1034 @noindent | |
1035 is transformed into this when the close brace is typed: | |
1036 @example | |
1037 @group | |
1038 | |
1039 class Spam | |
1040 @{@} | |
1041 | |
1042 @end group | |
1043 @end example | |
1044 | |
1045 @item | |
1046 @code{defun-close-semi} --- cleans up the terminating semi-colon on | |
1047 top-level function or class definitions when they follow a close | |
1048 brace. Clean up occurs when the semi-colon is typed. | |
1049 So for example, the following: | |
1050 @example | |
1051 @group | |
1052 | |
1053 class Spam | |
1054 @{ | |
1055 @} | |
1056 ; | |
1057 | |
1058 @end group | |
1059 @end example | |
1060 @noindent | |
1061 is transformed into this when the semi-colon is typed: | |
1062 | |
1063 @example | |
1064 @group | |
1065 | |
1066 class Spam | |
1067 @{ | |
1068 @}; | |
1069 | |
1070 @end group | |
1071 @end example | |
1072 | |
1073 @item | |
1074 @code{list-close-comma} --- cleans up commas following braces in array | |
1075 and aggregate initializers. Clean up occurs when the comma is typed. | |
1076 | |
1077 @item | |
1078 @code{scope-operator} --- cleans up double colons which may designate a | |
1079 C++ scope operator split across multiple lines@footnote{Certain C++ | |
1080 constructs introduce ambiguous situations, so @code{scope-operator} | |
1081 clean-ups may not always be correct. This usually only occurs when | |
1082 scoped identifiers appear in switch label tags.}. Clean up occurs when | |
1083 the second colon is typed. You will always want @code{scope-operator} | |
1084 in the @code{c-cleanup-list} when you are editing C++ code. | |
1085 | |
1086 @end itemize | |
1087 | |
1088 | |
1089 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1090 @node Hungry-deletion of Whitespace, , Auto-newline Insertion, Minor Modes |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1091 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1092 @section Hungry-deletion of Whitespace |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1093 @cindex hungry-deletion of whitespace |
25829 | 1094 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
1095 | |
1096 Hungry deletion of whitespace, or as it more commonly called, | |
1097 @dfn{hungry-delete mode}, is a simple feature that some people find | |
1098 extremely useful. In fact, you might find yourself wanting | |
1099 hungry-delete in @strong{all} your editing modes! | |
1100 | |
1101 @kindex DEL | |
1102 @kindex Backspace | |
1103 In a nutshell, when hungry-delete mode is enabled, hitting the | |
1104 @key{Backspace} key@footnote{I say ``hit the @key{Backspace} key'' but | |
1105 what I really mean is ``when Emacs receives the @code{BackSpace} key | |
1106 event''. The difference usually isn't significant to most users, but | |
1107 advanced users will realize that under window systems such as X, any | |
1108 physical key (keycap) on the keyboard can be configured to generate any | |
1109 keysym, and thus any Emacs key event. Also, the use of Emacs on TTYs | |
1110 will affect which keycap generates which key event. From a pedantic | |
1111 point of view, here we are only concerned with the key event that | |
1112 Emacs receives.} will consume all preceding whitespace, including | |
1113 newlines and tabs. This can really cut down on the number of | |
1114 @key{Backspace}'s you have to type if, for example you made a mistake on | |
1115 the preceding line. | |
1116 | |
1117 @findex c-electric-backspace | |
1118 @findex electric-backspace (c-) | |
1119 @vindex c-backspace-function | |
1120 @vindex backspace-function (c-) | |
1121 | |
1122 @findex c-electric-delete | |
1123 @findex electric-delete (c-) | |
1124 @vindex c-delete-function | |
1125 @vindex delete-function (c-) | |
1126 @cindex literal | |
1127 | |
1128 @findex backward-delete-char-untabify | |
1129 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1130 By default, when you hit the @key{Backspace} key @ccmode{} runs the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1131 command @code{c-electric-backspace}, which deletes text in the backwards |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1132 direction. When deleting a single character, or when @key{Backspace} is |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1133 hit in a literal (@pxref{Auto-newline Insertion}), or when hungry-delete |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1134 mode is disabled, the function contained in the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1135 @code{c-backspace-function} variable is called with one argument (the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1136 number of characters to delete). This variable is set to |
25829 | 1137 @code{backward-delete-char-untabify} by default. |
1138 | |
1139 @vindex delete-key-deletes-forward | |
1140 @findex delete-char | |
1141 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1142 The default behavior of the @key{Delete} key depends on the flavor of |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1143 Emacs you are using. By default in XEmacs 20.3 and beyond, the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1144 @key{Delete} key is bound to @code{c-electric-delete}. You control the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1145 direction that the @key{Delete} key deletes by setting the variable |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1146 @code{delete-key-deletes-forward}, a standard XEmacs variable. When |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1147 this variable is non-@code{nil} and hungry-delete mode is enabled, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1148 @code{c-electric-delete} will consume all whitespace @emph{following} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1149 point. When @code{delete-key-deletes-forward} is @code{nil}, it deletes |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1150 all whitespace @emph{preceding} point@footnote{i.e. it literally calls |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1151 @code{c-electric-backspace}.} When deleting a single character, or if |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1152 @key{Delete} is hit in a literal, or hungry-delete mode is disabled, the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1153 function contained in @code{c-delete-function} is called with one |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1154 argument: the number of characters to delete. This variable is set to |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1155 @code{delete-char} by default. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1156 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1157 In Emacs 19 or Emacs 20, both the @key{Delete} and @key{Backspace} keys |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1158 are bound to @code{c-electric-backspace}, however you can change this by |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1159 explicitly binding @code{[delete]}@footnote{E.g. to |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1160 @code{c-electric-delete} in your @file{.emacs} file. Note however, that |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1161 Emacs 20 does not have a standard variable such as |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1162 @code{delete-key-deletes-forward}.}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1163 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1164 XEmacsen older than 20.3 behave similar to Emacs 19 and Emacs 20. |
25829 | 1165 |
1166 | |
1167 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1168 @node Text Filling and Line Breaking, Commands, Minor Modes, Top |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1169 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1170 @chapter Text Filling and Line Breaking |
25829 | 1171 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
1172 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1173 Since there's a lot of normal text in comments and string literals, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1174 @ccmode{} provides features to edit these like in text mode. The goal |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1175 is to do it as seamlessly as possible, i.e. you can use auto fill mode, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1176 sentence and paragraph movement, paragraph filling, adaptive filling etc |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1177 wherever there's a piece of normal text without having to think much |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1178 about it. @ccmode{} should keep the indentation, fix the comment line |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1179 decorations, and so on, for you. It does that by hooking in on the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1180 different line breaking functions and tuning relevant variables as |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1181 necessary. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1182 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1183 @vindex c-comment-prefix-regexp |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1184 @vindex comment-prefix-regexp (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1185 @cindex comment line prefix |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1186 @vindex comment-start |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1187 @vindex comment-end |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1188 @vindex comment-start-skip |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1189 @vindex paragraph-start |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1190 @vindex paragraph-separate |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1191 @vindex paragraph-ignore-fill-prefix |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1192 @vindex adaptive-fill-mode |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1193 @vindex adaptive-fill-regexp |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1194 @vindex adaptive-fill-first-line-regexp |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1195 To make Emacs recognize comments and treat text in them as normal |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1196 paragraphs, @ccmode{} makes several standard |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1197 variables@footnote{@code{comment-start}, @code{comment-end}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1198 @code{comment-start-skip}, @code{paragraph-start}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1199 @code{paragraph-separate}, @code{paragraph-ignore-fill-prefix}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1200 @code{adaptive-fill-mode}, @code{adaptive-fill-regexp}, and |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1201 @code{adaptive-fill-first-line-regexp}.} buffer local and modifies them |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1202 according to the language syntax and the style of line decoration that |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1203 starts every line in a comment. The style variable |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1204 @code{c-comment-prefix-regexp} contains the regexp used to recognize |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1205 this @dfn{comment line prefix}. The default is @samp{//+\\|\\**}, which |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1206 matches C++ style line comments like |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1207 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1208 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1209 // blah blah |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1210 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1211 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1212 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1213 @noindent |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1214 with two or more slashes in front of them, and C style block comments |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1215 like |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1216 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1217 @group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1218 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1219 /* |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1220 * blah blah |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1221 */ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1222 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1223 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1224 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1225 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1226 @noindent |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1227 with zero or more stars at the beginning of every line. If you change |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1228 that variable, please make sure it still matches the comment starter |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1229 (i.e. @code{//}) of line comments @emph{and} the line prefix inside |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1230 block comments. Also note that since @ccmode{} uses the value of |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1231 @code{c-comment-prefix-regexp} to set up several other variables at mode |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1232 initialization, you need to reinitialize the program mode if you change |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1233 it inside a @ccmode{} buffer. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1234 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1235 @findex auto-fill-mode |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1236 @cindex auto fill mode |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1237 @cindex paragraph fill |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1238 Line breaks are by default handled (almost) the same regardless whether |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1239 they are made by auto fill mode (@pxref{Auto Fill,,, emacs, The Emacs |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1240 Editor}), paragraph filling (e.g. with @kbd{M-q}), or explicitly with |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1241 @kbd{M-j} or similar methods. In string literals, the new line gets the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1242 same indentation as the previous nonempty line (may be changed with the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1243 @code{string} syntactic symbol). In comments, @ccmode{} uses |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1244 @code{c-comment-prefix-regexp} to adapt the line prefix from the other |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1245 lines in the comment. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1246 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1247 @vindex adaptive-fill-mode |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1248 @cindex adaptive fill mode |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1249 @ccmode{} uses adaptive fill mode (@pxref{Adaptive Fill,,, emacs, The |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1250 Emacs Editor}) to make Emacs correctly keep the line prefix when filling |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1251 paragraphs. That also makes Emacs preserve the text indentation |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1252 @emph{inside} the comment line prefix. E.g. in the following comment, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1253 both paragraphs will be filled with the left margins kept intact: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1254 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1255 @group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1256 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1257 /* Make a balanced b-tree of the nodes in the incoming |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1258 * stream. But, to quote the famous words of Donald E. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1259 * Knuth, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1260 * |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1261 * Beware of bugs in the above code; I have only |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1262 * proved it correct, not tried it. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1263 */ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1264 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1265 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1266 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1267 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1268 @findex c-setup-filladapt |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1269 @findex setup-filladapt (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1270 @findex filladapt-mode |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1271 @vindex filladapt-mode |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1272 @cindex Filladapt mode |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1273 It's also possible to use other adaptive filling packages, notably Kyle |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1274 E. Jones' Filladapt package@footnote{It's available from |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1275 @uref{http://www.wonderworks.com/}. As of version 2.12, it does however |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1276 lack a feature that makes it work suboptimally when |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1277 @code{c-comment-prefix-regexp} matches the empty string (which it does |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1278 by default). A patch for that is available from |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1279 @uref{http://www.python.org/emacs/cc-mode/,, the CC Mode site}.}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1280 which handles things like bulleted lists nicely. There's a convenience |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1281 function @code{c-setup-filladapt} that tunes the relevant variables in |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1282 Filladapt for use in @ccmode{}. Call it from a mode hook, e.g. with |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1283 something like this in your @file{.emacs}: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1284 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1285 @group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1286 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1287 (defun my-c-mode-common-hook () |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1288 (c-setup-filladapt) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1289 (filladapt-mode 1)) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1290 (add-hook 'c-mode-common-hook 'my-c-mode-common-hook) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1291 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1292 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1293 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1294 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1295 @vindex c-block-comment-prefix |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1296 @vindex block-comment-prefix (c-) |
25829 | 1297 @vindex c-comment-continuation-stars |
1298 @vindex comment-continuation-stars (c-) | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1299 Normally the comment line prefix inserted for a new line inside a |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1300 comment is deduced from other lines in it. However there's one |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1301 situation when there's no clue about how the prefix should look, namely |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1302 when a block comment is broken for the first time. The string in the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1303 style variable @code{c-block-comment-prefix}@footnote{In versions before |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1304 5.26, this variable was called @code{c-comment-continuation-stars}. As |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1305 a compatibility measure, @ccmode{} still uses the value on that variable |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1306 if it's set.} is used in that case. It defaults to @samp{* }, which |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1307 makes a comment |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1308 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1309 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1310 /* Got O(n^2) here, which is a Bad Thing. */ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1311 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1312 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1313 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1314 @noindent |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1315 break into |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1316 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1317 @group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1318 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1319 /* Got O(n^2) here, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1320 * which is a Bad Thing. */ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1321 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1322 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1323 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1324 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1325 Note that it won't work to justify the indentation by putting leading |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1326 spaces in the @code{c-block-comment-prefix} string, since @ccmode{} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1327 still uses the normal indentation engine to indent the line. Thus, the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1328 right way to fix the indentation is by setting the @code{c} syntactic |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1329 symbol. It defaults to @code{c-lineup-C-comments}, which handles the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1330 indentation of most common comment styles, see @ref{Indentation |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1331 Functions}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1332 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1333 @vindex c-ignore-auto-fill |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1334 @vindex ignore-auto-fill (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1335 When auto fill mode is enabled, @ccmode{} can selectively ignore it |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1336 depending on the context the line break would occur in, e.g. to never |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1337 break a line automatically inside a string literal. This behavior can |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1338 be controlled with the @code{c-ignore-auto-fill} variable. It takes a |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1339 list of symbols for the different contexts where auto-filling never |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1340 should occur: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1341 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1342 @itemize @bullet |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1343 @item @code{string} --- Inside a string or character literal. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1344 @item @code{c} --- Inside a C style block comment. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1345 @item @code{c++} --- Inside a C++ style line comment. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1346 @item @code{cpp} --- Inside a preprocessor directive. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1347 @item @code{code} --- Anywhere else, i.e. in normal code. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1348 @end itemize |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1349 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1350 By default, @code{c-ignore-auto-fill} is set to @code{'(string cpp |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1351 code)}, which means that auto-filling only occurs in comments when |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1352 auto-fill mode is activated. In literals, it's often desirable to have |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1353 explicit control over newlines. In preprocessor directives, the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1354 necessary @samp{\} escape character before the newline is not |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1355 automatically inserted, so an automatic line break would produce invalid |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1356 code. In normal code, line breaks are normally dictated by some logical |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1357 structure in the code rather than the last whitespace character, so |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1358 automatic line breaks there will produce poor results in the current |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1359 implementation. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1360 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1361 The commands that does the actual work follows. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1362 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1363 @table @asis |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1364 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1365 @kindex M-q |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1366 @findex c-fill-paragraph |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1367 @findex fill-paragraph (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1368 @cindex Javadoc markup |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1369 @item @kbd{M-q} (@code{c-fill-paragraph}) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1370 This is the replacement for @code{fill-paragraph} in @ccmode{} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1371 buffers. It's used to fill multiline string literals and both block and |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1372 line style comments. In Java buffers, the Javadoc markup words are |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1373 recognized as paragraph starters. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1374 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1375 The function keeps the comment starters and enders of block comments as |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1376 they were before the filling. This means that a comment ender on the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1377 same line as the paragraph being filled will be filled with the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1378 paragraph, and one on a line by itself will stay as it is. The comment |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1379 starter is handled similarly@footnote{This means that the variables |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1380 @code{c-hanging-comment-starter-p} and @code{c-hanging-comment-ender-p}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1381 which controlled this behavior in earlier versions of @ccmode{}, are now |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1382 obsolete.}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1383 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1384 @kindex M-j |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1385 @findex c-indent-new-comment-line |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1386 @findex indent-new-comment-line (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1387 @item @kbd{M-j} (@code{c-indent-new-comment-line}) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1388 This is the replacement for @code{indent-new-comment-line}. It breaks |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1389 the line at point and indents the new line like the current one. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1390 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1391 @vindex comment-multi-line |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1392 If inside a comment and @code{comment-multi-line} is non-@code{nil}, the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1393 indentation and line prefix are preserved. If inside a comment and |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1394 @code{comment-multi-line} is @code{nil}, a new comment of the same type |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1395 is started on the next line and indented as appropriate for comments. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1396 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1397 @findex c-context-line-break |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1398 @findex context-line-break (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1399 @item @kbd{M-x c-context-line-break} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1400 This is a function that works like @code{indent-new-comment-line} in |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1401 comments and @code{newline-and-indent} elsewhere, thus combining those |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1402 two in a way that uses each one in the context it's best suited for. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1403 I.e. in comments the comment line prefix and indentation is kept for the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1404 new line, and in normal code it's indented according to context by the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1405 indentation engine. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1406 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1407 It's not bound to a key by default, but it's intended to be used on the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1408 @kbd{RET} key. If you like the behavior of @code{newline-and-indent} on |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1409 @kbd{RET}, you might consider switching to this function. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1410 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1411 @end table |
25829 | 1412 |
1413 | |
1414 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1415 @node Commands, Customizing Indentation, Text Filling and Line Breaking, Top |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1416 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1417 @chapter Commands |
25829 | 1418 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
1419 | |
1420 @menu | |
1421 * Indentation Commands:: | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1422 * Movement Commands:: |
25829 | 1423 * Other Commands:: |
1424 @end menu | |
1425 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1426 See also @ref{Text Filling and Line Breaking}, for commands concerning |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1427 that bit. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1428 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1429 |
25829 | 1430 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1431 @node Indentation Commands, Movement Commands, , Commands |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1432 @comment node-name, next, previous,up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1433 @section Indentation Commands |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1434 @cindex indentation commands |
25829 | 1435 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
1436 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1437 The following list of commands re-indent C constructs. Note that when |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1438 you change your coding style, either interactively or through some other |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1439 means, your file does @emph{not} automatically get re-indented. You |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1440 will need to execute one of the following commands to see the effects of |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1441 your changes. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1442 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1443 @cindex GNU indent program |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1444 Also, variables like @code{c-hanging-*} and @code{c-cleanup-list} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1445 only affect how on-the-fly code is formatted. Changing the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1446 ``hanginess'' of a brace and then re-indenting, will not move the brace |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1447 to a different line. For this, you're better off getting an external |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1448 program like GNU @code{indent}, which will re-arrange brace location, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1449 among other things. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1450 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1451 Re-indenting large sections of code can take a long time. When |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1452 @ccmode{} reindents a region of code, it is essentially equivalent to |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1453 hitting @kbd{TAB} on every line of the region. Especially vulnerable is |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1454 code generator output@footnote{In particular, I have had people |
25829 | 1455 complain about the speed with which @code{lex(1)} output is re-indented. |
1456 Lex, yacc, and other code generators usually output some pretty | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1457 perversely formatted code. Re-indenting such code will be slow.}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1458 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1459 These commands are useful when indenting code: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1460 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1461 @table @asis |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1462 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1463 @kindex TAB |
25829 | 1464 @findex c-indent-command |
1465 @findex indent-command (c-) | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1466 @item @kbd{TAB} (@code{c-indent-command}) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1467 Indents the current line. The actual behavior is controlled by several |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1468 variables, described below. See @code{c-tab-always-indent}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1469 @code{c-insert-tab-function}, and @code{indent-tabs-mode}. With a |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1470 numeric argument, this command rigidly indents the region, preserving |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1471 the relative indentation among the lines. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1472 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1473 @kindex M-C-q |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1474 @findex c-indent-exp |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1475 @findex indent-exp (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1476 @item @kbd{M-C-q} (@code{c-indent-exp}) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1477 Indent an entire balanced brace or parenthesis expression. Note that |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1478 point must be on the opening brace or parenthesis of the expression you |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1479 want to indent. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1480 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1481 @kindex C-c C-q |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1482 @findex c-indent-defun |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1483 @findex indent-defun (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1484 @item @kbd{C-c C-q} (@code{c-indent-defun}) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1485 Indents the entire top-level function or class definition encompassing |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1486 point. It leaves point unchanged. This function can't be used to |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1487 re-indent a nested brace construct, such as a nested class or function, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1488 or a Java method. The top-level construct being re-indented must be |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1489 complete, i.e. it must have both a beginning brace and an ending brace. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1490 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1491 @kindex M-C-\ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1492 @findex indent-region |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1493 @item @kbd{M-C-\} (@code{indent-region}) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1494 Indents an arbitrary region of code. This is a standard Emacs command, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1495 tailored for C code in a @ccmode{} buffer. Note that of course, point |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1496 and mark must delineate the region you want to indent. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1497 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1498 @kindex M-C-h |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1499 @findex c-mark-function |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1500 @findex mark-function (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1501 @item @kbd{M-C-h} (@code{c-mark-function}) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1502 While not strictly an indentation command, this is useful for marking |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1503 the current top-level function or class definition as the current |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1504 region. As with @code{c-indent-defun}, this command operates on |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1505 top-level constructs, and can't be used to mark say, a Java method. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1506 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1507 @end table |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1508 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1509 These variables are also useful when indenting code: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1510 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1511 @table @code |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1512 |
25829 | 1513 @vindex c-tab-always-indent |
1514 @vindex tab-always-indent (c-) | |
1515 @kindex TAB | |
1516 @cindex literal | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1517 @item c-tab-always-indent |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1518 This variable controls how @kbd{TAB} @code{c-indent-command} operates. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1519 When this variable is @code{t}, @kbd{TAB} always just indents the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1520 current line. When it is @code{nil}, the line is indented only if point |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1521 is at the left margin, or on or before the first non-whitespace |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1522 character on the line, otherwise some whitespace is inserted. If this |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1523 variable is the symbol @code{other}, then some whitespace is inserted |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1524 only within strings and comments (literals), an inside preprocessor |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1525 directives, but the line is always reindented. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1526 |
25829 | 1527 @vindex c-insert-tab-function |
1528 @vindex insert-tab-function (c-) | |
1529 @findex tab-to-tab-stop | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1530 @item c-insert-tab-function |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1531 When ``some whitespace'' is inserted as described above, what actually |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1532 happens is that the function stored in @code{c-insert-tab-function} is |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1533 called. Normally, this just inserts a real tab character, or the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1534 equivalent number of spaces, depending on @code{indent-tabs-mode}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1535 Some people, however, set @code{c-insert-tab-function} to |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1536 @code{tab-to-tab-stop} so as to get hard tab stops when indenting. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1537 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1538 @vindex indent-tabs-mode |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1539 @item indent-tabs-mode |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1540 This is a standard Emacs variable that controls how line indentation is |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1541 composed. When this variable is non-@code{nil}, then tabs can be used |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1542 in a line's indentation, otherwise only spaces can be used. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1543 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1544 @vindex c-progress-interval |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1545 @vindex progress-interval (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1546 @item c-progress-interval |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1547 When indenting large regions of code, this variable controls how often a |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1548 progress message is displayed. Set this variable to @code{nil} to |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1549 inhibit the progress messages, or set it to an integer which is the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1550 interval in seconds that progress messages are displayed. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1551 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1552 @end table |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1553 |
25829 | 1554 |
1555 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1556 @node Movement Commands, Other Commands, Indentation Commands, Commands |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1557 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1558 @section Movement Commands |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1559 @cindex movement commands |
25829 | 1560 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
1561 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1562 @ccmode{} contains some useful command for moving around in C |
25829 | 1563 code. |
1564 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1565 @table @asis |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1566 |
25829 | 1567 @findex c-beginning-of-defun |
1568 @findex beginning-of-defun (c-) | |
1569 @findex beginning-of-defun | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1570 @item @kbd{M-x c-beginning-of-defun} |
25829 | 1571 Moves point back to the least-enclosing brace. This function is |
1572 analogous to the Emacs built-in command @code{beginning-of-defun}, | |
1573 except it eliminates the constraint that the top-level opening brace | |
1574 must be in column zero. See @code{beginning-of-defun} for more | |
1575 information. | |
1576 | |
1577 Depending on the coding style being used, you might prefer | |
1578 @code{c-beginning-of-defun} to @code{beginning-of-defun}. If so, | |
1579 consider binding @kbd{C-M-a} to the former instead. For backwards | |
1580 compatibility reasons, the default binding remains in effect. | |
1581 | |
1582 @findex c-end-of-defun | |
1583 @findex end-of-defun (c-) | |
1584 @findex end-of-defun | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1585 @item @kbd{M-x c-end-of-defun} |
25829 | 1586 Moves point to the end of the current top-level definition. This |
1587 function is analogous to the Emacs built-in command @code{end-of-defun}, | |
1588 except it eliminates the constraint that the top-level opening brace of | |
1589 the defun must be in column zero. See @code{beginning-of-defun} for more | |
1590 information. | |
1591 | |
1592 Depending on the coding style being used, you might prefer | |
1593 @code{c-end-of-defun} to @code{end-of-defun}. If so, | |
1594 consider binding @kbd{C-M-e} to the former instead. For backwards | |
1595 compatibility reasons, the default binding remains in effect. | |
1596 | |
1597 @kindex C-c C-u | |
1598 @findex c-up-conditional | |
1599 @findex up-conditional (c-) | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1600 @item @kbd{C-c C-u} (@code{c-up-conditional}) |
25829 | 1601 Move point back to the containing preprocessor conditional, leaving the |
1602 mark behind. A prefix argument acts as a repeat count. With a negative | |
1603 argument, move point forward to the end of the containing | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1604 preprocessor conditional. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1605 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1606 @samp{#elif} is treated like @samp{#else} followed by @samp{#if}, so the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1607 function stops at them when going backward, but not when going forward. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1608 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1609 @findex c-up-conditional-with-else |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1610 @findex up-conditional-with-else (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1611 @item @kbd{M-x c-up-conditional-with-else} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1612 A variety of @code{c-up-conditional} that also stops at @samp{#else} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1613 lines. Normally those lines are ignored. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1614 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1615 @findex c-down-conditional |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1616 @findex down-conditional (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1617 @item @kbd{M-x c-down-conditional} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1618 Move point forward into the next nested preprocessor conditional, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1619 leaving the mark behind. A prefix argument acts as a repeat count. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1620 With a negative argument, move point backward into the previous |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1621 nested preprocessor conditional. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1622 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1623 @samp{#elif} is treated like @samp{#else} followed by @samp{#if}, so the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1624 function stops at them when going forward, but not when going backward. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1625 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1626 @findex c-down-conditional-with-else |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1627 @findex down-conditional-with-else (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1628 @item @kbd{M-x c-down-conditional-with-else} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1629 A variety of @code{c-down-conditional} that also stops at @samp{#else} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1630 lines. Normally those lines are ignored. |
25829 | 1631 |
1632 @kindex C-c C-p | |
1633 @findex c-backward-conditional | |
1634 @findex backward-conditional (c-) | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1635 @item @kbd{C-c C-p} (@code{c-backward-conditional}) |
25829 | 1636 Move point back over a preprocessor conditional, leaving the mark |
1637 behind. A prefix argument acts as a repeat count. With a negative | |
1638 argument, move forward. | |
1639 | |
1640 @kindex C-c C-n | |
1641 @findex c-forward-conditional | |
1642 @findex forward-conditional (c-) | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1643 @item @kbd{C-c C-n} (@code{c-forward-conditional}) |
25829 | 1644 Move point forward across a preprocessor conditional, leaving the mark |
1645 behind. A prefix argument acts as a repeat count. With a negative | |
1646 argument, move backward. | |
1647 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1648 @kindex M-a |
25829 | 1649 @findex c-beginning-of-statement |
1650 @findex beginning-of-statement (c-) | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1651 @item @kbd{M-a} (@code{c-beginning-of-statement}) |
25829 | 1652 Move point to the beginning of the innermost C statement. If point is |
1653 already at the beginning of a statement, it moves to the beginning of | |
1654 the closest preceding statement, even if that means moving into a block | |
1655 (you can use @kbd{M-C-b} to move over a balanced block). With prefix | |
1656 argument @var{n}, move back @var{n} @minus{} 1 statements. | |
1657 | |
1658 If point is within a comment, or next to a comment, this command moves | |
1659 by sentences instead of statements. | |
1660 | |
1661 When called from a program, this function takes three optional | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1662 arguments: the numeric prefix argument, a buffer position limit which is |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1663 the farthest back to search, and a flag to enable moving by sentence |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1664 inside comments. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1665 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1666 @kindex M-e |
25829 | 1667 @findex c-end-of-statement |
1668 @findex end-of-statement (c-) | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1669 @item @kbd{M-e} (@code{c-end-of-statement}) |
25829 | 1670 Move point to the end of the innermost C statement. If point is at the |
1671 end of a statement, move to the end of the next statement, even if it's | |
1672 inside a nested block (use @kbd{M-C-f} to move to the other side of the | |
1673 block). With prefix argument @var{n}, move forward @var{n} @minus{} 1 | |
1674 statements. | |
1675 | |
1676 If point is within a comment, or next to a comment, this command moves | |
1677 by sentences instead of statements. | |
1678 | |
1679 When called from a program, this function takes three optional | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1680 arguments: the numeric prefix argument, a buffer position limit which is |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1681 the farthest back to search, and a flag to enable moving by sentence |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1682 inside comments. |
25829 | 1683 |
1684 @findex c-forward-into-nomenclature | |
1685 @findex forward-into-nomenclature (c-) | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1686 @item @kbd{M-x c-forward-into-nomenclature} |
25829 | 1687 A popular programming style, especially for object-oriented languages |
1688 such as C++ is to write symbols in a mixed case format, where the first | |
1689 letter of each word is capitalized, and not separated by underscores. | |
1690 E.g. @samp{SymbolsWithMixedCaseAndNoUnderlines}. | |
1691 | |
1692 This command moves point forward to next capitalized word. With prefix | |
1693 argument @var{n}, move @var{n} times. | |
1694 | |
1695 @findex c-backward-into-nomenclature | |
1696 @findex backward-into-nomenclature (c-) | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1697 @item @kbd{M-x c-backward-into-nomenclature} |
25829 | 1698 Move point backward to beginning of the next capitalized |
1699 word. With prefix argument @var{n}, move @var{n} times. If | |
1700 @var{n} is negative, move forward. | |
1701 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1702 @end table |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1703 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1704 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1705 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1706 @node Other Commands, , Movement Commands, Commands |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1707 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1708 @section Other Commands |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1709 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1710 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1711 @ccmode{} contains a few other useful commands: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1712 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1713 @table @asis |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1714 |
25829 | 1715 @kindex C-c : |
1716 @findex c-scope-operator | |
1717 @findex scope-operator (c-) | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1718 @item @kbd{C-c :} (@code{c-scope-operator}) |
25829 | 1719 In C++, it is also sometimes desirable to insert the double-colon scope |
1720 operator without performing the electric behavior of colon insertion. | |
1721 @kbd{C-c :} does just this. | |
1722 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1723 @kindex C-c C-\ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1724 @findex c-backslash-region |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1725 @findex backslash-region (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1726 @item @kbd{C-c C-\} (@code{c-backslash-region}) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1727 This function is handy when editing macros split over several lines by |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1728 ending each line with a backslash. It inserts and aligns, or deletes |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1729 these end-of-line backslashes in the current region. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1730 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1731 @vindex c-backslash-column |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1732 @vindex backslash-column (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1733 With no prefix argument, it inserts any missing backslashes and aligns |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1734 them to the column specified by the @code{c-backslash-column} style |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1735 variable. With a prefix argument, it deletes any backslashes. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1736 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1737 The function does not modify blank lines at the start of the region. If |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1738 the region ends at the start of a line, it always deletes the backslash |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1739 (if any) at the end of the previous line. |
25829 | 1740 |
1741 @end table | |
1742 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1743 |
25829 | 1744 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1745 @node Customizing Indentation, Syntactic Symbols, Commands, Top |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1746 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1747 @chapter Customizing Indentation |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1748 @cindex customizing indentation |
25829 | 1749 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
1750 | |
1751 @vindex c-offsets-alist | |
1752 @vindex offsets-alist (c-) | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1753 The style variable @code{c-offsets-alist} contains the mappings between |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1754 syntactic symbols and the offsets to apply for those symbols. It's set |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1755 at mode initialization from a @emph{style} you may specify. Styles are |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1756 groupings of syntactic symbol offsets and other style variable values. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1757 Most likely, you'll find that one of the pre-defined styles will suit |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1758 your needs. @xref{Styles}, for an explanation of how to set up named |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1759 styles. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1760 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1761 Only syntactic symbols not already bound on @code{c-offsets-alist} will |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1762 be set from styles. This means that any association you set on it, be |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1763 it before or after mode initialization, will not be changed. The |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1764 @code{c-offsets-alist} variable may therefore be used from e.g. the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1765 Customization interface@footnote{Available in Emacs 20 and later, and |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1766 XEmacs 19.15 and later.} to easily change indentation offsets without |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1767 having to bother about styles. Initially @code{c-offsets-alist} is |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1768 empty, so that all syntactic symbols are set by the style system. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1769 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1770 @kindex C-c C-o |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1771 @findex c-set-offset |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1772 @findex set-offset (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1773 You can use the command @kbd{C-c C-o} (@code{c-set-offset}) as the way |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1774 to set offsets, both interactively and from your mode |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1775 hook@footnote{Obviously, you use the keybinding interactively, and the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1776 function call programmatically!}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1777 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1778 @vindex c-basic-offset |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1779 @vindex basic-offset (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1780 The offset associated with any particular syntactic symbol can be any of |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1781 an integer, a function or lambda expression, a variable name, or one of |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1782 the following symbols: @code{+}, @code{-}, @code{++}, @code{--}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1783 @code{*}, or @code{/}. These latter describe offset in multiples of the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1784 value of the style variable @code{c-basic-offset}. By defining a |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1785 style's indentation in terms of this fundamental variable, you can |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1786 change the amount of whitespace given to an indentation level while |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1787 maintaining the same basic shape of your code. Here are the values that |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1788 the special symbols correspond to: |
25829 | 1789 |
1790 @table @code | |
1791 | |
1792 @item + | |
1793 @code{c-basic-offset} times 1 | |
1794 @item - | |
1795 @code{c-basic-offset} times -1 | |
1796 @item ++ | |
1797 @code{c-basic-offset} times 2 | |
1798 @item -- | |
1799 @code{c-basic-offset} times -2 | |
1800 @item * | |
1801 @code{c-basic-offset} times 0.5 | |
1802 @item / | |
1803 @code{c-basic-offset} times -0.5 | |
1804 | |
1805 @end table | |
1806 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1807 @cindex indentation functions |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1808 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1809 When a function is used as offset, it's called an @dfn{indentation |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1810 function}. Such functions are useful when more context than just the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1811 syntactic symbol is needed to get the desired indentation. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1812 @xref{Indentation Functions}, and @ref{Custom Indentation Functions}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1813 for details about them. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1814 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1815 @vindex c-strict-syntax-p |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1816 @vindex strict-syntax-p (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1817 The offset can also be a list, in which case it is evaluated recursively |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1818 using the semantics described above. The first element of the list that |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1819 returns a non-@code{nil} value succeeds and the evaluation stops. If |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1820 none of the list elements return a non-@code{nil} value, then an offset |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1821 of 0 (zero) is used@footnote{There is however a variable |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1822 @code{c-strict-syntax-p} that, when set to non-@code{nil}, will cause an |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1823 error to be signalled in that case. It's now considered obsolete since |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1824 it doesn't work well with some of the alignment functions that now |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1825 returns @code{nil} instead of zero to be more usable in lists. You |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1826 should therefore leave @code{c-strict-syntax-p} set to @code{nil}.}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1827 |
25829 | 1828 So, for example, because most of the default offsets are defined in |
1829 terms of @code{+}, @code{-}, and @code{0}, if you like the general | |
1830 indentation style, but you use 4 spaces instead of 2 spaces per level, | |
1831 you can probably achieve your style just by changing | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1832 @code{c-basic-offset} like so@footnote{You can try this interactively in |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1833 a C buffer by typing the text that appears in italics.}: |
25829 | 1834 @example |
1835 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1836 @emph{M-x set-variable RET} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1837 Set variable: @emph{c-basic-offset RET} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1838 Set c-basic-offset to value: @emph{4 RET} |
25829 | 1839 |
1840 @end example | |
1841 | |
1842 @noindent | |
1843 This would change | |
1844 @example | |
1845 @group | |
1846 | |
1847 int add( int val, int incr, int doit ) | |
1848 @{ | |
1849 if( doit ) | |
1850 @{ | |
1851 return( val + incr ); | |
1852 @} | |
1853 return( val ); | |
1854 @} | |
1855 | |
1856 @end group | |
1857 @end example | |
1858 @noindent | |
1859 to | |
1860 @example | |
1861 @group | |
1862 | |
1863 int add( int val, int incr, int doit ) | |
1864 @{ | |
1865 if( doit ) | |
1866 @{ | |
1867 return( val + incr ); | |
1868 @} | |
1869 return( val ); | |
1870 @} | |
1871 | |
1872 @end group | |
1873 @end example | |
1874 | |
1875 To change indentation styles more radically, you will want to change the | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1876 offsets associated with other syntactic symbols. First, I'll show you |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1877 how to do that interactively, then I'll describe how to make changes to |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1878 your @file{.emacs} file so that your changes are more permanent. |
25829 | 1879 |
1880 @menu | |
1881 * Interactive Customization:: | |
1882 * Permanent Customization:: | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1883 * Hooks:: |
25829 | 1884 * Styles:: |
1885 * Advanced Customizations:: | |
1886 @end menu | |
1887 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1888 |
25829 | 1889 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1890 @node Interactive Customization, Permanent Customization, , Customizing Indentation |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1891 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1892 @section Interactive Customization |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1893 @cindex interactive customization |
25829 | 1894 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
1895 | |
1896 As an example of how to customize indentation, let's change the | |
1897 style of this example@footnote{In this an subsequent examples, the | |
1898 original code is formatted using the @samp{gnu} style unless otherwise | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1899 indicated. @xref{Styles}.}: |
25829 | 1900 @example |
1901 @group | |
1902 | |
1903 1: int add( int val, int incr, int doit ) | |
1904 2: @{ | |
1905 3: if( doit ) | |
1906 4: @{ | |
1907 5: return( val + incr ); | |
1908 6: @} | |
1909 7: return( val ); | |
1910 8: @} | |
1911 | |
1912 @end group | |
1913 @end example | |
1914 @noindent | |
1915 to: | |
1916 @example | |
1917 @group | |
1918 | |
1919 1: int add( int val, int incr, int doit ) | |
1920 2: @{ | |
1921 3: if( doit ) | |
1922 4: @{ | |
1923 5: return( val + incr ); | |
1924 6: @} | |
1925 7: return( val ); | |
1926 8: @} | |
1927 | |
1928 @end group | |
1929 @end example | |
1930 | |
1931 In other words, we want to change the indentation of braces that open a | |
1932 block following a condition so that the braces line up under the | |
1933 conditional, instead of being indented. Notice that the construct we | |
1934 want to change starts on line 4. To change the indentation of a line, | |
1935 we need to see which syntactic components affect the offset calculations | |
1936 for that line. Hitting @kbd{C-c C-s} on line 4 yields: | |
1937 @example | |
1938 | |
1939 ((substatement-open . 44)) | |
1940 | |
1941 @end example | |
1942 | |
1943 @noindent | |
1944 so we know that to change the offset of the open brace, we need to | |
1945 change the indentation for the @code{substatement-open} syntactic | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1946 symbol. To do this interactively, just hit @kbd{C-c C-o}. This prompts |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1947 you for the syntactic symbol to change, providing a reasonable default. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1948 In this case, the default is @code{substatement-open}, which is just the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1949 syntactic symbol we want to change! |
25829 | 1950 |
1951 After you hit return, @ccmode{} will then prompt you for the new | |
1952 offset value, with the old value as the default. The default in this | |
1953 case is @samp{+}, but we want no extra indentation so enter | |
1954 @samp{0} and @kbd{RET}. This will associate the offset 0 with the | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1955 syntactic symbol @code{substatement-open}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1956 |
25829 | 1957 To check your changes quickly, just hit @kbd{C-c C-q} |
1958 (@code{c-indent-defun}) to reindent the entire function. The example | |
1959 should now look like: | |
1960 @example | |
1961 @group | |
1962 | |
1963 1: int add( int val, int incr, int doit ) | |
1964 2: @{ | |
1965 3: if( doit ) | |
1966 4: @{ | |
1967 5: return( val + incr ); | |
1968 6: @} | |
1969 7: return( val ); | |
1970 8: @} | |
1971 | |
1972 @end group | |
1973 @end example | |
1974 | |
1975 Notice how just changing the open brace offset on line 4 is all we | |
1976 needed to do. Since the other affected lines are indented relative to | |
1977 line 4, they are automatically indented the way you'd expect. For more | |
1978 complicated examples, this may not always work. The general approach to | |
1979 take is to always start adjusting offsets for lines higher up in the | |
1980 file, then re-indent and see if any following lines need further | |
1981 adjustments. | |
1982 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1983 |
25829 | 1984 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1985 @node Permanent Customization, Hooks, Interactive Customization, Customizing Indentation |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1986 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1987 @section Permanent Customization |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1988 @cindex permanent customization |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1989 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1990 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1991 To make your changes permanent, you need to add some lisp code to your |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1992 @file{.emacs} file. @ccmode{} supports many different ways to be |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1993 configured, from the straightforward way by setting variables globally |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1994 in @file{.emacs} or in the Customization interface, to the complex and |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1995 precisely controlled way by using styles and hook functions. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1996 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1997 The simplest way of customizing @ccmode{} permanently is to set the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1998 variables in your @file{.emacs} with @code{setq} and similar commands. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1999 So to make the setting of @code{substatement-open} permanent, add this |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2000 to the @file{.emacs} file: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2001 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2002 @group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2003 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2004 (require 'cc-mode) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2005 (c-set-offset 'substatement-open 0) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2006 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2007 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2008 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2009 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2010 The @code{require} line is only needed once in the beginning to make |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2011 sure @ccmode{} is loaded so that the @code{c-set-offset} function is |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2012 defined. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2013 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2014 You can also use the more user friendly Customization interface, but |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2015 this manual does not cover how that works. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2016 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2017 Variables set like this at the top level in @file{.emacs} take effect in |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2018 all @ccmode{} buffers, regardless of language. The indentation style |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2019 related variables that you don't set get their value from the style |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2020 system (@pxref{Styles}), and they therefore depend on the setting of |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2021 @code{c-default-style}. Note that if you use Customize, this means that |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2022 the greyed-out default values presented there might not be the ones you |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2023 actually get, since the actual values depend on the style, which may |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2024 very well be different for different languages. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2025 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2026 If you want to make more advanced configurations, e.g. language-specific |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2027 customization, global variable settings isn't enough. For that you can |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2028 use the language hooks, see @ref{Hooks}, and/or the style system, see |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2029 @ref{Styles}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2030 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2031 @vindex c-style-variables-are-local-p |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2032 @vindex style-variables-are-local-p (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2033 By default, all style variables are global, so that every buffer will |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2034 share the same style settings. This is fine if you primarily edit one |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2035 style of code, but if you edit several languages and want to use |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2036 different styles for them, you need finer control by making the style |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2037 variables buffer local. The recommended way to do this is to set the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2038 variable @code{c-style-variables-are-local-p} to @code{t}. The |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2039 variables will be made buffer local when @ccmode{} is activated in a |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2040 buffer for the first time in the Emacs session. Note that once the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2041 style variables are made buffer local, they cannot be made global again, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2042 without restarting Emacs. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2043 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2044 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2045 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2046 @node Hooks, Styles, Permanent Customization, Customizing Indentation |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2047 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2048 @section Hooks |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2049 @cindex hooks |
25829 | 2050 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2051 | |
2052 @vindex c-mode-common-hook | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2053 @vindex mode-common-hook (c-) |
25829 | 2054 @vindex c-mode-hook |
2055 @vindex c++-mode-hook | |
2056 @vindex objc-mode-hook | |
2057 @vindex java-mode-hook | |
2058 @vindex idl-mode-hook | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2059 @vindex pike-mode-hook |
25829 | 2060 @vindex c-initialization-hook |
2061 @vindex initialization-hook (c-) | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2062 @ccmode{} provides several hooks that you can use to customize the mode |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2063 according to your coding style. Each language mode has its own hook, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2064 adhering to standard Emacs major mode conventions. There is also one |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2065 general hook and one package initialization hook: |
25829 | 2066 |
2067 @itemize @bullet | |
2068 | |
2069 @item | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2070 @code{c-mode-hook} --- For C buffers only. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2071 @item |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2072 @code{c++-mode-hook} --- For C++ buffers only. |
25829 | 2073 @item |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2074 @code{objc-mode-hook} --- For Objective-C buffers only. |
25829 | 2075 @item |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2076 @code{java-mode-hook} --- For Java buffers only. |
25829 | 2077 @item |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2078 @code{idl-mode-hook} --- For CORBA IDL buffers only. |
25829 | 2079 @item |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2080 @code{pike-mode-hook} --- For Pike buffers only. |
25829 | 2081 @item |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2082 @code{c-mode-common-hook} --- Common across all languages. |
25829 | 2083 @item |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2084 @code{c-initialization-hook} --- Hook run only once per Emacs session, |
25829 | 2085 when @ccmode{} is initialized. |
2086 | |
2087 @end itemize | |
2088 | |
2089 The language hooks get run as the last thing when you enter that | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2090 language mode. The @code{c-mode-common-hook} is run by all supported |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2091 modes @emph{before} the language specific hook, and thus can contain |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2092 customizations that are common across all languages. Most of the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2093 examples in this section will assume you are using the common |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2094 hook.@footnote{@code{java-mode} and the hook variables interact in a |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2095 slightly different way than the other modes. @code{java-mode} normally |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2096 sets the style of the buffer to @samp{java} @emph{before} running the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2097 @code{c-mode-common-hook} or @code{java-mode-hook}. You need to be |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2098 aware of this so that style settings in @code{c-mode-common-hook} don't |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2099 clobber your Java style. This is arguably bogus, but it's kept for |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2100 historical reasons. @xref{Built-in Styles}, the documentation of |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2101 @code{c-default-style}, for details.} |
25829 | 2102 |
2103 Here's a simplified example of what you can add to your @file{.emacs} | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2104 file to do things whenever any @ccmode{} language is edited. See the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2105 Emacs manuals for more information on customizing Emacs via hooks. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2106 @xref{Sample .emacs File}, for a more complete sample @file{.emacs} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2107 file. |
25829 | 2108 @example |
2109 @group | |
2110 | |
2111 (defun my-c-mode-common-hook () | |
2112 ;; my customizations for all of c-mode and related modes | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2113 (no-case-fold-search) |
25829 | 2114 ) |
2115 (add-hook 'c-mode-common-hook 'my-c-mode-common-hook) | |
2116 | |
2117 @end group | |
2118 @end example | |
2119 | |
2120 | |
2121 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2122 @node Styles, Advanced Customizations, Hooks, Customizing Indentation |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2123 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2124 @section Styles |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2125 @cindex styles |
25829 | 2126 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2127 | |
2128 Most people only need to edit code formatted in just a few well-defined | |
2129 and consistent styles. For example, their organization might impose a | |
2130 ``blessed'' style that all its programmers must conform to. Similarly, | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2131 people who work on GNU software will have to use the GNU coding style. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2132 Some shops are more lenient, allowing a variety of coding styles, and as |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2133 programmers come and go, there could be a number of styles in use. For |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2134 this reason, @ccmode{} makes it convenient for you to set up logical |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2135 groupings of customizations called @dfn{styles}, associate a single name |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2136 for any particular style, and pretty easily start editing new or |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2137 existing code using these styles. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2138 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2139 @cindex style variables |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2140 The variables that the style system affect are called @dfn{style |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2141 variables}. They are handled specially in several ways: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2142 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2143 @itemize @bullet |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2144 @item |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2145 Style variables are by default global variables, i.e. they have the same |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2146 value in all Emacs buffers. However, they can instead be made always |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2147 buffer local by setting @code{c-style-variables-are-local-p} to |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2148 non-@code{nil} before @ccmode{} is initialized. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2149 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2150 @vindex c-old-style-variable-behavior |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2151 @vindex old-style-variable-behavior (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2152 @item |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2153 The default value of any style variable (with two exceptions --- see |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2154 below) is the special symbol @code{set-from-style}. Variables that are |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2155 still set to that symbol when a @ccmode{} buffer is initialized will be |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2156 set according to the current style, otherwise they will keep their |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2157 current value@footnote{This is a big change from versions of @ccmode{} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2158 earlier than 5.26, where such settings would get overridden by the style |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2159 system unless special precautions were taken. That was changed since it |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2160 was counterintuitive and confusing, especially to novice users. If your |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2161 configuration depends on the old overriding behavior, you can set the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2162 variable @code{c-old-style-variable-behavior} to non-@code{nil}.}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2163 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2164 Note that when we talk about the ``default value'' for a style variable, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2165 we don't mean the @code{set-from-style} symbol that all style variables |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2166 are set to initially, but instead the value it will get at mode |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2167 initialization when neither a style nor a global setting has set its |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2168 value. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2169 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2170 The style variable @code{c-offsets-alist} is handled a little |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2171 differently from the other style variables. It's an association list, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2172 and is thus by default set to the empty list, @code{nil}. When the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2173 style system is initialized, any syntactic symbols already on it are |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2174 kept --- only the missing ones are filled in from the chosen style. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2175 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2176 The style variable @code{c-special-indent-hook} is also handled in a |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2177 special way. Styles may only add more functions on this hook, so the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2178 global settings on it are always preserved@footnote{This did not change |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2179 in version 5.26.}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2180 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2181 @item |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2182 The global settings of style variables get captured in the special |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2183 @code{user} style, which is used as the base for all the other styles. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2184 @xref{Built-in Styles}, for details. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2185 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2186 @end itemize |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2187 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2188 The style variables are: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2189 @code{c-basic-offset}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2190 @code{c-comment-only-line-offset}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2191 @code{c-block-comment-prefix}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2192 @code{c-comment-prefix-regexp}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2193 @code{c-cleanup-list}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2194 @code{c-hanging-braces-alist}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2195 @code{c-hanging-colons-alist}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2196 @code{c-hanging-semi&comma-criteria}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2197 @code{c-backslash-column}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2198 @code{c-special-indent-hook}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2199 @code{c-label-minimum-indentation}, and |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2200 @code{c-offsets-alist}. |
25829 | 2201 |
2202 @menu | |
2203 * Built-in Styles:: | |
2204 * Adding Styles:: | |
2205 * File Styles:: | |
2206 @end menu | |
2207 | |
2208 | |
2209 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2210 @node Built-in Styles, Adding Styles, , Styles |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2211 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2212 @subsection Built-in Styles |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2213 @cindex built-in styles |
25829 | 2214 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2215 | |
2216 If you're lucky, one of @ccmode{}'s built-in styles might be just | |
2217 what you're looking for. These include: | |
2218 | |
2219 @itemize @bullet | |
2220 @cindex GNU style | |
2221 @item | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2222 @code{gnu} --- Coding style blessed by the Free Software Foundation |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2223 for C code in GNU programs. |
25829 | 2224 |
2225 @cindex K&R style | |
2226 @item | |
2227 @code{k&r} --- The classic Kernighan and Ritchie style for C code. | |
2228 | |
2229 @cindex BSD style | |
2230 @item | |
2231 @code{bsd} --- Also known as ``Allman style'' after Eric Allman. | |
2232 | |
2233 @cindex Whitesmith style | |
2234 @item | |
2235 @code{whitesmith} --- Popularized by the examples that came with | |
2236 Whitesmiths C, an early commercial C compiler. | |
2237 | |
2238 @cindex Stroustrup style | |
2239 @item | |
2240 @code{stroustrup} --- The classic Stroustrup style for C++ code. | |
2241 | |
2242 @cindex Ellemtel style | |
2243 @item | |
2244 @code{ellemtel} --- Popular C++ coding standards as defined by | |
2245 ``Programming in C++, Rules and Recommendations'', Erik Nyquist and Mats | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2246 Henricson, Ellemtel@footnote{This document is available at |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2247 @uref{http://www.doc.ic.ac.uk/lab/cplus/c++.rules/} among other |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2248 places.}. |
25829 | 2249 |
2250 @cindex Linux style | |
2251 @item | |
2252 @code{linux} --- C coding standard for Linux development. | |
2253 | |
2254 @cindex Python style | |
2255 @item | |
2256 @code{python} --- C coding standard for Python extension | |
2257 modules@footnote{Python is a high level scripting language with a C/C++ | |
2258 foreign function interface. For more information, see | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2259 @uref{http://www.python.org/}.}. |
25829 | 2260 |
2261 @cindex Java style | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2262 @findex java-mode |
25829 | 2263 @item |
2264 @code{java} --- The style for editing Java code. Note that this style is | |
2265 automatically installed when you enter @code{java-mode}. | |
2266 | |
2267 @cindex User style | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2268 @item |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2269 @code{user} --- This is a special style for several reasons. First, the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2270 @ccmode{} customizations you do by using either the Customization |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2271 interface, or by writing @code{setq}'s at the top level of your |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2272 @file{.emacs} file, will be captured in the @code{user} style. Also, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2273 all other styles implicitly inherit their settings from @code{user} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2274 style. This means that for any styles you add via @code{c-add-style} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2275 (@pxref{Adding Styles}) you need only define the differences between |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2276 your new style and @code{user} style. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2277 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2278 @end itemize |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2279 |
25829 | 2280 @vindex c-default-style |
2281 @vindex default-style (c-) | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2282 The default style in all newly created buffers is @code{gnu}, but you |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2283 can change this by setting variable @code{c-default-style}. Although |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2284 the @code{user} style is not the default style, any style variable |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2285 settings you do with the Customization interface or on the top level in |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2286 your @file{.emacs} file will by default override the style system, so |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2287 you don't need to set @code{c-default-style} to @code{user} to see the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2288 effect of these settings. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2289 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2290 @code{c-default-style} takes either a style name string, or an |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2291 association list of major mode symbols to style names. Thus you can |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2292 control exactly which default style is used for which @ccmode{} language |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2293 mode. Here are the rules: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2294 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2295 @vindex c-style-alist |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2296 @vindex style-alist (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2297 @vindex c-mode-common-hook |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2298 @vindex mode-common-hook (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2299 @enumerate |
25829 | 2300 @item |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2301 When @code{c-default-style} is a string, it must be an existing style |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2302 name as found in @code{c-style-alist}. This style is then used for all |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2303 modes @emph{except} @code{java-mode}, where the style @samp{java} is |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2304 used by default@footnote{This is for backwards compatibility reasons. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2305 The hard-coding of @code{java-mode} style is admittedly bogus!}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2306 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2307 @item |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2308 When @code{c-default-style} is an association list, the current major |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2309 mode is looked up to find a style name string. In this case, this style |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2310 is always used exactly as specified and an error will occur if the named |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2311 style does not exist. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2312 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2313 @item |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2314 If @code{c-default-style} is an association list, but the current major |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2315 mode isn't found, then the special symbol @samp{other} is looked up. If |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2316 this value is found, the associated style is used. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2317 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2318 @item |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2319 If @samp{other} is not found, then the @samp{gnu} style is used. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2320 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2321 @item |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2322 In all cases, the style described in @code{c-default-style} is installed |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2323 @emph{before} the language hooks are run, so you can always override |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2324 this setting by including an explicit call to @code{c-set-style} in your |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2325 language mode hook, or in @code{c-mode-common-hook}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2326 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2327 @end enumerate |
25829 | 2328 |
2329 @findex c-set-style | |
2330 @findex set-style (c-) | |
2331 @kindex C-c . | |
2332 If you'd like to experiment with these built-in styles you can simply | |
2333 type the following in a @ccmode{} buffer: | |
2334 @example | |
2335 @group | |
2336 | |
2337 @kbd{C-c . @var{STYLE-NAME} RET} | |
2338 | |
2339 @end group | |
2340 @end example | |
2341 @noindent | |
2342 @kbd{C-c .} runs the command @code{c-set-style}. Note that all style | |
2343 names are case insensitive, even the ones you define. | |
2344 | |
2345 Setting a style in this way does @emph{not} automatically re-indent your | |
2346 file. For commands that you can use to view the effect of your changes, | |
2347 see @ref{Commands}. | |
2348 | |
2349 @vindex c-indentation-style | |
2350 @vindex indentation-style (c-) | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2351 Note that for BOCM compatibility, @samp{gnu} is the default style, and |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2352 any non-style based customizations you make (i.e. in |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2353 @code{c-mode-common-hook} in your @file{.emacs} file) will be based on |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2354 @samp{gnu} style unless you set @code{c-default-style} or do a |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2355 @code{c-set-style} as the first thing in your hook. The variable |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2356 @code{c-indentation-style} always contains the buffer's current style |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2357 name, as a string. |
25829 | 2358 |
2359 | |
2360 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2361 @node Adding Styles, File Styles, Built-in Styles, Styles |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2362 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2363 @subsection Adding Styles |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2364 @cindex adding styles |
25829 | 2365 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2366 | |
2367 @vindex c-style-alist | |
2368 @vindex style-alist (c-) | |
2369 @findex c-add-style | |
2370 @findex add-style (c-) | |
2371 If none of the built-in styles is appropriate, you'll probably want to | |
2372 add a new @dfn{style definition}. Styles are kept in the | |
2373 @code{c-style-alist} variable, but you should never modify this variable | |
2374 directly. Instead, @ccmode{} provides the function | |
2375 @code{c-add-style} that you can use to easily add new styles or change | |
2376 existing styles. This function takes two arguments, a @var{stylename} | |
2377 string, and an association list @var{description} of style | |
2378 customizations. If @var{stylename} is not already in | |
2379 @code{c-style-alist}, the new style is added, otherwise the style is | |
2380 changed to the new @var{description}. | |
2381 This function also takes an optional third argument, which if | |
2382 non-@code{nil}, automatically applies the new style to the current | |
2383 buffer. | |
2384 | |
2385 @comment TBD: The next paragraph is bogus. I really need to better | |
2386 @comment document adding styles, including setting up inherited styles. | |
2387 | |
2388 The sample @file{.emacs} file provides a concrete example of how a new | |
2389 style can be added and automatically set. @xref{Sample .emacs File}. | |
2390 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2391 |
25829 | 2392 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2393 @node File Styles, , Adding Styles, Styles |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2394 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2395 @subsection File Styles |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2396 @cindex file styles |
25829 | 2397 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2398 | |
2399 @cindex local variables | |
2400 | |
2401 The Emacs manual describes how you can customize certain variables on a | |
2402 per-file basis by including a @dfn{Local Variable} block at the end of | |
2403 the file. So far, you've only seen a functional interface to @ccmode{} | |
2404 customization, which is highly inconvenient for use in a Local Variable | |
2405 block. @ccmode{} provides two variables that make it easier for you to | |
2406 customize your style on a per-file basis. | |
2407 | |
2408 @vindex c-file-style | |
2409 @vindex file-style (c-) | |
2410 @vindex c-file-offsets | |
2411 @vindex file-offsets (c-) | |
2412 | |
2413 The variable @code{c-file-style} can be set to a style name string. | |
2414 When the file is visited, @ccmode{} will automatically set the | |
2415 file's style to this style using @code{c-set-style}. | |
2416 | |
2417 Another variable, @code{c-file-offsets}, takes an association list | |
2418 similar to what is allowed in @code{c-offsets-alist}. When the file is | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2419 visited, @ccmode{} will automatically institute these offsets using |
25829 | 2420 @code{c-set-offset}. |
2421 | |
2422 Note that file style settings (i.e. @code{c-file-style}) are applied | |
2423 before file offset settings (i.e. @code{c-file-offsets}). Also, if | |
2424 either of these are set in a file's local variable section, all the | |
2425 style variable values are made local to that buffer. | |
2426 | |
2427 | |
2428 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2429 @node Advanced Customizations, , Styles, Customizing Indentation |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2430 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2431 @section Advanced Customizations |
25829 | 2432 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2433 | |
2434 @vindex c-style-alist | |
2435 @vindex style-alist (c-) | |
2436 For most users, @ccmode{} will support their coding styles with | |
2437 very little need for more advanced customizations. Usually, one of the | |
2438 standard styles defined in @code{c-style-alist} will do the trick. At | |
2439 most, perhaps one of the syntactic symbol offsets will need to be | |
2440 tweaked slightly, or maybe @code{c-basic-offset} will need to be | |
2441 changed. However, some styles require a more flexible framework for | |
2442 customization, and one of the real strengths of @ccmode{} is that | |
2443 the syntactic analysis model provides just such a framework. This allows | |
2444 you to implement custom indentation calculations for situations not | |
2445 handled by the mode directly. | |
2446 | |
2447 @menu | |
2448 * Custom Indentation Functions:: | |
2449 * Custom Brace and Colon Hanging:: | |
2450 * Customizing Semi-colons and Commas:: | |
2451 * Other Special Indentations:: | |
2452 @end menu | |
2453 | |
2454 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2455 @node Custom Indentation Functions, Custom Brace and Colon Hanging, , Advanced Customizations |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2456 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2457 @subsection Custom Indentation Functions |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2458 @cindex custom indentation functions |
25829 | 2459 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2460 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2461 The most flexible way to customize @ccmode{} is by writing custom |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2462 indentation functions, and associating them with specific syntactic |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2463 symbols (@pxref{Syntactic Symbols}). @ccmode{} itself uses indentation |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2464 functions to provide more sophisticated indentation, for example when |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2465 lining up C++ stream operator blocks: |
25829 | 2466 @example |
2467 @group | |
2468 | |
2469 1: void main(int argc, char**) | |
2470 2: @{ | |
2471 3: cout << "There were " | |
2472 4: << argc | |
2473 5: << "arguments passed to the program" | |
2474 6: << endl; | |
2475 7: @} | |
2476 | |
2477 @end group | |
2478 @end example | |
2479 | |
2480 In this example, lines 4 through 6 are assigned the @code{stream-op} | |
2481 syntactic symbol. Here, @code{stream-op} has an offset of @code{+}, and | |
2482 with a @code{c-basic-offset} of 2, you can see that lines 4 through 6 | |
2483 are simply indented two spaces to the right of line 3. But perhaps we'd | |
2484 like @ccmode{} to be a little more intelligent so that it aligns | |
2485 all the @samp{<<} symbols in lines 3 through 6. To do this, we have | |
2486 to write a custom indentation function which finds the column of first | |
2487 stream operator on the first line of the statement. Here is sample | |
2488 lisp code implementing this: | |
2489 @example | |
2490 @group | |
2491 | |
2492 (defun c-lineup-streamop (langelem) | |
2493 ;; lineup stream operators | |
2494 (save-excursion | |
2495 (let* ((relpos (cdr langelem)) | |
2496 (curcol (progn (goto-char relpos) | |
2497 (current-column)))) | |
2498 (re-search-forward "<<\\|>>" (c-point 'eol) 'move) | |
2499 (goto-char (match-beginning 0)) | |
2500 (- (current-column) curcol)))) | |
2501 | |
2502 @end group | |
2503 @end example | |
2504 @noindent | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2505 Indentation functions take a single argument, which is a syntactic |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2506 component cons cell (@pxref{Syntactic Analysis}). The function returns |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2507 an integer offset value that will be added to the running total |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2508 indentation for the line. Note that what actually gets returned is the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2509 difference between the column that the first stream operator is on, and |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2510 the column of the buffer relative position passed in the function's |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2511 argument. Remember that @ccmode{} automatically adds in the column of |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2512 the component's relative buffer position and we don't the column offset |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2513 added in twice. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2514 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2515 The function should return @code{nil} if it's used in a situation where |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2516 it doesn't want to do any decision. If the function is used in a list |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2517 expression (@pxref{Customizing Indentation}), that will cause @ccmode{} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2518 to go on and check the next entry in the list. |
25829 | 2519 |
2520 @cindex stream-op syntactic symbol | |
2521 @findex c-lineup-streamop | |
2522 @findex lineup-streamop (c-) | |
2523 Now, to associate the function @code{c-lineup-streamop} with the | |
2524 @code{stream-op} syntactic symbol, we can add something like the | |
2525 following to our @code{c++-mode-hook}@footnote{It probably makes more | |
2526 sense to add this to @code{c++-mode-hook} than @code{c-mode-common-hook} | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2527 since stream operators are only relevant for C++.}: |
25829 | 2528 @example |
2529 | |
2530 (c-set-offset 'stream-op 'c-lineup-streamop) | |
2531 | |
2532 @end example | |
2533 | |
2534 Now the function looks like this after re-indenting (using @kbd{C-c | |
2535 C-q}): | |
2536 @example | |
2537 @group | |
2538 | |
2539 1: void main(int argc, char**) | |
2540 2: @{ | |
2541 3: cout << "There were " | |
2542 4: << argc | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2543 5: << " arguments passed to the program" |
25829 | 2544 6: << endl; |
2545 7: @} | |
2546 | |
2547 @end group | |
2548 @end example | |
2549 | |
2550 Custom indentation functions can be as simple or as complex as you like, | |
2551 and any syntactic symbol that appears in @code{c-offsets-alist} can have | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2552 a custom indentation function associated with it. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2553 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2554 @ccmode{} comes with an extensive set of predefined indentation |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2555 functions, not all of which are used by the default styles. So there's |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2556 a good chance the function you want already exists. @xref{Indentation |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2557 Functions}, for a list of them. If you have written an indentation |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2558 function that you think is generally useful, you're very welcome to |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2559 contribute it; please contact @email{bug-cc-mode@@gnu.org}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2560 |
25829 | 2561 |
2562 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2563 @node Custom Brace and Colon Hanging, Customizing Semi-colons and Commas, Custom Indentation Functions, Advanced Customizations |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2564 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2565 @subsection Custom Brace and Colon Hanging |
25829 | 2566 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2567 | |
2568 @vindex c-hanging-braces-alist | |
2569 @vindex hanging-braces-alist (c-) | |
2570 Syntactic symbols aren't the only place where you can customize | |
2571 @ccmode{} with the lisp equivalent of callback functions. Brace | |
2572 ``hanginess'' can also be determined by custom functions associated with | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2573 syntactic symbols on the @code{c-hanging-braces-alist} style variable. |
25829 | 2574 Remember that @var{ACTION}'s are typically a list containing some |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2575 combination of the symbols @code{before} and @code{after} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2576 (@pxref{Hanging Braces}). However, an @var{ACTION} can also be a |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2577 function which gets called when a brace matching that syntactic symbol |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2578 is entered. |
25829 | 2579 |
2580 @cindex customizing brace hanging | |
2581 These @var{ACTION} functions are called with two arguments: the | |
2582 syntactic symbol for the brace, and the buffer position at which the | |
2583 brace was inserted. The @var{ACTION} function is expected to return a | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2584 list containing some combination of @code{before} and @code{after}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2585 including neither of them (i.e. @code{nil}). This return value has the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2586 normal brace hanging semantics. |
25829 | 2587 |
2588 As an example, @ccmode{} itself uses this feature to dynamically | |
2589 determine the hanginess of braces which close ``do-while'' | |
2590 constructs: | |
2591 @example | |
2592 @group | |
2593 | |
2594 void do_list( int count, char** atleast_one_string ) | |
2595 @{ | |
2596 int i=0; | |
2597 do @{ | |
2598 handle_string( atleast_one_string[i] ); | |
2599 i++; | |
2600 @} while( i < count ); | |
2601 @} | |
2602 | |
2603 @end group | |
2604 @end example | |
2605 | |
2606 @findex c-snug-do-while | |
2607 @findex snug-do-while (c-) | |
2608 @ccmode{} assigns the @code{block-close} syntactic symbol to the | |
2609 brace that closes the @code{do} construct, and normally we'd like the | |
2610 line that follows a @code{block-close} brace to begin on a separate | |
2611 line. However, with ``do-while'' constructs, we want the | |
2612 @code{while} clause to follow the closing brace. To do this, we | |
2613 associate the @code{block-close} symbol with the @var{ACTION} function | |
2614 @code{c-snug-do-while}: | |
2615 @example | |
2616 | |
2617 (defun c-snug-do-while (syntax pos) | |
2618 "Dynamically calculate brace hanginess for do-while statements. | |
2619 Using this function, `while' clauses that end a `do-while' block will | |
2620 remain on the same line as the brace that closes that block. | |
2621 | |
2622 See `c-hanging-braces-alist' for how to utilize this function as an | |
2623 ACTION associated with `block-close' syntax." | |
2624 (save-excursion | |
2625 (let (langelem) | |
2626 (if (and (eq syntax 'block-close) | |
2627 (setq langelem (assq 'block-close c-syntactic-context)) | |
2628 (progn (goto-char (cdr langelem)) | |
2629 (if (= (following-char) ?@{) | |
2630 (forward-sexp -1)) | |
2631 (looking-at "\\<do\\>[^_]"))) | |
2632 '(before) | |
2633 '(before after))))) | |
2634 | |
2635 @end example | |
2636 | |
2637 This function simply looks to see if the brace closes a ``do-while'' | |
2638 clause and if so, returns the list @samp{(before)} indicating | |
2639 that a newline should be inserted before the brace, but not after it. | |
2640 In all other cases, it returns the list @samp{(before after)} so | |
2641 that the brace appears on a line by itself. | |
2642 | |
2643 @vindex c-syntactic-context | |
2644 @vindex syntactic-context (c-) | |
2645 During the call to the brace hanging @var{ACTION} function, the variable | |
2646 @code{c-syntactic-context} is bound to the full syntactic analysis list. | |
2647 | |
2648 @cindex customizing colon hanging | |
2649 @vindex c-hanging-colon-alist | |
2650 @vindex hanging-colon-alist (c-) | |
2651 Note that for symmetry, colon hanginess should be customizable by | |
2652 allowing function symbols as @var{ACTION}s on the | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2653 @code{c-hanging-colon-alist} style variable. Since no use has actually |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2654 been found for this feature, it isn't currently implemented! |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2655 |
25829 | 2656 |
2657 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2658 @node Customizing Semi-colons and Commas, Other Special Indentations, Custom Brace and Colon Hanging, Advanced Customizations |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2659 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2660 @subsection Customizing Semi-colons and Commas |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2661 @cindex customizing semi-colons and commas |
25829 | 2662 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2663 | |
2664 @vindex c-hanging-semi&comma-criteria | |
2665 @vindex hanging-semi&comma-criteria (c-) | |
2666 You can also customize the insertion of newlines after semi-colons and | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2667 commas, when the auto-newline minor mode is enabled (@pxref{Minor |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2668 Modes}). This is controlled by the style variable |
25829 | 2669 @code{c-hanging-semi&comma-criteria}, which contains a list of functions |
2670 that are called in the order they appear. Each function is called with | |
2671 zero arguments, and is expected to return one of the following values: | |
2672 | |
2673 @itemize @bullet | |
2674 @item | |
2675 non-@code{nil} --- A newline is inserted, and no more functions from the | |
2676 list are called. | |
2677 | |
2678 @item | |
2679 @code{stop} --- No more functions from the list are called, but no | |
2680 newline is inserted. | |
2681 | |
2682 @item | |
2683 @code{nil} --- No determination is made, and the next function in the | |
2684 list is called. | |
2685 | |
2686 @end itemize | |
2687 | |
2688 If every function in the list is called without a determination being | |
2689 made, then no newline is added. The default value for this variable is a | |
2690 list containing a single function which inserts newlines only after | |
2691 semi-colons which do not appear inside parenthesis lists (i.e. those | |
2692 that separate @code{for}-clause statements). | |
2693 | |
2694 @findex c-semi&comma-no-newlines-before-nonblanks | |
2695 @findex semi&comma-no-newlines-before-nonblanks (c-) | |
2696 Here's an example of a criteria function, provided by @ccmode{}, that | |
2697 will prevent newlines from being inserted after semicolons when there is | |
2698 a non-blank following line. Otherwise, it makes no determination. To | |
2699 use, add this to the front of the @code{c-hanging-semi&comma-criteria} | |
2700 list. | |
2701 | |
2702 @example | |
2703 @group | |
2704 | |
2705 (defun c-semi&comma-no-newlines-before-nonblanks () | |
2706 (save-excursion | |
2707 (if (and (eq last-command-char ?\;) | |
2708 (zerop (forward-line 1)) | |
2709 (not (looking-at "^[ \t]*$"))) | |
2710 'stop | |
2711 nil))) | |
2712 | |
2713 @end group | |
2714 @end example | |
2715 | |
2716 @findex c-semi&comma-inside-parenlist | |
2717 @findex c-semi&comma-no-newlines-for-oneline-inliners | |
2718 @findex semi&comma-inside-parenlist (c-) | |
2719 @findex semi&comma-no-newlines-for-oneline-inliners (c-) | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2720 The function @code{c-semi&comma-inside-parenlist} is what prevents |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2721 newlines from being inserted inside the parenthesis list of @code{for} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2722 statements. In addition to |
25829 | 2723 @code{c-semi&comma-no-newlines-before-nonblanks} described above, |
2724 @ccmode{} also comes with the criteria function | |
2725 @code{c-semi&comma-no-newlines-for-oneline-inliners}, which suppresses | |
2726 newlines after semicolons inside one-line inline method definitions | |
2727 (i.e. in C++ or Java). | |
2728 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2729 |
25829 | 2730 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2731 @node Other Special Indentations, , Customizing Semi-colons and Commas, Advanced Customizations |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2732 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2733 @subsection Other Special Indentations |
25829 | 2734 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2735 | |
2736 @vindex c-label-minimum-indentation | |
2737 @vindex label-minimum-indentation (c-) | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2738 In @samp{gnu} style (@pxref{Built-in Styles}), a minimum indentation |
25829 | 2739 is imposed on lines inside top-level constructs. This minimum |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2740 indentation is controlled by the style variable |
25829 | 2741 @code{c-label-minimum-indentation}. The default value for this variable |
2742 is 1. | |
2743 | |
2744 @vindex c-special-indent-hook | |
2745 @vindex special-indent-hook (c-) | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2746 One other customization variable is available in @ccmode{}: The style |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2747 variable @code{c-special-indent-hook}. This is a standard hook variable |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2748 that is called after every line is indented by @ccmode{}. You can use |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2749 it to do any special indentation or line adjustments your style |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2750 dictates, such as adding extra indentation to constructors or destructor |
25829 | 2751 declarations in a class definition, etc. Note however, that you should |
2752 not change point or mark inside your @code{c-special-indent-hook} | |
2753 functions (i.e. you'll probably want to wrap your function in a | |
2754 @code{save-excursion}). | |
2755 | |
2756 Setting @code{c-special-indent-hook} in your style definition is handled | |
2757 slightly differently than other variables. In your style definition, | |
2758 you should set the value for | |
2759 @code{c-special-indent-hook} to a function or list of functions, which | |
2760 will be appended to @code{c-special-indent-hook} using @code{add-hook}. | |
2761 That way, the current setting for the buffer local value of | |
2762 @code{c-special-indent-hook} won't be overridden. | |
2763 | |
2764 @kindex M-; | |
2765 @findex indent-for-comment | |
2766 @vindex c-indent-comments-syntactically-p | |
2767 @vindex indent-comments-syntactically-p (c-) | |
2768 @vindex comment-column | |
2769 Normally, the standard Emacs command @kbd{M-;} | |
2770 (@code{indent-for-comment}) will indent comment only lines to | |
2771 @code{comment-column}. Some users however, prefer that @kbd{M-;} act | |
2772 just like @kbd{TAB} for purposes of indenting comment-only lines; | |
2773 i.e. they want the comments to always indent as they would for normal | |
2774 code, regardless of whether @kbd{TAB} or @kbd{M-;} were used. This | |
2775 behavior is controlled by the variable | |
2776 @code{c-indent-comments-syntactically-p}. When @code{nil} (the | |
2777 default), @kbd{M-;} indents comment-only lines to @code{comment-column}, | |
2778 otherwise, they are indented just as they would be if @kbd{TAB} were | |
2779 typed. | |
2780 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2781 Note that this has no effect for comment lines that are inserted with |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2782 @kbd{M-;} at the end of regular code lines. These comments will always |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2783 start at @code{comment-column}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2784 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2785 |
25829 | 2786 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2787 @node Syntactic Symbols, Indentation Functions, Customizing Indentation, Top |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2788 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2789 @chapter Syntactic Symbols |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2790 @cindex syntactic symbols |
25829 | 2791 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2792 | |
2793 @vindex c-offsets-alist | |
2794 @vindex offsets-alist (c-) | |
2795 Here is a complete list of the recognized syntactic symbols as described | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2796 in the @code{c-offsets-alist} style variable, along with a brief |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2797 description. More detailed descriptions follow. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2798 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2799 @table @code |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2800 @item string |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2801 Inside a multi-line string. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2802 @item c |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2803 Inside a multi-line C style block comment. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2804 @item defun-open |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2805 Brace that opens a top-level function definition. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2806 @item defun-close |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2807 Brace that closes a top-level function definition. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2808 @item defun-block-intro |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2809 The first line in a top-level defun. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2810 @item class-open |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2811 Brace that opens a class definition. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2812 @item class-close |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2813 Brace that closes a class definition. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2814 @item inline-open |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2815 Brace that opens an in-class inline method. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2816 @item inline-close |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2817 Brace that closes an in-class inline method. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2818 @item func-decl-cont |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2819 The region between a function definition's argument list and the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2820 function opening brace (excluding K&R argument declarations). In C, you |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2821 cannot put anything but whitespace and comments in this region, however |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2822 in C++ and Java, @code{throws} declarations and other things can appear |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2823 here. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2824 @item knr-argdecl-intro |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2825 First line of a K&R C argument declaration. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2826 @item knr-argdecl |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2827 Subsequent lines in a K&R C argument declaration. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2828 @item topmost-intro |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2829 The first line in a ``topmost'' definition. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2830 @item topmost-intro-cont |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2831 Topmost definition continuation lines. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2832 @item member-init-intro |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2833 First line in a member initialization list. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2834 @item member-init-cont |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2835 Subsequent member initialization list lines. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2836 @item inher-intro |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2837 First line of a multiple inheritance list. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2838 @item inher-cont |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2839 Subsequent multiple inheritance lines. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2840 @item block-open |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2841 Statement block open brace. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2842 @item block-close |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2843 Statement block close brace. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2844 @item brace-list-open |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2845 Open brace of an enum or static array list. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2846 @item brace-list-close |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2847 Close brace of an enum or static array list. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2848 @item brace-list-intro |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2849 First line in an enum or static array list. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2850 @item brace-list-entry |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2851 Subsequent lines in an enum or static array list. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2852 @item brace-entry-open |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2853 Subsequent lines in an enum or static array list where the line begins |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2854 with an open brace. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2855 @item statement |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2856 A statement. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2857 @item statement-cont |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2858 A continuation of a statement. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2859 @item statement-block-intro |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2860 The first line in a new statement block. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2861 @item statement-case-intro |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2862 The first line in a case block. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2863 @item statement-case-open |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2864 The first line in a case block that starts with a brace. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2865 @item substatement |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2866 The first line after a conditional or loop construct. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2867 @item substatement-open |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2868 The brace that opens a substatement block. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2869 @item case-label |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2870 A @code{case} or @code{default} label. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2871 @item access-label |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2872 C++ access control label. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2873 @item label |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2874 Any non-special C label. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2875 @item do-while-closure |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2876 The @code{while} line that ends a @code{do}-@code{while} construct. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2877 @item else-clause |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2878 The @code{else} line of an @code{if}-@code{else} construct. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2879 @item catch-clause |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2880 The @code{catch} or @code{finally} (in Java) line of a |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2881 @code{try}-@code{catch} construct. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2882 @item comment-intro |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2883 A line containing only a comment introduction. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2884 @item arglist-intro |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2885 The first line in an argument list. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2886 @item arglist-cont |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2887 Subsequent argument list lines when no arguments follow on the same line |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2888 as the the arglist opening paren. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2889 @item arglist-cont-nonempty |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2890 Subsequent argument list lines when at least one argument follows on the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2891 same line as the arglist opening paren. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2892 @item arglist-close |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2893 The solo close paren of an argument list. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2894 @item stream-op |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2895 Lines continuing a stream operator (C++ only). |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2896 @item inclass |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2897 The line is nested inside a class definition. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2898 @item cpp-macro |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2899 The start of a C preprocessor macro definition. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2900 @item cpp-macro-cont |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2901 Subsequent lines of a multi-line C preprocessor macro definition. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2902 @item friend |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2903 A C++ friend declaration. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2904 @item objc-method-intro |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2905 The first line of an Objective-C method. definition. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2906 @item objc-method-args-cont |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2907 Lines continuing an Objective-C method. definition |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2908 @item objc-method-call-cont |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2909 Lines continuing an Objective-C method call. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2910 @item extern-lang-open |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2911 Brace that opens an external language block. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2912 @item extern-lang-close |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2913 Brace that closes an external language block. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2914 @item inextern-lang |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2915 Analogous to @code{inclass} syntactic symbol, but used inside external |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2916 language blocks (e.g. @code{extern "C" @{}). |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2917 @item namespace-open |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2918 Brace that opens a C++ namespace block. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2919 @item namespace-close |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2920 Brace that closes a C++ namespace block. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2921 @item innamespace |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2922 Analogous to @code{inextern-lang} syntactic symbol, but used inside C++ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2923 namespace blocks. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2924 @item template-args-cont |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2925 C++ template argument list continuations. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2926 @item inlambda |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2927 Analogous to @code{inclass} syntactic symbol, but used inside lambda |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2928 (i.e. anonymous) functions. Only used in Pike mode. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2929 @item lambda-intro-cont |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2930 Lines continuing the header of a lambda function, i.e. between the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2931 @code{lambda} keyword and the function body. Only used in Pike mode. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2932 @item inexpr-statement |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2933 A statement block inside an expression. The gcc C extension of this is |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2934 recognized. It's also used for the special functions that takes a |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2935 statement block as an argument in Pike. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2936 @item inexpr-class |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2937 A class definition inside an expression. This is used for anonymous |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2938 classes in Java. It's also used for anonymous array initializers in |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2939 Java. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2940 @end table |
25829 | 2941 |
2942 @cindex -open syntactic symbols | |
2943 @cindex -close syntactic symbols | |
2944 Most syntactic symbol names follow a general naming convention. When a | |
2945 line begins with an open or close brace, the syntactic symbol will | |
2946 contain the suffix @code{-open} or @code{-close} respectively. | |
2947 | |
2948 @cindex -intro syntactic symbols | |
2949 @cindex -cont syntactic symbols | |
2950 @cindex -block-intro syntactic symbols | |
2951 Usually, a distinction is made between the first line that introduces a | |
2952 construct and lines that continue a construct, and the syntactic symbols | |
2953 that represent these lines will contain the suffix @code{-intro} or | |
2954 @code{-cont} respectively. As a sub-classification of this scheme, a | |
2955 line which is the first of a particular brace block construct will | |
2956 contain the suffix @code{-block-intro}. | |
2957 | |
2958 Let's look at some examples to understand how this works. Remember that | |
2959 you can check the syntax of any line by using @kbd{C-c C-s}. | |
2960 @example | |
2961 @group | |
2962 | |
2963 1: void | |
2964 2: swap( int& a, int& b ) | |
2965 3: @{ | |
2966 4: int tmp = a; | |
2967 5: a = b; | |
2968 6: b = tmp; | |
2969 7: int ignored = | |
2970 8: a + b; | |
2971 9: @} | |
2972 | |
2973 @end group | |
2974 @end example | |
2975 | |
2976 @cindex topmost-intro syntactic symbol | |
2977 @cindex topmost-intro-cont syntactic symbol | |
2978 @cindex defun-open syntactic symbol | |
2979 @cindex defun-close syntactic symbol | |
2980 @cindex defun-block-intro syntactic symbol | |
2981 Line 1 shows a @code{topmost-intro} since it is the first line that | |
2982 introduces a top-level construct. Line 2 is a continuation of the | |
2983 top-level construct introduction so it has the syntax | |
2984 @code{topmost-intro-cont}. Line 3 shows a @code{defun-open} since it is | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2985 the brace that opens a top-level function definition. Line 9 is the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2986 corresponding |
25829 | 2987 @code{defun-close} since it contains the brace that closes the top-level |
2988 function definition. Line 4 is a @code{defun-block-intro}, i.e. it is | |
2989 the first line of a brace-block, enclosed in a | |
2990 top-level function definition. | |
2991 | |
2992 @cindex statement syntactic symbol | |
2993 @cindex statement-cont syntactic symbol | |
2994 Lines 5, 6, and 7 are all given @code{statement} syntax since there | |
2995 isn't much special about them. Note however that line 8 is given | |
2996 @code{statement-cont} syntax since it continues the statement begun | |
2997 on the previous line. | |
2998 | |
2999 Here's another example, which illustrates some C++ class syntactic | |
3000 symbols: | |
3001 @example | |
3002 @group | |
3003 | |
3004 1: class Bass | |
3005 2: : public Guitar, | |
3006 3: public Amplifiable | |
3007 4: @{ | |
3008 5: public: | |
3009 6: Bass() | |
3010 7: : eString( new BassString( 0.105 )), | |
3011 8: aString( new BassString( 0.085 )), | |
3012 9: dString( new BassString( 0.065 )), | |
3013 10: gString( new BassString( 0.045 )) | |
3014 11: @{ | |
3015 12: eString.tune( 'E' ); | |
3016 13: aString.tune( 'A' ); | |
3017 14: dString.tune( 'D' ); | |
3018 15: gString.tune( 'G' ); | |
3019 16: @} | |
3020 17: friend class Luthier; | |
3021 18: @} | |
3022 | |
3023 @end group | |
3024 @end example | |
3025 | |
3026 @cindex class-open syntactic symbol | |
3027 @cindex class-close syntactic symbol | |
3028 As in the previous example, line 1 has the @code{topmost-intro} syntax. | |
3029 Here however, the brace that opens a C++ class definition on line 4 is | |
3030 assigned the @code{class-open} syntax. Note that in C++, classes, | |
3031 structs, and unions are essentially equivalent syntactically (and are | |
3032 very similar semantically), so replacing the @code{class} keyword in the | |
3033 example above with @code{struct} or @code{union} would still result in a | |
3034 syntax of @code{class-open} for line 4 @footnote{This is the case even | |
3035 for C and Objective-C. For consistency, structs in all supported | |
3036 languages are syntactically equivalent to classes. Note however that | |
3037 the keyword @code{class} is meaningless in C and Objective-C.}. | |
3038 Similarly, line 18 is assigned @code{class-close} syntax. | |
3039 | |
3040 @cindex inher-intro syntactic symbol | |
3041 @cindex inher-cont syntactic symbol | |
3042 Line 2 introduces the inheritance list for the class so it is assigned | |
3043 the @code{inher-intro} syntax, and line 3, which continues the | |
3044 inheritance list is given @code{inher-cont} syntax. | |
3045 | |
3046 @cindex access-label syntactic symbol | |
3047 @cindex inclass syntactic symbol | |
3048 Hitting @kbd{C-c C-s} on line 5 shows the following analysis: | |
3049 | |
3050 @example | |
3051 @group | |
3052 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3053 @code{((inclass . 58) (access-label . 67))} |
25829 | 3054 |
3055 @end group | |
3056 @end example | |
3057 | |
3058 @noindent | |
3059 The primary syntactic symbol for this line is @code{access-label} as | |
3060 this a label keyword that specifies access protection in C++. However, | |
3061 because this line is also a top-level construct inside a class | |
3062 definition, the analysis actually shows two syntactic symbols. The | |
3063 other syntactic symbol assigned to this line is @code{inclass}. | |
3064 Similarly, line 6 is given both @code{inclass} and @code{topmost-intro} | |
3065 syntax: | |
3066 | |
3067 @example | |
3068 @group | |
3069 | |
3070 @code{((inclass . 58) (topmost-intro . 60))} | |
3071 | |
3072 @end group | |
3073 @end example | |
3074 | |
3075 @cindex member-init-intro syntactic symbol | |
3076 @cindex member-init-cont syntactic symbol | |
3077 Line 7 introduces a C++ member initialization list and as such is given | |
3078 @code{member-init-intro} syntax. Note that in this case it is | |
3079 @emph{not} assigned @code{inclass} since this is not considered a | |
3080 top-level construct. Lines 8 through 10 are all assigned | |
3081 @code{member-init-cont} since they continue the member initialization | |
3082 list started on line 7. | |
3083 | |
3084 @cindex in-class inline methods | |
3085 @cindex inline-open syntactic symbol | |
3086 @cindex inline-close syntactic symbol | |
3087 Line 11's analysis is a bit more complicated: | |
3088 | |
3089 @example | |
3090 @group | |
3091 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3092 @code{((inclass . 58) (inline-open))} |
25829 | 3093 |
3094 @end group | |
3095 @end example | |
3096 | |
3097 This line is assigned a syntax of both @code{inline-open} and | |
3098 @code{inclass} because it opens an @dfn{in-class} C++ inline method | |
3099 definition. This is distinct from, but related to, the C++ notion of an | |
3100 inline function in that its definition occurs inside an enclosing class | |
3101 definition, which in C++ implies that the function should be inlined. | |
3102 If though, the definition of the @code{Bass} constructor appeared | |
3103 outside the class definition, the construct would be given the | |
3104 @code{defun-open} syntax, even if the keyword @code{inline} appeared | |
3105 before the method name, as in: | |
3106 @example | |
3107 @group | |
3108 | |
3109 class Bass | |
3110 : public Guitar, | |
3111 public Amplifiable | |
3112 @{ | |
3113 public: | |
3114 Bass(); | |
3115 @} | |
3116 | |
3117 inline | |
3118 Bass::Bass() | |
3119 : eString( new BassString( 0.105 )), | |
3120 aString( new BassString( 0.085 )), | |
3121 dString( new BassString( 0.065 )), | |
3122 gString( new BassString( 0.045 )) | |
3123 @{ | |
3124 eString.tune( 'E' ); | |
3125 aString.tune( 'A' ); | |
3126 dString.tune( 'D' ); | |
3127 gString.tune( 'G' ); | |
3128 @} | |
3129 | |
3130 @end group | |
3131 @end example | |
3132 | |
3133 @cindex friend syntactic symbol | |
3134 Returning to the previous example, line 16 is given @code{inline-close} | |
3135 syntax, while line 12 is given @code{defun-block-open} syntax, and lines | |
3136 13 through 15 are all given @code{statement} syntax. Line 17 is | |
3137 interesting in that its syntactic analysis list contains three | |
3138 elements: | |
3139 | |
3140 @example | |
3141 | |
3142 @code{((friend) (inclass . 58) (topmost-intro . 380))} | |
3143 | |
3144 @end example | |
3145 | |
3146 The @code{friend} syntactic symbol is a modifier that typically does not | |
3147 have a relative buffer position. | |
3148 | |
3149 Template definitions introduce yet another syntactic symbol: | |
3150 | |
3151 @example | |
3152 @group | |
3153 | |
3154 1: ThingManager <int, | |
3155 2: Framework::Callback *, | |
3156 3: Mutex> framework_callbacks; | |
3157 | |
3158 @end group | |
3159 @end example | |
3160 | |
3161 Here, line 1 is analyzed as a @code{topmost-intro}, but lines 2 and 3 | |
3162 are both analyzed as @code{template-args-cont} lines. | |
3163 | |
3164 Here is another (totally contrived) example which illustrates how syntax | |
3165 is assigned to various conditional constructs: | |
3166 @example | |
3167 @group | |
3168 | |
3169 1: void spam( int index ) | |
3170 2: @{ | |
3171 3: for( int i=0; i<index; i++ ) | |
3172 4: @{ | |
3173 5: if( i == 10 ) | |
3174 6: @{ | |
3175 7: do_something_special(); | |
3176 8: @} | |
3177 9: else | |
3178 10: do_something( i ); | |
3179 11: @} | |
3180 12: do @{ | |
3181 13: another_thing( i-- ); | |
3182 14: @} | |
3183 15: while( i > 0 ); | |
3184 16: @} | |
3185 | |
3186 | |
3187 @end group | |
3188 @end example | |
3189 | |
3190 @noindent | |
3191 Only the lines that illustrate new syntactic symbols will be discussed. | |
3192 | |
3193 @cindex substatement-open syntactic symbol | |
3194 @cindex substatement-block-intro syntactic symbol | |
3195 @cindex block-close syntactic symbol | |
3196 Line 4 has a brace which opens a conditional's substatement block. It | |
3197 is thus assigned @code{substatement-open} syntax, and since line 5 is | |
3198 the first line in the substatement block, it is assigned | |
3199 @code{substatement-block-intro} syntax. Lines 6 and 7 are assigned | |
3200 similar syntax. Line 8 contains the brace that closes the inner | |
3201 substatement block. It is given the syntax @code{block-close}, | |
3202 as are lines 11 and 14. | |
3203 | |
3204 @cindex else-clause syntactic symbol | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3205 @cindex catch-clause syntactic symbol |
25829 | 3206 Line 9 is a little different --- since it contains the keyword |
3207 @code{else} matching the @code{if} statement introduced on line 5, it is | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3208 given the @code{else-clause} syntax. The @code{try}-@code{catch} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3209 constructs in C++ and Java are treated this way too, with the only |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3210 difference that the @code{catch}, and in Java also @code{finally}, is |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3211 marked with @code{catch-clause}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3212 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3213 @cindex substatement syntactic symbol |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3214 Line 10 is also slightly different. Because @code{else} is considered a |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3215 conditional introducing keyword @footnote{The list of conditional |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3216 keywords are (in C, C++, Objective-C, Java, and Pike): @code{for}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3217 @code{if}, @code{do}, @code{else}, @code{while}, and @code{switch}. C++ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3218 and Java have two additional conditional keywords: @code{try} and |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3219 @code{catch}. Java also has the @code{finally} and @code{synchronized} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3220 keywords.}, and because the following substatement is not a brace block, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3221 line 10 is assigned the @code{substatement} syntax. |
25829 | 3222 |
3223 @cindex do-while-closure syntactic symbol | |
3224 One other difference is seen on line 15. The @code{while} construct | |
3225 that closes a @code{do} conditional is given the special syntax | |
3226 @code{do-while-closure} if it appears on a line by itself. Note that if | |
3227 the @code{while} appeared on the same line as the preceding close brace, | |
3228 that line would have been assigned @code{block-close} syntax instead. | |
3229 | |
3230 Switch statements have their own set of syntactic symbols. Here's an | |
3231 example: | |
3232 @example | |
3233 @group | |
3234 | |
3235 1: void spam( enum Ingredient i ) | |
3236 2: @{ | |
3237 3: switch( i ) @{ | |
3238 4: case Ham: | |
3239 5: be_a_pig(); | |
3240 6: break; | |
3241 7: case Salt: | |
3242 8: drink_some_water(); | |
3243 9: break; | |
3244 10: default: | |
3245 11: @{ | |
3246 12: what_is_it(); | |
3247 13: break; | |
3248 14: @} | |
3249 15: @} | |
3250 14: @} | |
3251 | |
3252 @end group | |
3253 @end example | |
3254 | |
3255 @cindex case-label syntactic symbol | |
3256 @cindex statement-case-intro syntactic symbol | |
3257 @cindex statement-case-open syntactic symbol | |
3258 Here, lines 4, 7, and 10 are all assigned @code{case-label} syntax, | |
3259 while lines 5 and 8 are assigned @code{statement-case-intro}. Line 11 | |
3260 is treated slightly differently since it contains a brace that opens a | |
3261 block --- it is given @code{statement-case-open} syntax. | |
3262 | |
3263 @cindex brace lists | |
3264 There are a set of syntactic symbols that are used to recognize | |
3265 constructs inside of brace lists. A brace list is defined as an | |
3266 @code{enum} or aggregate initializer list, such as might statically | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3267 initialize an array of structs. The three special aggregate constructs |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3268 in Pike, @code{(@{ @})}, @code{([ ])} and @code{(< >)}, are treated as |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3269 brace lists too. An example: |
25829 | 3270 @example |
3271 @group | |
3272 | |
3273 1: static char* ingredients[] = | |
3274 2: @{ | |
3275 3: "Ham", | |
3276 4: "Salt", | |
3277 5: NULL | |
3278 6: @} | |
3279 | |
3280 @end group | |
3281 @end example | |
3282 | |
3283 @cindex brace-list-open syntactic symbol | |
3284 @cindex brace-list-intro syntactic symbol | |
3285 @cindex brace-list-close syntactic symbol | |
3286 @cindex brace-list-entry syntactic symbol | |
3287 Following convention, line 2 in this example is assigned | |
3288 @code{brace-list-open} syntax, and line 3 is assigned | |
3289 @code{brace-list-intro} syntax. Likewise, line 6 is assigned | |
3290 @code{brace-list-close} syntax. Lines 4 and 5 however, are assigned | |
3291 @code{brace-list-entry} syntax, as would all subsequent lines in this | |
3292 initializer list. | |
3293 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3294 @cindex brace-entry-open syntactic symbol |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3295 Your static initializer might be initializing nested structures, for |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3296 example: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3297 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3298 @group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3299 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3300 1: struct intpairs[] = |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3301 2: @{ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3302 3: @{ 1, 2 @}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3303 4: @{ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3304 5: 3, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3305 6: 4 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3306 7: @} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3307 8: @{ 1, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3308 9: 2 @}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3309 10: @{ 3, 4 @} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3310 11: @} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3311 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3312 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3313 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3314 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3315 Here, you've already seen the analysis of lines 1, 2, 3, and 11. On |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3316 line 4, things get interesting; this line is assigned |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3317 @code{brace-entry-open} syntactic symbol because it's a bracelist entry |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3318 line that starts with an open brace. Lines 5 and 6 (and line 9) are |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3319 pretty standard, and line 7 is a @code{brace-list-close} as you'd |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3320 expect. Once again, line 8 is assigned as @code{brace-entry-open} as is |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3321 line 10. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3322 |
25829 | 3323 External language definition blocks also have their own syntactic |
3324 symbols. In this example: | |
3325 @example | |
3326 @group | |
3327 | |
3328 1: extern "C" | |
3329 2: @{ | |
3330 3: int thing_one( int ); | |
3331 4: int thing_two( double ); | |
3332 5: @} | |
3333 | |
3334 @end group | |
3335 @end example | |
3336 | |
3337 @cindex extern-lang-open syntactic symbol | |
3338 @cindex extern-lang-close syntactic symbol | |
3339 @cindex inextern-lang syntactic symbol | |
3340 @cindex inclass syntactic symbol | |
3341 @noindent | |
3342 line 2 is given the @code{extern-lang-open} syntax, while line 5 is given | |
3343 the @code{extern-lang-close} syntax. The analysis for line 3 yields: | |
3344 @code{((inextern-lang) (topmost-intro . 14))}, where | |
3345 @code{inextern-lang} is a modifier similar in purpose to @code{inclass}. | |
3346 | |
3347 Similarly, C++ namespace constructs have their own associated syntactic | |
3348 symbols. In this example: | |
3349 @example | |
3350 @group | |
3351 | |
3352 1: namespace foo | |
3353 2: @{ | |
3354 3: void xxx() @{@} | |
3355 4: @} | |
3356 | |
3357 @end group | |
3358 @end example | |
3359 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3360 @cindex namespace-open syntactic symbol |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3361 @cindex namespace-close syntactic symbol |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3362 @cindex innamespace syntactic symbol |
25829 | 3363 @noindent |
3364 line 2 is given the @code{namespace-open} syntax, while line 4 is given | |
3365 the @code{namespace-close} syntax. The analysis for line 3 yields: | |
3366 @code{((innamespace) (topmost-intro . 17))}, where @code{innamespace} is | |
3367 a modifier similar in purpose to @code{inextern-lang} and @code{inclass}. | |
3368 | |
3369 A number of syntactic symbols are associated with parenthesis lists, | |
3370 a.k.a argument lists, as found in function declarations and function | |
3371 calls. This example illustrates these: | |
3372 @example | |
3373 @group | |
3374 | |
3375 1: void a_function( int line1, | |
3376 2: int line2 ); | |
3377 3: | |
3378 4: void a_longer_function( | |
3379 5: int line1, | |
3380 6: int line2 | |
3381 7: ); | |
3382 8: | |
3383 9: void call_them( int line1, int line2 ) | |
3384 10: @{ | |
3385 11: a_function( | |
3386 12: line1, | |
3387 13: line2 | |
3388 14: ); | |
3389 15: | |
3390 16: a_longer_function( line1, | |
3391 17: line2 ); | |
3392 18: @} | |
3393 | |
3394 @end group | |
3395 @end example | |
3396 | |
3397 @cindex arglist-intro syntactic symbol | |
3398 @cindex arglist-close syntactic symbol | |
3399 Lines 5 and 12 are assigned @code{arglist-intro} syntax since they are | |
3400 the first line following the open parenthesis, and lines 7 and 14 are | |
3401 assigned @code{arglist-close} syntax since they contain the parenthesis | |
3402 that closes the argument list. | |
3403 | |
3404 @cindex arglist-cont-nonempty syntactic symbol | |
3405 @cindex arglist-cont syntactic symbol | |
3406 Lines that continue argument lists can be assigned one of two syntactic | |
3407 symbols. For example, Lines 2 and 17 | |
3408 are assigned @code{arglist-cont-nonempty} syntax. What this means | |
3409 is that they continue an argument list, but that the line containing the | |
3410 parenthesis that opens the list is @emph{not empty} following the open | |
3411 parenthesis. Contrast this against lines 6 and 13 which are assigned | |
3412 @code{arglist-cont} syntax. This is because the parenthesis that opens | |
3413 their argument lists is the last character on that line. | |
3414 | |
3415 Note that there is no @code{arglist-open} syntax. This is because any | |
3416 parenthesis that opens an argument list, appearing on a separate line, | |
3417 is assigned the @code{statement-cont} syntax instead. | |
3418 | |
3419 A few miscellaneous syntactic symbols that haven't been previously | |
3420 covered are illustrated by this C++ example: | |
3421 @example | |
3422 @group | |
3423 | |
3424 1: void Bass::play( int volume ) | |
3425 2: const | |
3426 3: @{ | |
3427 4: /* this line starts a multi-line | |
3428 5: * comment. This line should get `c' syntax */ | |
3429 6: | |
3430 7: char* a_multiline_string = "This line starts a multi-line \ | |
3431 8: string. This line should get `string' syntax."; | |
3432 9: | |
3433 10: note: | |
3434 11: @{ | |
3435 12: #ifdef LOCK | |
3436 13: Lock acquire(); | |
3437 14: #endif // LOCK | |
3438 15: slap_pop(); | |
3439 16: cout << "I played " | |
3440 17: << "a note\n"; | |
3441 18: @} | |
3442 19: @} | |
3443 | |
3444 @end group | |
3445 @end example | |
3446 | |
3447 The lines to note in this example include: | |
3448 | |
3449 @itemize @bullet | |
3450 | |
3451 @cindex func-decl-cont syntactic symbol | |
3452 @item | |
3453 line 2, assigned the @code{func-decl-cont} syntax; | |
3454 | |
3455 @cindex comment-intro syntactic symbol | |
3456 @item | |
3457 line 4, assigned both @code{defun-block-intro} @emph{and} | |
3458 @code{comment-intro} syntax; | |
3459 | |
3460 @cindex c syntactic symbol | |
3461 @item | |
3462 line 5, assigned @code{c} syntax; | |
3463 | |
3464 @item | |
3465 @cindex syntactic whitespace | |
3466 line 6 which, even though it contains nothing but whitespace, is | |
3467 assigned @code{defun-block-intro}. Note that the appearance of the | |
3468 comment on lines 4 and 5 do not cause line 6 to be assigned | |
3469 @code{statement} syntax because comments are considered to be | |
3470 @dfn{syntactic whitespace}, which are ignored when analyzing | |
3471 code; | |
3472 | |
3473 @cindex string syntactic symbol | |
3474 @item | |
3475 line 8, assigned @code{string} syntax; | |
3476 | |
3477 @cindex label syntactic symbol | |
3478 @item | |
3479 line 10, assigned @code{label} syntax; | |
3480 | |
3481 @cindex block-open syntactic symbol | |
3482 @item | |
3483 line 11, assigned @code{block-open} syntax; | |
3484 | |
3485 @cindex cpp-macro syntactic symbol | |
3486 @cindex cpp-macro-cont syntactic symbol | |
3487 @item | |
3488 lines 12 and 14, assigned @code{cpp-macro} syntax. | |
3489 | |
3490 @cindex stream-op syntactic symbol | |
3491 @item | |
3492 line 17, assigned @code{stream-op} syntax. | |
3493 | |
3494 @end itemize | |
3495 | |
3496 @cindex multi-line macros | |
3497 @cindex syntactic whitespace | |
3498 Multi-line C preprocessor macros are now (somewhat) supported. At least | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3499 @ccmode{} now recognizes the fact that it is inside a multi-line macro, |
25829 | 3500 and it properly skips such macros as syntactic whitespace. In this |
3501 example: | |
3502 @example | |
3503 @group | |
3504 | |
3505 1: #define LIST_LOOP(cons, listp) \ | |
3506 2: for (cons = listp; !NILP (cons); cons = XCDR (cons)) \ | |
3507 3: if (!CONSP (cons)) \ | |
3508 4: signal_error ("Invalid list format", listp); \ | |
3509 5: else | |
3510 | |
3511 @end group | |
3512 @end example | |
3513 @noindent | |
3514 line 1 is given the syntactic symbol @code{cpp-macro}. This first line | |
3515 of a macro is always given this symbol. The second and subsequent lines | |
3516 (e.g. lines 2 through 5) are given the @code{cpp-macro-cont} syntactic | |
3517 symbol, with a relative buffer position pointing to the @code{#} which | |
3518 starts the macro definition. | |
3519 | |
3520 In Objective-C buffers, there are three additional syntactic symbols | |
3521 assigned to various message calling constructs. Here's an example | |
3522 illustrating these: | |
3523 @example | |
3524 @group | |
3525 | |
3526 1: - (void)setDelegate:anObject | |
3527 2: withStuff:stuff | |
3528 3: @{ | |
3529 4: [delegate masterWillRebind:self | |
3530 5: toDelegate:anObject | |
3531 6: withExtraStuff:stuff]; | |
3532 7: @} | |
3533 | |
3534 @end group | |
3535 @end example | |
3536 | |
3537 @cindex objc-method-intro syntactic symbol | |
3538 @cindex objc-method-args-cont syntactic symbol | |
3539 @cindex objc-method-call-cont syntactic symbol | |
3540 Here, line 1 is assigned @code{objc-method-intro} syntax, and line 2 is | |
3541 assigned @code{objc-method-args-cont} syntax. Lines 5 and 6 are both | |
3542 assigned @code{objc-method-call-cont} syntax. | |
3543 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3544 Java has a concept of anonymous classes, which may look something like |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3545 this: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3546 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3547 @group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3548 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3549 1: public void watch(Observable o) @{ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3550 2: o.addObserver(new Observer() @{ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3551 3: public void update(Observable o, Object arg) @{ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3552 4: history.addElement(arg); |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3553 5: @} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3554 6: @}); |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3555 7: @} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3556 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3557 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3558 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3559 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3560 @cindex inexpr-class syntactic symbol |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3561 The brace following the @code{new} operator opens the anonymous class. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3562 Lines 3 and 6 are assigned the @code{inexpr-class} syntax, besides the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3563 @code{inclass} symbol used in normal classes. Thus, the class will be |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3564 indented just like a normal class, with the added indentation given to |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3565 @code{inexpr-class}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3566 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3567 There are a few occasions where a statement block may be used inside an |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3568 expression. One is in C code using the gcc extension for this, e.g: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3569 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3570 @group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3571 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3572 1: int res = (@{ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3573 2: int y = foo (); int z; |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3574 3: if (y > 0) z = y; else z = - y; |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3575 4: z; |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3576 5: @}); |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3577 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3578 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3579 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3580 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3581 @cindex inexpr-statement syntactic symbol |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3582 Lines 2 and 5 get the @code{inexpr-statement} syntax, besides the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3583 symbols they'd get in a normal block. Therefore, the indentation put on |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3584 @code{inexpr-statement} is added to the normal statement block |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3585 indentation. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3586 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3587 In Pike code, there are a few other situations where blocks occur inside |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3588 statements, as illustrated here: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3589 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3590 @group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3591 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3592 1: array itgob() |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3593 2: @{ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3594 3: string s = map (backtrace()[-2][3..], |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3595 4: lambda |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3596 5: (mixed arg) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3597 6: @{ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3598 7: return sprintf ("%t", arg); |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3599 8: @}) * ", " + "\n"; |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3600 9: return catch @{ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3601 10: write (s + "\n"); |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3602 11: @}; |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3603 12: @} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3604 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3605 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3606 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3607 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3608 @cindex inlambda syntactic symbol |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3609 @cindex lambda-intro-cont syntactic symbol |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3610 Lines 4 through 8 contain a lambda function, which @ccmode{} recognizes |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3611 by the @code{lambda} keyword. If the function argument list is put |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3612 on a line of its own, as in line 5, it gets the @code{lambda-intro-cont} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3613 syntax. The function body is handled as an inline method body, with the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3614 addition of the @code{inlambda} syntactic symbol. This means that line |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3615 6 gets @code{inlambda} and @code{inline-open}, and line 8 gets |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3616 @code{inline-close}@footnote{You might wonder why it doesn't get |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3617 @code{inlambda} too. It's because the closing brace is relative to the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3618 opening brace, which stands on its own line in this example. If the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3619 opening brace was hanging on the previous line, then the closing brace |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3620 would get the @code{inlambda} syntax too to be indented correctly.}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3621 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3622 @cindex inexpr-statement syntactic symbol |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3623 On line 9, @code{catch} is a special function taking a statement block |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3624 as its argument. The block is handled as an in-expression statement |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3625 with the @code{inexpr-statement} syntax, just like the gcc extended C |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3626 example above. The other similar special function, @code{gauge}, is |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3627 handled like this too. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3628 |
25829 | 3629 @cindex knr-argdecl-intro syntactic symbol |
3630 @cindex knr-argdecl syntactic symbol | |
3631 Two other syntactic symbols can appear in old style, non-prototyped C | |
3632 code @footnote{a.k.a. K&R C, or Kernighan & Ritchie C}: | |
3633 @example | |
3634 @group | |
3635 | |
3636 1: int add_three_integers(a, b, c) | |
3637 2: int a; | |
3638 3: int b; | |
3639 4: int c; | |
3640 5: @{ | |
3641 6: return a + b + c; | |
3642 7: @} | |
3643 | |
3644 @end group | |
3645 @end example | |
3646 | |
3647 Here, line 2 is the first line in an argument declaration list and so is | |
3648 given the @code{knr-argdecl-intro} syntactic symbol. Subsequent lines | |
3649 (i.e. lines 3 and 4 in this example), are given @code{knr-argdecl} | |
3650 syntax. | |
3651 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3652 |
25829 | 3653 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3654 @node Indentation Functions, Performance Issues, Syntactic Symbols, Top |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3655 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3656 @chapter Indentation Functions |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3657 @cindex indentation functions |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3658 @cindex line-up functions |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3659 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3660 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3661 Often there are cases when a simple offset setting on a syntactic symbol |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3662 isn't enough to get the desired indentation. Therefore, it's also |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3663 possible to use a @dfn{indentation function} (a.k.a. line-up function) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3664 for a syntactic symbol. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3665 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3666 @ccmode{} comes with many predefined indentation functions for common |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3667 situations. If none of these does what you want, you can write your |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3668 own, see @ref{Custom Indentation Functions}. If you do, it's probably a |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3669 good idea to start working from one of these predefined functions, they |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3670 can be found in the file @file{cc-align.el}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3671 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3672 For every function below there is a ``works with'' list that indicates |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3673 which syntactic symbols the function is intended to be used with. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3674 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3675 @macro workswith |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3676 @emph{Works with:} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3677 @end macro |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3678 @ifinfo |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3679 @unmacro workswith |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3680 @macro workswith |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3681 Works with: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3682 @end macro |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3683 @end ifinfo |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3684 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3685 @table @code |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3686 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3687 @findex c-lineup-arglist |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3688 @findex lineup-arglist (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3689 @item c-lineup-arglist |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3690 Line up the current argument line under the first argument. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3691 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3692 @workswith @code{arglist-cont-nonempty}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3693 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3694 @findex c-lineup-arglist-intro-after-paren |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3695 @findex lineup-arglist-intro-after-paren (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3696 @item c-lineup-arglist-intro-after-paren |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3697 Line up a line just after the open paren of the surrounding paren or |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3698 brace block. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3699 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3700 @workswith @code{defun-block-intro}, @code{brace-list-intro}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3701 @code{statement-block-intro}, @code{statement-case-intro}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3702 @code{arglist-intro}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3703 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3704 @findex c-lineup-arglist-close-under-paren |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3705 @findex lineup-arglist-close-under-paren (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3706 @item c-lineup-arglist-close-under-paren |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3707 Set e.g. your @code{arglist-close} syntactic symbol to this line-up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3708 function so that parentheses that close argument lists will line up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3709 under the parenthesis that opened the argument list. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3710 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3711 @workswith @code{defun-close}, @code{class-close}, @code{inline-close}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3712 @code{block-close}, @code{brace-list-close}, @code{arglist-close}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3713 @code{extern-lang-close}, @code{namespace-close} (for most of these, a |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3714 zero offset will normally produce the same result, though). |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3715 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3716 @findex c-lineup-close-paren |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3717 @findex lineup-close-paren (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3718 @item c-lineup-close-paren |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3719 Line up the closing paren under its corresponding open paren if the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3720 open paren is followed by code. If the open paren ends its line, no |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3721 indentation is added. E.g: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3722 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3723 @group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3724 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3725 main (int, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3726 char ** |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3727 ) // c-lineup-close-paren |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3728 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3729 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3730 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3731 @noindent |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3732 and |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3733 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3734 @group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3735 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3736 main ( |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3737 int, char ** |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3738 ) // c-lineup-close-paren |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3739 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3740 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3741 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3742 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3743 @workswith @code{defun-close}, @code{class-close}, @code{inline-close}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3744 @code{block-close}, @code{brace-list-close}, @code{arglist-close}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3745 @code{extern-lang-close}, @code{namespace-close}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3746 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3747 @findex c-lineup-streamop |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3748 @findex lineup-streamop (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3749 @item c-lineup-streamop |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3750 Line up C++ stream operators (i.e. @samp{<<} and @samp{>>}). |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3751 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3752 @workswith @code{stream-op}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3753 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3754 @findex c-lineup-multi-inher |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3755 @findex lineup-multi-inher (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3756 @item c-lineup-multi-inher |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3757 Line up the classes in C++ multiple inheritance clauses under each |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3758 other. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3759 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3760 @workswith @code{inher-cont}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3761 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3762 @findex c-lineup-java-inher |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3763 @findex lineup-java-inher (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3764 @item c-lineup-java-inher |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3765 Line up Java implements and extends declarations. If class names |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3766 follows on the same line as the @samp{implements}/@samp{extends} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3767 keyword, they are lined up under each other. Otherwise, they are |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3768 indented by adding @code{c-basic-offset} to the column of the keyword. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3769 E.g: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3770 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3771 @group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3772 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3773 class Foo |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3774 extends |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3775 Bar // c-lineup-java-inher |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3776 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3777 <--> c-basic-offset |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3778 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3779 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3780 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3781 @noindent |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3782 and |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3783 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3784 @group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3785 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3786 class Foo |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3787 extends Cyphr, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3788 Bar // c-lineup-java-inher |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3789 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3790 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3791 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3792 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3793 @workswith @code{inher-cont}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3794 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3795 @findex c-lineup-java-throws |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3796 @findex lineup-java-throws (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3797 @item c-lineup-java-throws |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3798 Line up Java throws declarations. If exception names follows on the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3799 same line as the throws keyword, they are lined up under each other. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3800 Otherwise, they are indented by adding @code{c-basic-offset} to the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3801 column of the @samp{throws} keyword. The @samp{throws} keyword itself |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3802 is also indented by @code{c-basic-offset} from the function declaration |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3803 start if it doesn't hang. E.g: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3804 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3805 @group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3806 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3807 int foo() |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3808 throws // c-lineup-java-throws |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3809 Bar // c-lineup-java-throws |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3810 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3811 <--><--> c-basic-offset |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3812 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3813 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3814 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3815 @noindent |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3816 and |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3817 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3818 @group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3819 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3820 int foo() throws Cyphr, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3821 Bar, // c-lineup-java-throws |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3822 Vlod // c-lineup-java-throws |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3823 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3824 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3825 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3826 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3827 @workswith @code{func-decl-cont}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3828 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3829 @findex c-indent-one-line-block |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3830 @findex indent-one-line-block (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3831 @item c-indent-one-line-block |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3832 Indent a one line block @code{c-basic-offset} extra. E.g: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3833 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3834 @group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3835 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3836 if (n > 0) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3837 @{m+=n; n=0;@} // c-indent-one-line-block |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3838 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3839 <--> c-basic-offset |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3840 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3841 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3842 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3843 @noindent |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3844 and |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3845 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3846 @group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3847 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3848 if (n > 0) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3849 @{ // c-indent-one-line-block |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3850 m+=n; n=0; |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3851 @} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3852 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3853 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3854 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3855 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3856 The block may be surrounded by any kind of parenthesis characters. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3857 @code{nil} is returned if the line doesn't start with a one line block, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3858 which makes the function usable in list expressions. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3859 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3860 @workswith Almost all syntactic symbols, but most useful on the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3861 @code{-open} symbols. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3862 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3863 @findex c-indent-multi-line-block |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3864 @findex indent-multi-line-block (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3865 @item c-indent-multi-line-block |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3866 Indent a multi line block @code{c-basic-offset} extra. E.g: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3867 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3868 @group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3869 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3870 int *foo[] = @{ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3871 NULL, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3872 @{17@}, // c-indent-multi-line-block |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3873 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3874 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3875 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3876 @noindent |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3877 and |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3878 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3879 @group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3880 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3881 int *foo[] = @{ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3882 NULL, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3883 @{ // c-indent-multi-line-block |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3884 17 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3885 @}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3886 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3887 <--> c-basic-offset |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3888 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3889 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3890 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3891 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3892 The block may be surrounded by any kind of parenthesis characters. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3893 @code{nil} is returned if the line doesn't start with a multi line |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3894 block, which makes the function usable in list expressions. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3895 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3896 @workswith Almost all syntactic symbols, but most useful on the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3897 @code{-open} symbols. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3898 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3899 @findex c-lineup-C-comments |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3900 @findex lineup-C-comments (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3901 @item c-lineup-C-comments |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3902 Line up C block comment continuation lines. Various heuristics are used |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3903 to handle most of the common comment styles. Some examples: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3904 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3905 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3906 @group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3907 /* /** /* |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3908 * text * text text |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3909 */ */ */ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3910 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3911 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3912 @group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3913 /* text /* /** |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3914 text ** text ** text |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3915 */ */ */ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3916 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3917 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3918 @group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3919 /************************************************** |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3920 * text |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3921 *************************************************/ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3922 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3923 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3924 @vindex comment-start-skip |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3925 @group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3926 /************************************************** |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3927 Free form text comments: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3928 In comments with a long delimiter line at the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3929 start, the indentation is kept unchanged for lines |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3930 that start with an empty comment line prefix. The |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3931 delimiter line is whatever matches the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3932 @code{comment-start-skip} regexp. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3933 **************************************************/ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3934 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3935 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3936 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3937 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3938 The style variable @code{c-comment-prefix-regexp} is used to recognize |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3939 the comment line prefix, e.g. the @samp{*} that usually starts every |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3940 line inside a comment. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3941 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3942 @workswith The @code{c} syntactic symbol. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3943 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3944 @findex c-lineup-comment |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3945 @findex lineup-comment (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3946 @item c-lineup-comment |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3947 Line up a comment-only line according to the style variable |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3948 @code{c-comment-only-line-offset}. If the comment is lined up with a |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3949 comment starter on the previous line, that alignment is preserved. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3950 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3951 @vindex c-comment-only-line-offset |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3952 @vindex comment-only-line-offset (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3953 @code{c-comment-only-line-offset} specifies the extra offset for the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3954 line. It can contain an integer or a cons cell of the form |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3955 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3956 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3957 (@r{<non-anchored-offset>} . @r{<anchored-offset>}) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3958 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3959 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3960 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3961 @noindent |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3962 where @var{non-anchored-offset} is the amount of offset given to |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3963 non-column-zero anchored lines, and @var{anchored-offset} is the amount |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3964 of offset to give column-zero anchored lines. Just an integer as value |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3965 is equivalent to @code{(@r{<value>} . -1000)}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3966 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3967 @workswith @code{comment-intro}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3968 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3969 @findex c-lineup-runin-statements |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3970 @findex lineup-runin-statements (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3971 @item c-lineup-runin-statements |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3972 Line up statements for coding standards which place the first statement |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3973 in a block on the same line as the block opening brace@footnote{Run-in |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3974 style doesn't really work too well. You might need to write your own |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3975 custom indentation functions to better support this style.}. E.g: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3976 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3977 @group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3978 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3979 int main() |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3980 @{ puts (\"Hello world!\"); |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3981 return 0; // c-lineup-runin-statements |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3982 @} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3983 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3984 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3985 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3986 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3987 If there is no statement after the opening brace to align with, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3988 @code{nil} is returned. This makes the function usable in list |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3989 expressions. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3990 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3991 @workswith The @code{statement} syntactic symbol. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3992 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3993 @findex c-lineup-math |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3994 @findex lineup-math (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3995 @item c-lineup-math |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3996 Line up the current line after the equal sign on the first line in the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3997 statement. If there isn't any, indent with @code{c-basic-offset}. If |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3998 the current line contains an equal sign too, try to align it with the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3999 first one. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4000 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4001 @workswith @code{statement-cont}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4002 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4003 @findex c-lineup-template-args |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4004 @findex lineup-template-args (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4005 @item c-lineup-template-args |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4006 Line up the arguments of a template argument list under each other, but |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4007 only in the case where the first argument is on the same line as the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4008 opening @samp{<}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4009 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4010 To allow this function to be used in a list expression, @code{nil} is |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4011 returned if there's no template argument on the first line. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4012 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4013 @workswith @code{template-args-cont}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4014 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4015 @findex c-lineup-ObjC-method-call |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4016 @findex lineup-ObjC-method-call (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4017 @item c-lineup-ObjC-method-call |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4018 For Objective-C code, line up selector args as @code{elisp-mode} does |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4019 with function args: go to the position right after the message receiver, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4020 and if you are at the end of the line, indent the current line |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4021 c-basic-offset columns from the opening bracket; otherwise you are |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4022 looking at the first character of the first method call argument, so |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4023 lineup the current line with it. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4024 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4025 @workswith @code{objc-method-call-cont}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4026 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4027 @findex c-lineup-ObjC-method-args |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4028 @findex lineup-ObjC-method-args (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4029 @item c-lineup-ObjC-method-args |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4030 For Objective-C code, line up the colons that separate args. The colon |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4031 on the current line is aligned with the one on the first line. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4032 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4033 @workswith @code{objc-method-args-cont}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4034 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4035 @findex c-lineup-ObjC-method-args-2 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4036 @findex lineup-ObjC-method-args-2 (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4037 @item c-lineup-ObjC-method-args-2 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4038 Similar to @code{c-lineup-ObjC-method-args} but lines up the colon on |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4039 the current line with the colon on the previous line. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4040 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4041 @workswith @code{objc-method-args-cont}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4042 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4043 @findex c-lineup-inexpr-block |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4044 @findex lineup-inexpr-block (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4045 @item c-lineup-inexpr-block |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4046 This can be used with the in-expression block symbols to indent the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4047 whole block to the column where the construct is started. E.g. for Java |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4048 anonymous classes, this lines up the class under the @samp{new} keyword, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4049 and in Pike it lines up the lambda function body under the @samp{lambda} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4050 keyword. Returns @code{nil} if the block isn't part of such a |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4051 construct. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4052 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4053 @workswith @code{inlambda}, @code{inexpr-statement}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4054 @code{inexpr-class}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4055 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4056 @findex c-lineup-whitesmith-in-block |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4057 @findex lineup-whitesmith-in-block (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4058 @item c-lineup-whitesmith-in-block |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4059 Line up lines inside a block in Whitesmith style. It's done in a way |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4060 that works both when the opening brace hangs and when it doesn't. E.g: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4061 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4062 @group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4063 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4064 something |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4065 @{ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4066 foo; // c-lineup-whitesmith-in-block |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4067 @} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4068 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4069 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4070 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4071 @noindent |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4072 and |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4073 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4074 @group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4075 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4076 something @{ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4077 foo; // c-lineup-whitesmith-in-block |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4078 @} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4079 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4080 <--> c-basic-offset |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4081 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4082 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4083 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4084 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4085 In the first case the indentation is kept unchanged, in the second |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4086 @code{c-basic-offset} is added. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4087 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4088 @workswith @code{defun-close}, @code{defun-block-intro}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4089 @code{block-close}, @code{brace-list-close}, @code{brace-list-intro}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4090 @code{statement-block-intro}, @code{inclass}, @code{inextern-lang}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4091 @code{innamespace}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4092 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4093 @findex c-lineup-dont-change |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4094 @findex lineup-dont-change (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4095 @item c-lineup-dont-change |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4096 This lineup function returns the indentation of the current line. Think |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4097 of it as an identity function for lineups; it is used for |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4098 @code{cpp-macro-cont} lines. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4099 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4100 @workswith Any syntactic symbol. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4101 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4102 @end table |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4103 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4104 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4105 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4106 @node Performance Issues, Frequently Asked Questions, Indentation Functions, Top |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4107 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4108 @chapter Performance Issues |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4109 @cindex performance issues |
25829 | 4110 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
4111 | |
4112 C and its derivative languages are highly complex creatures. Often, | |
4113 ambiguous code situations arise that require @ccmode{} to scan | |
4114 large portions of the buffer to determine syntactic context. Such | |
4115 pathological code@footnote{such as the output of @code{lex(1)}!} | |
4116 can cause @ccmode{} to perform fairly badly. | |
4117 This section identifies some of the coding styles to watch out for, and | |
4118 suggests some workarounds that you can use to improve performance. | |
4119 | |
4120 Because @ccmode{} has to scan the buffer backwards from the current | |
4121 insertion point, and because C's syntax is fairly difficult to parse in | |
4122 the backwards direction, @ccmode{} often tries to find the nearest | |
4123 position higher up in the buffer from which to begin a forward scan. | |
4124 The farther this position is from the current insertion point, the | |
4125 slower the mode gets. Some coding styles can even force @ccmode{} | |
4126 to scan from the beginning of the buffer for every line of code! | |
4127 | |
4128 @findex beginning-of-defun | |
4129 @findex defun-prompt-regexp | |
4130 One of the simplest things you can do to reduce scan time, is make sure | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4131 any brace that opens a top-level construct@footnote{E.g. a function in |
25829 | 4132 C, or outermost class definition in C++ or Java.} always appears in the |
4133 leftmost column. This is actually an Emacs constraint, as embodied in | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4134 the @code{beginning-of-defun} function which @ccmode{} uses heavily. If |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4135 you insist on hanging top-level open braces on the right side of the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4136 line, then you might want to set the variable @code{defun-prompt-regexp} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4137 to something reasonable, however that ``something reasonable'' is |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4138 difficult to define, so @ccmode{} doesn't do it for you. |
25829 | 4139 |
4140 @vindex c-Java-defun-prompt-regexp | |
4141 @vindex Java-defun-prompt-regexp (c-) | |
4142 A special note about @code{defun-prompt-regexp} in Java mode: while much | |
4143 of the early sample Java code seems to encourage a style where the brace | |
4144 that opens a class is hung on the right side of the line, this is not a | |
4145 good style to pursue in Emacs. @ccmode{} comes with a variable | |
4146 @code{c-Java-defun-prompt-regexp} which tries to define a regular | |
4147 expression usable for this style, but there are problems with it. In | |
4148 some cases it can cause @code{beginning-of-defun} to hang@footnote{This | |
4149 has been observed in Emacs 19.34 and XEmacs 19.15.}. For this reason, | |
4150 it is not used by default, but if you feel adventurous, you can set | |
4151 @code{defun-prompt-regexp} to it in your mode hook. In any event, | |
4152 setting and rely on @code{defun-prompt-regexp} will definitely slow | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4153 things down anyway because you'll be doing regular expression searches |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4154 for every line you indent, so you're probably screwed either way! |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4155 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4156 @vindex c-enable-xemacs-performance-kludge-p |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4157 @vindex enable-xemacs-performance-kludge-p (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4158 Another alternative for XEmacs users, is to set the variable |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4159 @code{c-enable-xemacs-performance-kludge-p} to non-@code{nil}. This |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4160 tells @ccmode{} to use XEmacs-specific built-in functions which, in some |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4161 circumstances, can locate the top-most opening brace much quicker than |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4162 @code{beginning-of-defun}. Preliminary testing has shown that for |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4163 styles where these braces are hung (e.g. most JDK-derived Java styles), |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4164 this hack can improve performance of the core syntax parsing routines |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4165 from 3 to 60 times. However, for styles which @emph{do} conform to |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4166 Emacs' recommended style of putting top-level braces in column zero, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4167 this hack can degrade performance by about as much. Thus this variable |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4168 is set to @code{nil} by default, since the Emacs-friendly styles |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4169 should be more common (and |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4170 encouraged!). Note that this variable has no effect in Emacs since the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4171 necessary built-in functions don't exist (in Emacs 20.2 or 20.3 as of |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4172 this writing 27-Apr-1998). |
25829 | 4173 |
4174 You will probably notice pathological behavior from @ccmode{} when | |
4175 working in files containing large amounts of C preprocessor macros. | |
4176 This is because Emacs cannot skip backwards over these lines as quickly | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4177 as it can comments. |
25829 | 4178 |
4179 @vindex c-recognize-knr-p | |
4180 @vindex recognize-knr-p (c-) | |
4181 Previous versions of @ccmode{} had potential performance problems | |
4182 when recognizing K&R style function argument declarations. This was | |
4183 because there are ambiguities in the C syntax when K&R style argument | |
4184 lists are used@footnote{It is hard to distinguish them from top-level | |
4185 declarations.}. @ccmode{} has adopted BOCM's convention for | |
4186 limiting the search: it assumes that argdecls are indented at least one | |
4187 space, and that the function headers are not indented at all. With | |
4188 current versions of @ccmode{}, user customization of | |
4189 @code{c-recognize-knr-p} is deprecated. Just don't put argdecls in | |
4190 column zero! | |
4191 | |
4192 @cindex @file{cc-lobotomy.el} file | |
4193 @vindex cc-lobotomy-pith-list | |
4194 You might want to investigate the speed-ups contained in the | |
4195 file @file{cc-lobotomy.el}, which comes as part of the @ccmode{} | |
4196 distribution, but is completely unsupported. | |
4197 As mentioned previous, @ccmode{} always trades speed for accuracy, | |
4198 however it is recognized that sometimes you need speed and can sacrifice | |
4199 some accuracy in indentation. The file @file{cc-lobotomy.el} contains | |
4200 hacks that will ``dumb down'' @ccmode{} in some specific ways, making | |
4201 that trade-off of accurancy for speed. I won't go into details of its | |
4202 use here; you should read the comments at the top of the file, and look | |
4203 at the variable @code{cc-lobotomy-pith-list} for details. | |
4204 | |
4205 | |
4206 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4207 @node Frequently Asked Questions, Getting the Latest CC Mode Release, Performance Issues, Top |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4208 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4209 @chapter Frequently Asked Questions |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4210 @cindex frequently asked questions |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4211 @cindex FAQ |
25829 | 4212 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
4213 | |
4214 @kindex C-x h | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4215 @kindex C-M-\ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4216 @kindex C-M-x |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4217 @kindex C-M-q |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4218 @kindex C-M-u |
25829 | 4219 @kindex RET |
4220 @kindex C-j | |
4221 @quotation | |
4222 | |
4223 @strong{Q.} @emph{How do I re-indent the whole file?} | |
4224 | |
4225 @strong{A.} Visit the file and hit @kbd{C-x h} to mark the whole | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4226 buffer. Then hit @kbd{C-M-\}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4227 |
25829 | 4228 @sp 1 |
4229 @strong{Q.} @emph{How do I re-indent the entire function? | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4230 @kbd{C-M-x} doesn't work.} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4231 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4232 @strong{A.} @kbd{C-M-x} is reserved for future Emacs use. |
25829 | 4233 To re-indent the entire function hit @kbd{C-c C-q}. |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4234 |
25829 | 4235 @sp 1 |
4236 @strong{Q.} @emph{How do I re-indent the current block?} | |
4237 | |
4238 @strong{A.} First move to the brace which opens the block with | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4239 @kbd{C-M-u}, then re-indent that expression with |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4240 @kbd{C-M-q}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4241 |
25829 | 4242 @sp 1 |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4243 @strong{Q.} @emph{Why doesn't the @kbd{RET} key indent the new line?} |
25829 | 4244 |
4245 @strong{A.} Emacs' convention is that @kbd{RET} just adds a newline, | |
4246 and that @kbd{C-j} adds a newline and indents it. You can make | |
4247 @kbd{RET} do this too by adding this to your | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4248 @code{c-mode-common-hook}: |
25829 | 4249 @example |
4250 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4251 (define-key c-mode-base-map "\C-m" 'c-context-line-break) |
25829 | 4252 |
4253 @end example | |
4254 | |
4255 This is a very common question. If you want this to be the default | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4256 behavior, don't lobby me, lobby RMS! @t{:-)} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4257 |
25829 | 4258 @sp 1 |
4259 @strong{Q.} @emph{I put @code{(c-set-offset 'substatement-open 0)} | |
4260 in my @file{.emacs} file but I get an error saying that | |
4261 @code{c-set-offset}'s function definition is void.} | |
4262 | |
4263 @strong{A.} This means that @ccmode{} wasn't loaded into your | |
4264 Emacs session by the time the @code{c-set-offset} call was reached, | |
4265 mostly likely because @ccmode{} is being autoloaded. Instead | |
4266 of putting the @code{c-set-offset} line in your top-level | |
4267 @file{.emacs} file, put it in your @code{c-mode-common-hook}, or | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4268 simply modify @code{c-offsets-alist} directly: |
25829 | 4269 @example |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4270 @group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4271 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4272 (setq c-offsets-alist (cons '(substatement-open . 0) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4273 c-offsets-alist)) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4274 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4275 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4276 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4277 @sp 1 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4278 @strong{Q.} @emph{My style settings works in all the @ccmode{} language |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4279 modes except for Java, where I still get e.g. 4 column indentation.} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4280 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4281 @strong{A.} Java mode switches to the @samp{java} style by default for |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4282 historical reasons. You can override it by putting an association list |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4283 on @code{c-default-style}: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4284 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4285 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4286 (setq c-default-style '((other . "my-style"))) |
25829 | 4287 |
4288 @end example | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4289 @noindent |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4290 The @samp{other} symbol says that @ccmode{} should use "my-style" in all |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4291 modes not explicitly listed. Since there's nothing else on the list |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4292 this causes "my-style" to be used in every mode. |
25829 | 4293 |
4294 @sp 1 | |
4295 @strong{Q.} @emph{How do I make strings, comments, keywords, and other | |
4296 constructs appear in different colors, or in bold face, etc.?} | |
4297 | |
4298 @strong{A.} ``Syntax Colorization'' is a standard Emacs feature, | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4299 controlled by @code{font-lock-mode}. @ccmode{} does not contain |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4300 font-lock definitions for any of its supported languages. |
25829 | 4301 |
4302 @sp 1 | |
4303 @strong{Q.} @emph{@kbd{M-a} and @kbd{M-e} used to move over entire | |
4304 balanced brace lists, but now they move into blocks. How do I get the | |
4305 old behavior back?} | |
4306 | |
4307 @strong{A.} Use @kbd{C-M-f} and @kbd{C-M-b} to move over balanced brace | |
4308 blocks. Use @kbd{M-a} and @kbd{M-e} to move by statements, which will | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4309 also move into blocks. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4310 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4311 @sp 1 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4312 @strong{Q.} @emph{Whenever I try to indent a line or type an |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4313 ``electric'' key such as @kbd{;}, @kbd{@{}, or @kbd{@}}, I get an error |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4314 that look like this: @code{Invalid function: (macro . #[...}. What |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4315 gives?} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4316 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4317 @strong{A.} This is a common error when @ccmode{} hasn't been compiled |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4318 correctly, especially under Emacs 19.34@footnote{Technically, it's |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4319 because some macros wasn't defined during the compilation, so the byte |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4320 compiler put in function calls instead of the macro expansions. Later, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4321 when the interpreter tries to call the macros as functions, it shows |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4322 this (somewhat cryptic) error message.}. If you are using the standalone |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4323 @ccmode{} distribution, try recompiling it according to the instructions |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4324 in the @file{README} file. |
25829 | 4325 |
4326 @end quotation | |
4327 | |
4328 | |
4329 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4330 @node Getting the Latest CC Mode Release, Sample .emacs File, Frequently Asked Questions, Top |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4331 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4332 @chapter Getting the Latest CC Mode Release |
25829 | 4333 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
4334 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4335 @ccmode{} is standard with all versions of Emacs since 19.34 and of |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4336 XEmacs since 19.16. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4337 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4338 Due to release schedule skew, it is likely that all of these Emacsen |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4339 have old versions of @ccmode{} and so should be upgraded. Access to the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4340 @ccmode{} source code, as well as more detailed information on Emacsen |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4341 compatibility, etc. are all available via the Web at: |
25829 | 4342 |
4343 @example | |
4344 @group | |
4345 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4346 @uref{http://www.python.org/emacs/cc-mode/} |
25829 | 4347 |
4348 @end group | |
4349 @end example | |
4350 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4351 @emph{Old URLs, including the FTP URLs, should no longer be used.} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4352 |
25829 | 4353 There are many files under these directories; you can pick up the entire |
4354 distribution (named @code{cc-mode.tar.gz}; a gzip'd tar file), or any of | |
4355 the individual files, including PostScript documentation. | |
4356 | |
4357 | |
4358 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4359 @node Sample .emacs File, Limitations and Known Bugs, Getting the Latest CC Mode Release, Top |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4360 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4361 @chapter Sample .emacs file |
25829 | 4362 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
4363 | |
4364 @example | |
4365 ;; Here's a sample .emacs file that might help you along the way. Just | |
4366 ;; copy this region and paste it into your .emacs file. You may want to | |
4367 ;; change some of the actual values. | |
4368 | |
4369 (defconst my-c-style | |
4370 '((c-tab-always-indent . t) | |
4371 (c-comment-only-line-offset . 4) | |
4372 (c-hanging-braces-alist . ((substatement-open after) | |
4373 (brace-list-open))) | |
4374 (c-hanging-colons-alist . ((member-init-intro before) | |
4375 (inher-intro) | |
4376 (case-label after) | |
4377 (label after) | |
4378 (access-label after))) | |
4379 (c-cleanup-list . (scope-operator | |
4380 empty-defun-braces | |
4381 defun-close-semi)) | |
4382 (c-offsets-alist . ((arglist-close . c-lineup-arglist) | |
4383 (substatement-open . 0) | |
4384 (case-label . 4) | |
4385 (block-open . 0) | |
4386 (knr-argdecl-intro . -))) | |
4387 (c-echo-syntactic-information-p . t) | |
4388 ) | |
4389 "My C Programming Style") | |
4390 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4391 ;; offset customizations not in my-c-style |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4392 (setq c-offsets-alist (cons '(member-init-intro . ++) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4393 c-offsets-alist)) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4394 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4395 ;; Customizations for all modes in CC Mode. |
25829 | 4396 (defun my-c-mode-common-hook () |
4397 ;; add my personal style and set it for the current buffer | |
4398 (c-add-style "PERSONAL" my-c-style t) | |
4399 ;; other customizations | |
4400 (setq tab-width 8 | |
4401 ;; this will make sure spaces are used instead of tabs | |
4402 indent-tabs-mode nil) | |
4403 ;; we like auto-newline and hungry-delete | |
4404 (c-toggle-auto-hungry-state 1) | |
4405 ;; keybindings for all supported languages. We can put these in | |
4406 ;; c-mode-base-map because c-mode-map, c++-mode-map, objc-mode-map, | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4407 ;; java-mode-map, idl-mode-map, and pike-mode-map inherit from it. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4408 (define-key c-mode-base-map "\C-m" 'c-context-line-break) |
25829 | 4409 ) |
4410 | |
4411 (add-hook 'c-mode-common-hook 'my-c-mode-common-hook) | |
4412 @end example | |
4413 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4414 |
25829 | 4415 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4416 @node Limitations and Known Bugs, Mailing Lists and Submitting Bug Reports, Sample .emacs File, Top |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4417 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4418 @chapter Limitations and Known Bugs |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4419 @cindex limitations |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4420 @cindex bugs |
25829 | 4421 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
4422 | |
4423 @itemize @bullet | |
4424 @item | |
4425 Re-indenting large regions or expressions can be slow. | |
4426 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4427 @findex c-indent-exp |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4428 @findex indent-exp (c-) |
25829 | 4429 @item |
4430 @code{c-indent-exp} has not been fully optimized. It essentially | |
4431 equivalent to hitting @kbd{TAB} (@code{c-indent-command}) on every | |
4432 line. Some information is cached from line to line, but such caching | |
4433 invariable causes inaccuracies in analysis in some bizarre situations. | |
4434 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4435 @vindex signal-error-on-buffer-boundary |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4436 @item |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4437 XEmacs versions from 19.15 until (as of this writing 12-Mar-1998) 20.4 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4438 contain a variable called @code{signal-error-on-buffer-boundary}. This |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4439 was intended as a solution to user interface problems associated with |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4440 buffer movement and the @code{zmacs-region} deactivation on errors. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4441 However, setting this variable to a non-default value had the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4442 deleterious side effect of breaking many built-in primitive functions. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4443 Most users will not be affected since they never change the value of |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4444 this variable. @strong{Do not set this variable to @code{nil}}; you |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4445 will cause serious problems in @ccmode{} and probably other XEmacs |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4446 packages! As of at least XEmacs 20.4, the effects this variable tried |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4447 to correct have been fixed in other, better ways. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4448 |
25829 | 4449 @end itemize |
4450 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4451 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4452 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4453 @node Mailing Lists and Submitting Bug Reports, Concept Index, Limitations and Known Bugs, Top |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4454 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4455 @chapter Mailing Lists and Submitting Bug Reports |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4456 @cindex mailing lists |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4457 @cindex reporting bugs |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4458 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
25829 | 4459 |
4460 @kindex C-c C-b | |
4461 @findex c-submit-bug-report | |
4462 @findex submit-bug-report (c-) | |
4463 To report bugs, use the @kbd{C-c C-b} (@code{c-submit-bug-report}) | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4464 command. This provides vital information we need to reproduce your |
25829 | 4465 problem. Make sure you include a concise, but complete code example. |
4466 Please try to boil your example down to just the essential code needed | |
4467 to reproduce the problem, and include an exact recipe of steps needed to | |
4468 expose the bug. Be especially sure to include any code that appears | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4469 @emph{before} your bug example, if you think it might affect our ability |
25829 | 4470 to reproduce it. |
4471 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4472 Please try to produce the problem in an Emacs instance without any |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4473 customizations loaded (i.e. start it with the @code{-q -no-site-file} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4474 arguments). If it works correctly there, the problem might be caused by |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4475 faulty customizations in either your own or your site configuration. In |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4476 that case, we'd appreciate if you isolate the Emacs Lisp code that trigs |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4477 the bug and include it in your report. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4478 |
25829 | 4479 Bug reports are now sent to the following email addresses: |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4480 @email{bug-cc-mode@@gnu.org} and @email{bug-gnu-emacs@@gnu.org}; the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4481 latter is mirrored on the Usenet newsgroup @code{gnu.emacs.bug}. You |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4482 can send other questions and suggestions (kudos? @t{;-)} to |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4483 @email{bug-cc-mode@@gnu.org}, or @email{help-gnu-emacs@@gnu.org} which is |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4484 mirrored on newsgroup @code{gnu.emacs.help}. The old contact address |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4485 @email{cc-mode-help@@python.org} is still active, but its use is |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4486 discouraged. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4487 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4488 @cindex beta testers mailing list |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4489 @cindex announcement mailing list |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4490 If you want to get announcements of new @ccmode{} releases, send the word |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4491 @emph{subscribe} in the body of a message to |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4492 @email{cc-mode-announce-request@@python.org}. Announcements will also |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4493 be posted to the Usenet newsgroups @code{gnu.emacs.sources}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4494 @code{comp.emacs}, @code{comp.emacs.xemacs}, and possibly some of the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4495 language oriented newsgroups. Note that the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4496 @code{cc-mode-victims@@python.org} mailing list has been |
25829 | 4497 decommissioned. |
4498 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4499 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4500 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4501 @node Concept Index, Command Index, Mailing Lists and Submitting Bug Reports, Top |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4502 @comment node-name, next, previous, up |
25829 | 4503 @unnumbered Concept Index |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4504 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
25829 | 4505 |
4506 @printindex cp | |
4507 | |
4508 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4509 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4510 @node Command Index, Key Index, Concept Index, Top |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4511 @comment node-name, next, previous, up |
25829 | 4512 @unnumbered Command Index |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4513 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4514 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4515 Since most @ccmode{} commands are prepended with the string |
25829 | 4516 @samp{c-}, each appears under its @code{c-@var{<thing>}} name and its |
4517 @code{@var{<thing>} (c-)} name. | |
4518 @iftex | |
4519 @sp 2 | |
4520 @end iftex | |
4521 @printindex fn | |
4522 | |
4523 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4524 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4525 @node Key Index, Variable Index, Command Index, Top |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4526 @comment node-name, next, previous, up |
25829 | 4527 @unnumbered Key Index |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4528 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
25829 | 4529 |
4530 @printindex ky | |
4531 | |
4532 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4533 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4534 @node Variable Index, , Key Index, Top |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4535 @comment node-name, next, previous, up |
25829 | 4536 @unnumbered Variable Index |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4537 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4538 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4539 Since most @ccmode{} variables are prepended with the string |
25829 | 4540 @samp{c-}, each appears under its @code{c-@var{<thing>}} name and its |
4541 @code{@var{<thing>} (c-)} name. | |
4542 @iftex | |
4543 @sp 2 | |
4544 @end iftex | |
4545 @printindex vr | |
4546 @page | |
4547 @summarycontents | |
4548 @contents | |
4549 @bye |