Mercurial > emacs
annotate man/cc-mode.texi @ 36141:02c61ff8a12b
(uniquify-buffer-name-style): Doc fix.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 17 Feb 2001 13:32:45 +0000 |
parents | 050e2c097faf |
children | 2f0f137c2d1a |
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 | |
30396
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
26 @comment Maintained by Martin Stjernholm <bug-cc-mode@gnu.org> |
25829 | 27 @comment |
28 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
29 | |
30396
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
30 @comment Info directory entry for use by install-info |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
31 @dircategory Emacs |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
32 @direntry |
34239 | 33 * CC Mode: (ccmode). Emacs mode for editing C, C++, Objective-C, |
34 Java, Pike, and IDL code. | |
30396
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
35 @end direntry |
25829 | 36 |
37 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
38 @comment The following line inserts the copyright notice | |
39 @comment into the Info file. | |
40 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
41 | |
34239 | 42 @ifnottex |
34248 | 43 Copyright @copyright{} 1995, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. |
34239 | 44 |
45 Permission is granted to copy, distribute and/or modify this document | |
46 under the terms of the GNU Free Documentation License, Version 1.1 or | |
47 any later version published by the Free Software Foundation; with the | |
48 Invariant Sections being ``The GNU Manifesto'', ``Distribution'' and | |
49 ``GNU GENERAL PUBLIC LICENSE'', with the Front-Cover texts being ``A GNU | |
50 Manual'', and with the Back-Cover Texts as in (a) below. A copy of the | |
51 license is included in the section entitled ``GNU Free Documentation | |
52 License'' in the Emacs manual. | |
53 | |
54 (a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify | |
55 this GNU Manual, like GNU software. Copies published by the Free | |
56 Software Foundation raise funds for GNU development.'' | |
57 | |
58 This document is part of a collection distributed under the GNU Free | |
59 Documentation License. If you want to distribute this document | |
60 separately from the collection, you can do so by adding a copy of the | |
61 license to the document, as described in section 6 of the license. | |
62 @end ifnottex | |
25829 | 63 |
64 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
65 @comment !!!The titlepage section does not appear in the Info file.!!! | |
66 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
67 | |
68 @titlepage | |
69 @sp 10 | |
70 | |
71 | |
72 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
73 @comment The title is printed in a large font. | |
74 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
75 | |
30396
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
76 @center @titlefont{CC Mode 5.27} |
25829 | 77 @sp 2 |
78 @center @subtitlefont{A GNU Emacs mode for editing C and C-like languages} | |
79 @sp 2 | |
30396
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
80 @center Current maintainer: |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
81 @center Martin Stjernholm |
25829 | 82 |
83 | |
84 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
85 @comment The following two commands start the copyright page | |
86 @comment for the printed manual. This will not appear in the Info file. | |
87 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
88 | |
89 @page | |
90 @vskip 0pt plus 1filll | |
34248 | 91 Copyright @copyright{} 1995, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. |
34239 | 92 @sp 1 |
93 Permission is granted to copy, distribute and/or modify this document | |
94 under the terms of the GNU Free Documentation License, Version 1.1 or | |
95 any later version published by the Free Software Foundation; with the | |
96 Invariant Sections being ``The GNU Manifesto'', ``Distribution'' and | |
97 ``GNU GENERAL PUBLIC LICENSE'', with the Front-Cover texts being ``A GNU | |
98 Manual'', and with the Back-Cover Texts as in (a) below. A copy of the | |
99 license is included in the section entitled ``GNU Free Documentation | |
100 License'' in the Emacs manual. | |
101 | |
102 (a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify | |
103 this GNU Manual, like GNU software. Copies published by the Free | |
104 Software Foundation raise funds for GNU development.'' | |
105 | |
106 This document is part of a collection distributed under the GNU Free | |
107 Documentation License. If you want to distribute this document | |
108 separately from the collection, you can do so by adding a copy of the | |
109 license to the document, as described in section 6 of the license. | |
25829 | 110 @end titlepage |
111 | |
112 | |
113 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
114 @comment The Top node contains the master menu for the Info file. | |
115 @comment This appears only in the Info file, not the printed manual. | |
116 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
117 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
118 @node Top, Introduction, (dir), (dir) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
119 @comment node-name, next, previous, up |
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 @macro ccmode |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
122 CC Mode |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
123 @end macro |
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 @ifinfo |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
126 @top @ccmode{} |
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 @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
|
129 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
|
130 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
|
131 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
|
132 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
|
133 @end ifinfo |
25829 | 134 |
135 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
136 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
137 | |
138 @menu | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
139 * Introduction:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
140 * Getting Connected:: |
25829 | 141 * New Indentation Engine:: |
142 * Minor Modes:: | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
143 * Text Filling and Line Breaking:: |
25829 | 144 * Commands:: |
145 * Customizing Indentation:: | |
146 * Syntactic Symbols:: | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
147 * Indentation Functions:: |
25829 | 148 * Performance Issues:: |
149 * Frequently Asked Questions:: | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
150 * Getting the Latest CC Mode Release:: |
25829 | 151 * Sample .emacs File:: |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
152 * Limitations and Known Bugs:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
153 * Mailing Lists and Submitting Bug Reports:: |
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 --- Indices --- |
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 * Concept Index:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
158 * Command Index:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
159 * Key Index:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
160 * Variable Index:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
161 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
162 --- The Detailed Node Listing --- |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
163 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
164 New Indentation Engine |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
165 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
166 * Syntactic Analysis:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
167 * Indentation Calculation:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
168 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
169 Minor Modes |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
170 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
171 * Auto-newline Insertion:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
172 * Hungry-deletion of Whitespace:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
173 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
174 Auto-newline Insertion |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
175 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
176 * Hanging Braces:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
177 * Hanging Colons:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
178 * Hanging Semi-colons and Commas:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
179 * Other Electric Commands:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
180 * Clean-ups:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
181 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
182 Commands |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
183 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
184 * Indentation Commands:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
185 * Movement Commands:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
186 * Other Commands:: |
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 Customizing Indentation |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
189 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
190 * Interactive Customization:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
191 * Permanent Customization:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
192 * Hooks:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
193 * Styles:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
194 * Advanced Customizations:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
195 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
196 Styles |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
197 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
198 * Built-in Styles:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
199 * Adding Styles:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
200 * File Styles:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
201 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
202 Advanced Customizations |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
203 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
204 * Custom Indentation Functions:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
205 * Custom Brace and Colon Hanging:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
206 * Customizing Semi-colons and Commas:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
207 * Other Special Indentations:: |
25829 | 208 @end menu |
209 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
210 |
25829 | 211 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
212 @node Introduction, Getting Connected, Top, Top |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
213 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
214 @chapter Introduction |
25829 | 215 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
216 | |
217 @cindex BOCM | |
218 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
219 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
|
220 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
|
221 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
|
222 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
|
223 been maintaining since 1992. @ccmode{} represents a significant |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
224 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
|
225 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
|
226 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
|
227 joined the @ccmode{} Maintainers Team, and implemented the Pike support. |
30396
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
228 As of 2000 Martin has taken over as the sole maintainer. |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
229 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
230 This manual describes @ccmode{} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
231 @comment The following line must appear on its own, so that the automated |
30396
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
232 version 5.27. |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
233 @comment Release.py script can update the version number automatically |
25829 | 234 |
235 @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
|
236 @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
|
237 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
|
238 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
|
239 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
|
240 @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
|
241 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
|
242 @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
|
243 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
|
244 modes. Font-locking is handled by other Emacs packages. |
25829 | 245 |
246 This manual will describe the following: | |
247 | |
248 @itemize @bullet | |
249 @item | |
250 How to get started using @ccmode{}. | |
251 | |
252 @item | |
253 How the new indentation engine works. | |
254 | |
255 @item | |
256 How to customize the new indentation engine. | |
257 | |
258 @end itemize | |
259 | |
260 @findex c-mode | |
261 @findex c++-mode | |
262 @findex objc-mode | |
263 @findex java-mode | |
264 @findex idl-mode | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
265 @findex pike-mode |
25829 | 266 Note that the name of this package is ``@ccmode{}'', but there is no top |
267 level @code{cc-mode} entry point. All of the variables, commands, and | |
268 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
|
269 @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
|
270 @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
|
271 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
|
272 @file{c++-mode.el}. |
25829 | 273 |
274 @cindex @file{cc-compat.el} file | |
275 This distribution also contains a file | |
276 called @file{cc-compat.el} which should ease your transition from BOCM | |
277 to @ccmode{}. If you have a BOCM configuration you are really happy | |
278 with, and want to postpone learning how to configure @ccmode{}, take a | |
279 look at that file. It maps BOCM configuration variables to @ccmode{}'s | |
280 new indentation model. It is not actively supported so for the long | |
281 run, you should learn how to customize @ccmode{} to support your coding | |
282 style. | |
283 | |
284 A special word of thanks goes to Krishna Padmasola for his work in | |
285 converting the original @file{README} file to Texinfo format. I'd also | |
286 like to thank all the @ccmode{} victims who help enormously during the | |
287 early beta stages of @ccmode{}'s development. | |
288 | |
289 | |
290 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
291 @node Getting Connected, New Indentation Engine, Introduction, Top |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
292 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
293 @chapter Getting Connected |
25829 | 294 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
295 | |
296 If you got this version of @ccmode{} with Emacs or XEmacs, it should | |
297 work just fine right out of the box. Note however that you may not have | |
298 the latest @ccmode{} release and may want to upgrade your copy. | |
299 | |
300 If you are upgrading an existing @ccmode{} installation, please see the | |
301 @file{README} file for installation details. @ccmode{} may not work | |
302 with older versions of Emacs or XEmacs. See the @ccmode{} release notes | |
303 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
|
304 compatibility (@pxref{Getting the Latest CC Mode Release}). |
25829 | 305 |
306 @cindex @file{cc-mode-18.el} file | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
307 @emph{Note that @ccmode{} no longer |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
308 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
|
309 you are out of luck. |
25829 | 310 |
311 @findex c-version | |
312 @findex version (c-) | |
313 You can find out what version of @ccmode{} you are using by visiting a C | |
314 file and entering @kbd{M-x c-version RET}. You should see this message in | |
315 the echo area: | |
316 @example | |
317 | |
318 Using CC Mode version 5.XX | |
319 | |
320 @end example | |
321 | |
322 @noindent | |
323 where @samp{XX} is the minor release number. | |
324 | |
325 | |
326 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
327 @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
|
328 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
329 @chapter New Indentation Engine |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
330 @cindex indentation engine |
25829 | 331 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
332 | |
333 @ccmode{} has a new indentation engine, providing a simplified, yet | |
334 flexible and general mechanism for customizing indentation. It separates | |
335 indentation calculation into two steps: first, @ccmode{} analyzes the | |
336 line of code being indented to determine the kind of language construct | |
337 it's looking at, then it applies user defined offsets to the current | |
338 line based on this analysis. | |
339 | |
340 This section will briefly cover how indentation is calculated in | |
341 @ccmode{}. It is important to understand the indentation model | |
342 being used so that you will know how to customize @ccmode{} for | |
343 your personal coding style. | |
344 | |
345 @menu | |
346 * Syntactic Analysis:: | |
347 * Indentation Calculation:: | |
348 @end menu | |
349 | |
350 | |
351 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
352 @node Syntactic Analysis, Indentation Calculation, , New Indentation Engine |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
353 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
354 @section Syntactic Analysis |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
355 @cindex syntactic analysis |
25829 | 356 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
357 | |
358 @cindex relative buffer position | |
359 @cindex syntactic symbol | |
360 @cindex syntactic component | |
361 @cindex syntactic component list | |
362 The first thing @ccmode{} does when indenting a line of code, is to | |
363 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
|
364 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
|
365 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
|
366 is a @dfn{syntactic symbol}, and the second part is a @dfn{relative |
25829 | 367 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
|
368 @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
|
369 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
|
370 @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
|
371 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
|
372 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
|
373 list of currently supported syntactic symbols. |
25829 | 374 |
375 Conceptually, a line of C code is always indented relative to the | |
376 indentation of some line higher up in the buffer. This is represented | |
377 by the relative buffer position in the syntactic component. | |
378 | |
379 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
|
380 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
|
381 don't actually appear in the buffer, of course!}: |
25829 | 382 @example |
383 @group | |
384 | |
385 1: void swap( int& a, int& b ) | |
386 2: @{ | |
387 3: int tmp = a; | |
388 4: a = b; | |
389 5: b = tmp; | |
390 6: @} | |
391 | |
392 @end group | |
393 @end example | |
394 | |
395 @kindex C-c C-s | |
396 @findex c-show-syntactic-information | |
397 @findex show-syntactic-information (c-) | |
398 We can use the command @kbd{C-c C-s} | |
399 (@code{c-show-syntactic-information}) to simply report what the | |
400 syntactic analysis is for the current line. Running this command on | |
401 line 4 of this example, we'd see in the echo area@footnote{With a universal | |
402 argument (i.e. @kbd{C-u C-c C-s}) the analysis is inserted into the | |
403 buffer as a comment | |
404 on the current line.}: | |
405 @example | |
406 | |
407 ((statement . 35)) | |
408 | |
409 @end example | |
410 | |
411 This tells us that the line is a statement and it is indented relative | |
412 to buffer position 35, which happens to be the @samp{i} in @code{int} on | |
413 line 3. If you were to move point to line 3 and hit @kbd{C-c C-s}, you | |
414 would see: | |
415 @example | |
416 | |
417 ((defun-block-intro . 29)) | |
418 | |
419 @end example | |
420 | |
421 This indicates that the @samp{int} line is the first statement in a top | |
422 level function block, and is indented relative to buffer position 29, | |
423 which is the brace just after the function header. | |
424 | |
425 Here's another example: | |
426 @example | |
427 @group | |
428 | |
429 1: int add( int val, int incr, int doit ) | |
430 2: @{ | |
431 3: if( doit ) | |
432 4: @{ | |
433 5: return( val + incr ); | |
434 6: @} | |
435 7: return( val ); | |
436 8: @} | |
437 | |
438 @end group | |
439 @end example | |
440 | |
441 @noindent | |
442 Hitting @kbd{C-c C-s} on line 4 gives us: | |
443 @example | |
444 | |
445 ((substatement-open . 46)) | |
446 | |
447 @end example | |
448 | |
449 @cindex substatement | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
450 @cindex substatement block |
25829 | 451 @noindent |
452 which tells us that this is a brace that @emph{opens} a substatement | |
453 block. @footnote{A @dfn{substatement} is the line after a | |
454 conditional statement, such as @code{if}, @code{else}, @code{while}, | |
455 @code{do}, @code{switch}, etc. A @dfn{substatement | |
456 block} is a brace block following one of these conditional statements.} | |
457 | |
458 @cindex comment-only line | |
459 Syntactic component lists can contain more than one component, and | |
460 individual syntactic components need not have relative buffer positions. | |
461 The most common example of this is a line that contains a @dfn{comment | |
462 only line}. | |
463 @example | |
464 @group | |
465 | |
466 1: void draw_list( List<Drawables>& drawables ) | |
467 2: @{ | |
468 3: // call the virtual draw() method on each element in list | |
469 4: for( int i=0; i < drawables.count(), ++i ) | |
470 5: @{ | |
471 6: drawables[i].draw(); | |
472 7: @} | |
473 8: @} | |
474 | |
475 @end group | |
476 @end example | |
477 | |
478 @noindent | |
479 Hitting @kbd{C-c C-s} on line 3 of this example gives: | |
480 @example | |
481 | |
482 ((comment-intro) (defun-block-intro . 46)) | |
483 | |
484 @end example | |
485 | |
486 @noindent | |
487 and you can see that the syntactic component list contains two syntactic | |
488 components. Also notice that the first component, | |
489 @samp{(comment-intro)} has no relative buffer position. | |
490 | |
491 | |
492 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
493 @node Indentation Calculation, , Syntactic Analysis, New Indentation Engine |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
494 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
495 @section Indentation Calculation |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
496 @cindex indentation calculation |
25829 | 497 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
498 | |
499 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
|
500 component list derived in step 1 above (@pxref{Syntactic Analysis}). |
25829 | 501 Each component contributes to the final total indentation of the line in |
502 two ways. | |
503 | |
504 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
|
505 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
|
506 the offsets to apply for those symbols. These offsets are added to a |
25829 | 507 running total. |
508 | |
509 Second, if the component has a relative buffer position, @ccmode{} | |
510 adds the column number of that position to the running total. By adding | |
511 up the offsets and columns for every syntactic component on the list, | |
512 the final total indentation for the current line is computed. | |
513 | |
514 Let's use our two code examples above to see how this works. Here is | |
515 our first example again: | |
516 @example | |
517 @group | |
518 | |
519 1: void swap( int& a, int& b ) | |
520 2: @{ | |
521 3: int tmp = a; | |
522 4: a = b; | |
523 5: b = tmp; | |
524 6: @} | |
525 | |
526 @end group | |
527 @end example | |
528 | |
529 Let's say point is on line 3 and we hit the @kbd{TAB} key to re-indent | |
530 the line. Remember that the syntactic component list for that | |
531 line is: | |
532 @example | |
533 | |
534 ((defun-block-intro . 29)) | |
535 | |
536 @end example | |
537 | |
538 @noindent | |
539 @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
|
540 @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
|
541 @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
|
542 yielding a running total indentation of 4 spaces. |
25829 | 543 |
544 Next @ccmode{} goes to buffer position 29 and asks for the current | |
545 column. This brace is in column zero, so @ccmode{} | |
546 adds @samp{0} to the running total. Since there is only one syntactic | |
547 component on the list for this line, indentation calculation is | |
548 complete, and the total indentation for the line | |
549 is 4 spaces. | |
550 | |
551 Here's another example: | |
552 @example | |
553 @group | |
554 | |
555 1: int add( int val, int incr, int doit ) | |
556 2: @{ | |
557 3: if( doit ) | |
558 4: @{ | |
559 5: return( val + incr ); | |
560 6: @} | |
561 7: return( val ); | |
562 8: @} | |
563 | |
564 @end group | |
565 @end example | |
566 | |
567 If we were to hit @kbd{TAB} on line 4 in the above example, the same | |
568 basic process is performed, despite the differences in the syntactic | |
569 component list. Remember that the list for this line is: | |
570 @example | |
571 | |
572 ((substatement-open . 46)) | |
573 | |
574 @end example | |
575 | |
576 Here, @ccmode{} first looks up the @code{substatement-open} symbol | |
577 in @code{c-offsets-alist}. Let's say it finds the value @samp{4}. This | |
578 yields a running total of 4. @ccmode{} then goes to | |
579 buffer position 46, which is the @samp{i} in @code{if} on line 3. This | |
580 character is in the fourth column on that line so adding this to the | |
581 running total yields an indentation for the line of 8 spaces. | |
582 | |
583 Simple, huh? | |
584 | |
585 Actually, the mode usually just does The Right Thing without you having | |
586 to think about it in this much detail. But when customizing | |
587 indentation, it's helpful to understand the general indentation model | |
588 being used. | |
589 | |
590 @vindex c-echo-syntactic-information-p | |
591 @vindex echo-syntactic-information-p (c-) | |
592 As you configure @ccmode{}, you might want to set the variable | |
593 @code{c-echo-syntactic-information-p} to non-@code{nil} so that the | |
594 syntactic component list and calculated offset will always be echoed in | |
595 the minibuffer when you hit @kbd{TAB}. | |
596 | |
597 | |
598 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
599 @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
|
600 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
601 @chapter Minor Modes |
25829 | 602 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
603 | |
604 @ccmode{} contains two minor-mode-like features that you should | |
605 find useful while you enter new C code. The first is called | |
606 @dfn{auto-newline} mode, and the second is called @dfn{hungry-delete} | |
607 mode. These minor modes can be toggled on and off independently, and | |
608 @ccmode{} can be configured so that it starts up with any | |
609 combination of these minor modes. By default, both of these minor modes | |
610 are turned off. | |
611 | |
612 The state of the minor modes is always reflected in the minor mode list | |
613 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
|
614 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
|
615 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
|
616 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
|
617 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
|
618 you'd see @samp{C/ah}. |
25829 | 619 |
620 @kindex C-c C-a | |
621 @kindex C-c C-d | |
622 @kindex C-c C-t | |
623 @findex c-toggle-hungry-state | |
624 @findex c-toggle-auto-state | |
625 @findex c-toggle-auto-hungry-state | |
626 @findex toggle-hungry-state (c-) | |
627 @findex toggle-auto-state (c-) | |
628 @findex toggle-auto-hungry-state (c-) | |
629 @ccmode{} provides keybindings which allow you to toggle the minor | |
630 modes on the fly while editing code. To toggle just the auto-newline | |
631 state, hit @kbd{C-c C-a} (@code{c-toggle-auto-state}). When you do | |
632 this, you should see the @samp{a} indicator either appear or disappear | |
633 on the modeline. Similarly, to toggle just the hungry-delete state, use | |
634 @kbd{C-c C-d} (@code{c-toggle-hungry-state}), and to toggle both states, | |
635 use @kbd{C-c C-t} (@code{c-toggle-auto-hungry-state}). | |
636 | |
637 To set up the auto-newline and hungry-delete states to your preferred | |
638 values, you would need to add some lisp to your @file{.emacs} file that | |
639 called one of the @code{c-toggle-*-state} functions directly. When | |
640 called programmatically, each function takes a numeric value, where | |
641 a positive number enables the minor mode, a negative number disables the | |
642 mode, and zero toggles the current state of the mode. | |
643 | |
644 So for example, if you wanted to enable both auto-newline and | |
645 hungry-delete for all your C file editing, you could add the following | |
646 to your @file{.emacs} file: | |
647 @example | |
648 | |
649 (add-hook 'c-mode-common-hook | |
34151
33df9c2e70bf
Don't quote lambdas.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30396
diff
changeset
|
650 (lambda () (c-toggle-auto-hungry-state 1))) |
25829 | 651 |
652 @end example | |
653 | |
654 | |
655 @cindex electric characters | |
656 | |
657 @menu | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
658 * Auto-newline Insertion:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
659 * Hungry-deletion of Whitespace:: |
25829 | 660 @end menu |
661 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
662 |
25829 | 663 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
664 @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
|
665 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
666 @section Auto-newline Insertion |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
667 @cindex auto-newline insertion |
25829 | 668 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
669 | |
670 @cindex electric commands | |
671 Auto-newline minor mode works by enabling certain @dfn{electric | |
672 commands}. Electric commands are typically bound to special characters | |
673 such as the left and right braces, colons, semi-colons, etc., which when | |
674 typed, perform some magic formatting in addition to inserting the typed | |
675 character. As a general rule, electric commands are only electric when | |
676 the following conditions apply: | |
677 | |
678 @itemize @bullet | |
679 @item | |
680 Auto-newline minor mode is enabled, as evidenced by a @samp{C/a} or | |
681 @samp{C/ah} indicator on the modeline. | |
682 | |
683 @cindex literal | |
684 @cindex syntactic whitespace | |
685 @item | |
686 The character was not typed inside of a literal @footnote{A | |
687 @dfn{literal} is defined as any comment, string, or C preprocessor macro | |
688 definition. These constructs are also known as @dfn{syntactic | |
689 whitespace} since they are usually ignored when scanning C code.}. | |
690 | |
691 @item | |
692 @kindex C-u | |
693 No numeric argument was supplied to the command (i.e. it was typed as | |
694 normal, with no @kbd{C-u} prefix). | |
695 | |
696 @end itemize | |
697 | |
698 @menu | |
699 * Hanging Braces:: | |
700 * Hanging Colons:: | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
701 * Hanging Semi-colons and Commas:: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
702 * Other Electric Commands:: |
25829 | 703 * Clean-ups:: |
704 @end menu | |
705 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
706 |
25829 | 707 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
708 @node Hanging Braces, Hanging Colons, , Auto-newline Insertion |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
709 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
710 @subsection Hanging Braces |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
711 @cindex hanging braces |
25829 | 712 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
713 | |
714 @findex c-electric-brace | |
715 @findex electric-brace (c-) | |
716 @vindex c-hanging-braces-alist | |
717 @vindex hanging-braces-alist (c-) | |
718 When you type either an open or close brace (i.e. @kbd{@{} or @kbd{@}}), | |
719 the electric command @code{c-electric-brace} gets run. This command has | |
720 two electric formatting behaviors. First, it will perform some | |
721 re-indentation of the line the brace was typed on, and second, it will | |
722 add various newlines before and/or after the typed brace. | |
723 Re-indentation occurs automatically whenever the electric behavior is | |
724 enabled. If the brace ends up on a line other than the one it was typed | |
725 on, then that line is also re-indented. | |
726 | |
727 @cindex class-open syntactic symbol | |
728 @cindex class-close syntactic symbol | |
729 @cindex defun-open syntactic symbol | |
730 @cindex defun-close syntactic symbol | |
731 @cindex inline-open syntactic symbol | |
732 @cindex inline-close syntactic symbol | |
733 @cindex brace-list-open syntactic symbol | |
734 @cindex brace-list-close syntactic symbol | |
735 @cindex brace-list-intro syntactic symbol | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
736 @cindex brace-entry-open syntactic symbol |
25829 | 737 @cindex block-open syntactic symbol |
738 @cindex block-close syntactic symbol | |
739 @cindex substatement-open syntactic symbol | |
740 @cindex statement-case-open syntactic symbol | |
741 @cindex extern-lang-open syntactic symbol | |
742 @cindex extern-lang-close syntactic symbol | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
743 @cindex namespace-open syntactic symbol |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
744 @cindex namespace-close syntactic symbol |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
745 @cindex inexpr-class-open symbol |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
746 @cindex inexpr-class-close symbol |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
747 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
748 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
|
749 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
|
750 @code{c-hanging-braces-alist} style variable. This variable contains a |
25829 | 751 mapping between syntactic symbols related to braces, and a list of |
752 places to insert a newline. The syntactic symbols that are useful for | |
753 this list are: @code{class-open}, @code{class-close}, @code{defun-open}, | |
754 @code{defun-close}, @code{inline-open}, @code{inline-close}, | |
755 @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
|
756 @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
|
757 @code{block-close}, @code{substatement-open}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
758 @code{statement-case-open}, @code{extern-lang-open}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
759 @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
|
760 @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
|
761 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
|
762 @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
|
763 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
|
764 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
|
765 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
|
766 description of these syntactic symbols, except for |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
767 @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
|
768 actual syntactic symbols. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
769 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
770 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
|
771 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
|
772 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
|
773 braces of anonymous classes produces a combination of |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
774 @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
|
775 normal indentation analysis.}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
776 |
25829 | 777 The value associated with each syntactic symbol in this association list |
778 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
|
779 @xref{Custom Brace and Colon Hanging}, for a more detailed discussion of |
25829 | 780 using a function as a brace hanging @var{ACTION}. |
781 | |
782 When the @var{ACTION} is a list, it can contain any combination of the | |
783 symbols @code{before} and @code{after}, directing @ccmode{} where to | |
784 put newlines in relationship to the brace being inserted. Thus, if the | |
785 list contains only the symbol @code{after}, then the brace is said to | |
786 @dfn{hang} on the right side of the line, as in: | |
787 @example | |
788 @group | |
789 | |
790 // here, open braces always `hang' | |
791 void spam( int i ) @{ | |
792 if( i == 7 ) @{ | |
793 dosomething(i); | |
794 @} | |
795 @} | |
796 | |
797 | |
798 @end group | |
799 @end example | |
800 | |
801 When the list contains both @code{after} and @code{before}, the braces | |
802 will appear on a line by themselves, as shown by the close braces in the | |
803 above example. The list can also be empty, in which case no newlines | |
804 are added either before or after the brace. | |
805 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
806 If a syntactic symbol is missing entirely from |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
807 @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
|
808 @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
|
809 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
|
810 |
25829 | 811 For example, the default value of @code{c-hanging-braces-alist} is: |
812 @example | |
813 @group | |
814 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
815 ((brace-list-open) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
816 (brace-entry-open) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
817 (substatement-open after) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
818 (block-close . c-snug-do-while) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
819 (extern-lang-open after) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
820 (inexpr-class-open after) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
821 (inexpr-class-close before)) |
25829 | 822 |
823 @end group | |
824 @end example | |
825 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
826 @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
|
827 @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
|
828 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
|
829 @code{substatement-open}, @code{extern-lang-open}, and |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
830 @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
|
831 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
|
832 @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
|
833 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
|
834 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
|
835 other cases, braces are put on a line by themselves. |
25829 | 836 |
837 A word of caution: it is not a good idea to hang top-level construct | |
838 introducing braces, such as @code{class-open} or @code{defun-open}. | |
839 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
|
840 zero, hanging them can introduce performance problems. |
26490
2b08d829af86
Fix complaints from makeinfo 4.0.
Eli Zaretskii <eliz@gnu.org>
parents:
25829
diff
changeset
|
841 @xref{Performance Issues}, for more information. |
25829 | 842 |
843 | |
844 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
845 @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
|
846 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
847 @subsection Hanging Colons |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
848 @cindex hanging colons |
25829 | 849 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
850 | |
851 @vindex hanging-colons-alist (c-) | |
852 @vindex c-hanging-colons-alist | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
853 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
|
854 colons can also be made to hang using the style variable |
25829 | 855 @code{c-hanging-colons-alist}. The syntactic symbols appropriate for |
856 this assocation list are: @code{case-label}, @code{label}, | |
857 @code{access-label}, @code{member-init-intro}, and @code{inher-intro}. | |
858 Note however that for @code{c-hanging-colons-alist}, @var{ACTION}s as | |
859 functions are not supported. See also @ref{Custom Brace and Colon | |
860 Hanging} for details. | |
861 | |
862 In C++, double-colons are used as a scope operator but because these | |
863 colons always appear right next to each other, newlines before and after | |
864 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
|
865 @ccmode{}. @xref{Clean-ups}, for details. |
25829 | 866 |
867 | |
868 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
869 @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
|
870 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
871 @subsection Hanging Semi-colons and Commas |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
872 @cindex hanging semi-colons |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
873 @cindex hanging commas |
25829 | 874 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
875 | |
876 Semicolons and commas are also electric in @ccmode{}, but since | |
877 these characters do not correspond directly to syntactic symbols, a | |
878 different mechanism is used to determine whether newlines should be | |
879 automatically inserted after these characters. @xref{Customizing | |
26490
2b08d829af86
Fix complaints from makeinfo 4.0.
Eli Zaretskii <eliz@gnu.org>
parents:
25829
diff
changeset
|
880 Semi-colons and Commas}, for details. |
25829 | 881 |
882 | |
883 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
884 @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
|
885 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
886 @subsection Other Electric Commands |
25829 | 887 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
888 | |
889 @kindex # | |
890 @findex c-electric-pound | |
891 @vindex c-electric-pound-behavior | |
892 @findex electric-pound (c-) | |
893 @vindex electric-pound-behavior (c-) | |
894 A few other keys also provide electric behavior. For example | |
895 @kbd{#} (@code{c-electric-pound}) is electric when typed as | |
896 the first non-whitespace character on a line. In this case, the | |
897 variable @code{c-electric-pound-behavior} is consulted for the electric | |
898 behavior. This variable takes a list value, although the only element | |
899 currently defined is @code{alignleft}, which tells this command to force | |
900 the @samp{#} character into column zero. This is useful for entering | |
901 C preprocessor macro definitions. | |
902 | |
903 @findex c-electric-star | |
904 @findex c-electric-slash | |
905 @findex electric-star (c-) | |
906 @findex electric-slash (c-) | |
907 Stars and slashes (i.e. @kbd{*} and @kbd{/}, @code{c-electric-star} and | |
908 @code{c-electric-slash} respectively) are also electric under | |
909 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
|
910 a C style block comment on a comment-only line, then the comment |
25829 | 911 delimiter is indented as defined by @code{c-offsets-alist}. A |
912 comment-only line is defined as a line which contains only a comment, as | |
913 in: | |
914 @example | |
915 @group | |
916 | |
917 void spam( int i ) | |
918 @{ | |
919 // this is a comment-only line... | |
920 if( i == 7 ) // but this is not | |
921 @{ | |
922 dosomething(i); | |
923 @} | |
924 @} | |
925 | |
926 @end group | |
927 @end example | |
928 | |
929 Likewise, if a slash is inserted as the second slash in a C++ style line | |
930 comment (also only on a comment-only line), then the line is indented as | |
931 defined by @code{c-offsets-alist}. | |
932 | |
933 @findex c-electric-lt-gt | |
934 @findex electric-lt-gt (c-) | |
935 @kindex < | |
936 @kindex > | |
937 Less-than and greater-than signs (@code{c-electric-lt-gt}) are also | |
938 electric, but only in C++ mode. Hitting the second of two @kbd{<} or | |
939 @kbd{>} keys re-indents the line if it is a C++ style stream operator. | |
940 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
941 @findex c-electric-paren |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
942 @findex electric-paren (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
943 @kindex ( |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
944 @kindex ) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
945 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
|
946 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
|
947 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
|
948 automatically. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
949 |
25829 | 950 |
951 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
952 @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
|
953 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
954 @subsection Clean-ups |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
955 @cindex clean-ups |
25829 | 956 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
957 | |
958 @dfn{Clean-ups} are a mechanism complementary to colon and brace | |
959 hanging. On the surface, it would seem that clean-ups overlap the | |
960 functionality provided by the @code{c-hanging-*-alist} variables, and | |
961 similarly, clean-ups are only enabled when auto-newline minor mode is | |
962 enabled. Clean-ups are used however to adjust code ``after-the-fact'', | |
963 i.e. to eliminate some whitespace that is inserted by electric | |
964 commands, or whitespace that contains intervening constructs. | |
965 | |
966 @vindex c-cleanup-list | |
967 @vindex cleanup-list (c-) | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
968 @cindex literal |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
969 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
|
970 @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
|
971 @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
|
972 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
|
973 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
|
974 (@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
|
975 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
|
976 |
25829 | 977 There are currently only five specific constructs that @ccmode{} |
978 can clean up, as indicated by these symbols: | |
979 | |
980 @itemize @bullet | |
981 @item | |
982 @code{brace-else-brace} --- cleans up @samp{@} else @{} constructs by | |
983 placing the entire construct on a single line. Clean-up occurs when the | |
984 open brace after the @samp{else} is typed. So for example, this: | |
985 @example | |
986 @group | |
987 | |
988 void spam(int i) | |
989 @{ | |
990 if( i==7 ) | |
991 @{ | |
992 dosomething(); | |
993 @} | |
994 else | |
995 @{ | |
996 | |
997 @end group | |
998 @end example | |
999 @noindent | |
1000 appears like this after the open brace is typed: | |
1001 @example | |
1002 @group | |
1003 | |
1004 void spam(int i) | |
1005 @{ | |
1006 if( i==7 ) @{ | |
1007 dosomething(); | |
1008 @} else @{ | |
1009 | |
1010 @end group | |
1011 @end example | |
1012 | |
1013 @item | |
1014 @code{brace-elseif-brace} --- similar to the @code{brace-else-brace} | |
1015 clean-up, but this cleans up @samp{@} else if (...) @{} constructs. For | |
1016 example: | |
1017 @example | |
1018 @group | |
1019 | |
1020 void spam(int i) | |
1021 @{ | |
1022 if( i==7 ) | |
1023 @{ | |
1024 dosomething(); | |
1025 @} | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1026 else if( i==3 ) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1027 @{ |
25829 | 1028 |
1029 @end group | |
1030 @end example | |
1031 @noindent | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1032 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
|
1033 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1034 @group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1035 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1036 void spam(int i) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1037 @{ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1038 if( i==7 ) @{ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1039 dosomething(); |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1040 @} else if( i==3 ) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1041 @{ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1042 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1043 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1044 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1045 @noindent |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1046 and like this after the open brace is typed: |
25829 | 1047 @example |
1048 @group | |
1049 | |
1050 void spam(int i) | |
1051 @{ | |
1052 if( i==7 ) @{ | |
1053 dosomething(); | |
1054 @} else if( i==3 ) @{ | |
1055 | |
1056 @end group | |
1057 @end example | |
1058 | |
1059 @item | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1060 @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
|
1061 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
|
1062 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1063 @item |
25829 | 1064 @code{empty-defun-braces} --- cleans up braces following a top-level |
1065 function or class definition that contains no body. Clean up occurs | |
1066 when the closing brace is typed. Thus the following: | |
1067 @example | |
1068 @group | |
1069 | |
1070 class Spam | |
1071 @{ | |
1072 @} | |
1073 | |
1074 @end group | |
1075 @end example | |
1076 @noindent | |
1077 is transformed into this when the close brace is typed: | |
1078 @example | |
1079 @group | |
1080 | |
1081 class Spam | |
1082 @{@} | |
1083 | |
1084 @end group | |
1085 @end example | |
1086 | |
1087 @item | |
1088 @code{defun-close-semi} --- cleans up the terminating semi-colon on | |
1089 top-level function or class definitions when they follow a close | |
1090 brace. Clean up occurs when the semi-colon is typed. | |
1091 So for example, the following: | |
1092 @example | |
1093 @group | |
1094 | |
1095 class Spam | |
1096 @{ | |
1097 @} | |
1098 ; | |
1099 | |
1100 @end group | |
1101 @end example | |
1102 @noindent | |
1103 is transformed into this when the semi-colon is typed: | |
1104 | |
1105 @example | |
1106 @group | |
1107 | |
1108 class Spam | |
1109 @{ | |
1110 @}; | |
1111 | |
1112 @end group | |
1113 @end example | |
1114 | |
1115 @item | |
1116 @code{list-close-comma} --- cleans up commas following braces in array | |
1117 and aggregate initializers. Clean up occurs when the comma is typed. | |
1118 | |
1119 @item | |
1120 @code{scope-operator} --- cleans up double colons which may designate a | |
1121 C++ scope operator split across multiple lines@footnote{Certain C++ | |
1122 constructs introduce ambiguous situations, so @code{scope-operator} | |
1123 clean-ups may not always be correct. This usually only occurs when | |
1124 scoped identifiers appear in switch label tags.}. Clean up occurs when | |
1125 the second colon is typed. You will always want @code{scope-operator} | |
1126 in the @code{c-cleanup-list} when you are editing C++ code. | |
1127 | |
1128 @end itemize | |
1129 | |
1130 | |
1131 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1132 @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
|
1133 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1134 @section Hungry-deletion of Whitespace |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1135 @cindex hungry-deletion of whitespace |
25829 | 1136 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
1137 | |
1138 Hungry deletion of whitespace, or as it more commonly called, | |
1139 @dfn{hungry-delete mode}, is a simple feature that some people find | |
1140 extremely useful. In fact, you might find yourself wanting | |
1141 hungry-delete in @strong{all} your editing modes! | |
1142 | |
1143 @kindex DEL | |
1144 @kindex Backspace | |
1145 In a nutshell, when hungry-delete mode is enabled, hitting the | |
1146 @key{Backspace} key@footnote{I say ``hit the @key{Backspace} key'' but | |
1147 what I really mean is ``when Emacs receives the @code{BackSpace} key | |
1148 event''. The difference usually isn't significant to most users, but | |
1149 advanced users will realize that under window systems such as X, any | |
1150 physical key (keycap) on the keyboard can be configured to generate any | |
1151 keysym, and thus any Emacs key event. Also, the use of Emacs on TTYs | |
1152 will affect which keycap generates which key event. From a pedantic | |
1153 point of view, here we are only concerned with the key event that | |
1154 Emacs receives.} will consume all preceding whitespace, including | |
1155 newlines and tabs. This can really cut down on the number of | |
1156 @key{Backspace}'s you have to type if, for example you made a mistake on | |
1157 the preceding line. | |
1158 | |
1159 @findex c-electric-backspace | |
1160 @findex electric-backspace (c-) | |
1161 @vindex c-backspace-function | |
1162 @vindex backspace-function (c-) | |
1163 | |
1164 @findex c-electric-delete | |
1165 @findex electric-delete (c-) | |
1166 @vindex c-delete-function | |
1167 @vindex delete-function (c-) | |
1168 @cindex literal | |
1169 | |
1170 @findex backward-delete-char-untabify | |
1171 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1172 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
|
1173 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
|
1174 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
|
1175 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
|
1176 mode is disabled, the function contained in the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1177 @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
|
1178 number of characters to delete). This variable is set to |
25829 | 1179 @code{backward-delete-char-untabify} by default. |
1180 | |
1181 @vindex delete-key-deletes-forward | |
1182 @findex delete-char | |
1183 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1184 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
|
1185 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
|
1186 @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
|
1187 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
|
1188 @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
|
1189 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
|
1190 @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
|
1191 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
|
1192 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
|
1193 @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
|
1194 @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
|
1195 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
|
1196 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
|
1197 @code{delete-char} by default. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1198 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1199 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
|
1200 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
|
1201 explicitly binding @code{[delete]}@footnote{E.g. to |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1202 @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
|
1203 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
|
1204 @code{delete-key-deletes-forward}.}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1205 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1206 XEmacsen older than 20.3 behave similar to Emacs 19 and Emacs 20. |
25829 | 1207 |
1208 | |
1209 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1210 @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
|
1211 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1212 @chapter Text Filling and Line Breaking |
25829 | 1213 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
1214 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1215 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
|
1216 @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
|
1217 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
|
1218 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
|
1219 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
|
1220 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
|
1221 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
|
1222 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
|
1223 necessary. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1224 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1225 @vindex c-comment-prefix-regexp |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1226 @vindex comment-prefix-regexp (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1227 @cindex comment line prefix |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1228 @vindex comment-start |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1229 @vindex comment-end |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1230 @vindex comment-start-skip |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1231 @vindex paragraph-start |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1232 @vindex paragraph-separate |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1233 @vindex paragraph-ignore-fill-prefix |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1234 @vindex adaptive-fill-mode |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1235 @vindex adaptive-fill-regexp |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1236 @vindex adaptive-fill-first-line-regexp |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1237 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
|
1238 paragraphs, @ccmode{} makes several standard |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1239 variables@footnote{@code{comment-start}, @code{comment-end}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1240 @code{comment-start-skip}, @code{paragraph-start}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1241 @code{paragraph-separate}, @code{paragraph-ignore-fill-prefix}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1242 @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
|
1243 @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
|
1244 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
|
1245 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
|
1246 @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
|
1247 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
|
1248 matches C++ style line comments like |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1249 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1250 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1251 // blah blah |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1252 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1253 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1254 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1255 @noindent |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1256 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
|
1257 like |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1258 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1259 @group |
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 /* |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1262 * blah blah |
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 @noindent |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1269 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
|
1270 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
|
1271 (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
|
1272 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
|
1273 @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
|
1274 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
|
1275 it inside a @ccmode{} buffer. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1276 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1277 @findex auto-fill-mode |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1278 @cindex auto fill mode |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1279 @cindex paragraph fill |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1280 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
|
1281 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
|
1282 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
|
1283 @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
|
1284 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
|
1285 @code{string} syntactic symbol). In comments, @ccmode{} uses |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1286 @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
|
1287 lines in the comment. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1288 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1289 @vindex adaptive-fill-mode |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1290 @cindex adaptive fill mode |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1291 @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
|
1292 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
|
1293 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
|
1294 @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
|
1295 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
|
1296 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1297 @group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1298 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1299 /* 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
|
1300 * 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
|
1301 * Knuth, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1302 * |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1303 * 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
|
1304 * proved it correct, not tried it. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1305 */ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1306 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1307 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1308 @end 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 @findex c-setup-filladapt |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1311 @findex setup-filladapt (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1312 @findex filladapt-mode |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1313 @vindex filladapt-mode |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1314 @cindex Filladapt mode |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1315 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
|
1316 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
|
1317 @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
|
1318 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
|
1319 @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
|
1320 by default). A patch for that is available from |
30396
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
1321 @uref{http://cc-mode.sourceforge.net/,, the CC Mode site}.}, |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1322 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
|
1323 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
|
1324 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
|
1325 something like this in your @file{.emacs}: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1326 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1327 @group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1328 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1329 (defun my-c-mode-common-hook () |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1330 (c-setup-filladapt) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1331 (filladapt-mode 1)) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1332 (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
|
1333 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1334 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1335 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1336 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1337 @vindex c-block-comment-prefix |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1338 @vindex block-comment-prefix (c-) |
25829 | 1339 @vindex c-comment-continuation-stars |
1340 @vindex comment-continuation-stars (c-) | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1341 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
|
1342 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
|
1343 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
|
1344 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
|
1345 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
|
1346 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
|
1347 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
|
1348 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
|
1349 makes a comment |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1350 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1351 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1352 /* 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
|
1353 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1354 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1355 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1356 @noindent |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1357 break into |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1358 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1359 @group |
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 /* Got O(n^2) here, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1362 * which is a Bad Thing. */ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1363 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1364 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1365 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1366 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1367 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
|
1368 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
|
1369 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
|
1370 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
|
1371 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
|
1372 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
|
1373 Functions}. |
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 @vindex c-ignore-auto-fill |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1376 @vindex ignore-auto-fill (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1377 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
|
1378 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
|
1379 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
|
1380 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
|
1381 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
|
1382 should occur: |
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 @itemize @bullet |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1385 @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
|
1386 @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
|
1387 @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
|
1388 @item @code{cpp} --- Inside a preprocessor directive. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1389 @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
|
1390 @end itemize |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1391 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1392 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
|
1393 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
|
1394 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
|
1395 explicit control over newlines. In preprocessor directives, the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1396 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
|
1397 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
|
1398 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
|
1399 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
|
1400 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
|
1401 implementation. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1402 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1403 The commands that does the actual work follows. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1404 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1405 @table @asis |
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 @kindex M-q |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1408 @findex c-fill-paragraph |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1409 @findex fill-paragraph (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1410 @cindex Javadoc markup |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1411 @item @kbd{M-q} (@code{c-fill-paragraph}) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1412 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
|
1413 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
|
1414 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
|
1415 recognized as paragraph starters. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1416 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1417 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
|
1418 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
|
1419 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
|
1420 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
|
1421 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
|
1422 @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
|
1423 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
|
1424 obsolete.}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1425 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1426 @kindex M-j |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1427 @findex c-indent-new-comment-line |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1428 @findex indent-new-comment-line (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1429 @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
|
1430 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
|
1431 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
|
1432 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1433 @vindex comment-multi-line |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1434 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
|
1435 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
|
1436 @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
|
1437 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
|
1438 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1439 @findex c-context-line-break |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1440 @findex context-line-break (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1441 @item @kbd{M-x c-context-line-break} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1442 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
|
1443 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
|
1444 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
|
1445 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
|
1446 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
|
1447 indentation engine. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1448 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1449 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
|
1450 @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
|
1451 @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
|
1452 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1453 @end table |
25829 | 1454 |
1455 | |
1456 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1457 @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
|
1458 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1459 @chapter Commands |
25829 | 1460 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
1461 | |
1462 @menu | |
1463 * Indentation Commands:: | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1464 * Movement Commands:: |
25829 | 1465 * Other Commands:: |
1466 @end menu | |
1467 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1468 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
|
1469 that bit. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1470 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1471 |
25829 | 1472 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1473 @node Indentation Commands, Movement Commands, , Commands |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1474 @comment node-name, next, previous,up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1475 @section Indentation Commands |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1476 @cindex indentation commands |
25829 | 1477 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
1478 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1479 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
|
1480 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
|
1481 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
|
1482 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
|
1483 your changes. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1484 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1485 @cindex GNU indent program |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1486 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
|
1487 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
|
1488 ``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
|
1489 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
|
1490 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
|
1491 among other things. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1492 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1493 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
|
1494 @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
|
1495 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
|
1496 code generator output@footnote{In particular, I have had people |
25829 | 1497 complain about the speed with which @code{lex(1)} output is re-indented. |
1498 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
|
1499 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
|
1500 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1501 These commands are useful when indenting code: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1502 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1503 @table @asis |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1504 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1505 @kindex TAB |
25829 | 1506 @findex c-indent-command |
1507 @findex indent-command (c-) | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1508 @item @kbd{TAB} (@code{c-indent-command}) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1509 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
|
1510 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
|
1511 @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
|
1512 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
|
1513 the relative indentation among the lines. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1514 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1515 @kindex M-C-q |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1516 @findex c-indent-exp |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1517 @findex indent-exp (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1518 @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
|
1519 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
|
1520 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
|
1521 want to indent. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1522 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1523 @kindex C-c C-q |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1524 @findex c-indent-defun |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1525 @findex indent-defun (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1526 @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
|
1527 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
|
1528 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
|
1529 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
|
1530 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
|
1531 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
|
1532 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1533 @kindex M-C-\ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1534 @findex indent-region |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1535 @item @kbd{M-C-\} (@code{indent-region}) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1536 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
|
1537 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
|
1538 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
|
1539 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1540 @kindex M-C-h |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1541 @findex c-mark-function |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1542 @findex mark-function (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1543 @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
|
1544 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
|
1545 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
|
1546 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
|
1547 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
|
1548 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1549 @end table |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1550 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1551 These variables are also useful when indenting code: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1552 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1553 @table @code |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1554 |
25829 | 1555 @vindex c-tab-always-indent |
1556 @vindex tab-always-indent (c-) | |
1557 @kindex TAB | |
1558 @cindex literal | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1559 @item c-tab-always-indent |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1560 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
|
1561 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
|
1562 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
|
1563 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
|
1564 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
|
1565 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
|
1566 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
|
1567 directives, but the line is always reindented. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1568 |
25829 | 1569 @vindex c-insert-tab-function |
1570 @vindex insert-tab-function (c-) | |
1571 @findex tab-to-tab-stop | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1572 @item c-insert-tab-function |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1573 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
|
1574 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
|
1575 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
|
1576 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
|
1577 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
|
1578 @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
|
1579 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1580 @vindex indent-tabs-mode |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1581 @item indent-tabs-mode |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1582 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
|
1583 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
|
1584 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
|
1585 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1586 @vindex c-progress-interval |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1587 @vindex progress-interval (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1588 @item c-progress-interval |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1589 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
|
1590 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
|
1591 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
|
1592 interval in seconds that progress messages are displayed. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1593 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1594 @end table |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1595 |
25829 | 1596 |
1597 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1598 @node Movement Commands, Other Commands, Indentation Commands, Commands |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1599 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1600 @section Movement Commands |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1601 @cindex movement commands |
25829 | 1602 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
1603 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1604 @ccmode{} contains some useful command for moving around in C |
25829 | 1605 code. |
1606 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1607 @table @asis |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1608 |
25829 | 1609 @findex c-beginning-of-defun |
1610 @findex beginning-of-defun (c-) | |
1611 @findex beginning-of-defun | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1612 @item @kbd{M-x c-beginning-of-defun} |
25829 | 1613 Moves point back to the least-enclosing brace. This function is |
1614 analogous to the Emacs built-in command @code{beginning-of-defun}, | |
1615 except it eliminates the constraint that the top-level opening brace | |
1616 must be in column zero. See @code{beginning-of-defun} for more | |
1617 information. | |
1618 | |
1619 Depending on the coding style being used, you might prefer | |
1620 @code{c-beginning-of-defun} to @code{beginning-of-defun}. If so, | |
1621 consider binding @kbd{C-M-a} to the former instead. For backwards | |
1622 compatibility reasons, the default binding remains in effect. | |
1623 | |
1624 @findex c-end-of-defun | |
1625 @findex end-of-defun (c-) | |
1626 @findex end-of-defun | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1627 @item @kbd{M-x c-end-of-defun} |
25829 | 1628 Moves point to the end of the current top-level definition. This |
1629 function is analogous to the Emacs built-in command @code{end-of-defun}, | |
1630 except it eliminates the constraint that the top-level opening brace of | |
1631 the defun must be in column zero. See @code{beginning-of-defun} for more | |
1632 information. | |
1633 | |
1634 Depending on the coding style being used, you might prefer | |
1635 @code{c-end-of-defun} to @code{end-of-defun}. If so, | |
1636 consider binding @kbd{C-M-e} to the former instead. For backwards | |
1637 compatibility reasons, the default binding remains in effect. | |
1638 | |
1639 @kindex C-c C-u | |
1640 @findex c-up-conditional | |
1641 @findex up-conditional (c-) | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1642 @item @kbd{C-c C-u} (@code{c-up-conditional}) |
25829 | 1643 Move point back to the containing preprocessor conditional, leaving the |
1644 mark behind. A prefix argument acts as a repeat count. With a negative | |
1645 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
|
1646 preprocessor conditional. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1647 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1648 @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
|
1649 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
|
1650 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1651 @findex c-up-conditional-with-else |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1652 @findex up-conditional-with-else (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1653 @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
|
1654 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
|
1655 lines. Normally those lines are ignored. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1656 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1657 @findex c-down-conditional |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1658 @findex down-conditional (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1659 @item @kbd{M-x c-down-conditional} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1660 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
|
1661 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
|
1662 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
|
1663 nested preprocessor conditional. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1664 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1665 @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
|
1666 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
|
1667 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1668 @findex c-down-conditional-with-else |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1669 @findex down-conditional-with-else (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1670 @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
|
1671 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
|
1672 lines. Normally those lines are ignored. |
25829 | 1673 |
1674 @kindex C-c C-p | |
1675 @findex c-backward-conditional | |
1676 @findex backward-conditional (c-) | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1677 @item @kbd{C-c C-p} (@code{c-backward-conditional}) |
25829 | 1678 Move point back over a preprocessor conditional, leaving the mark |
1679 behind. A prefix argument acts as a repeat count. With a negative | |
1680 argument, move forward. | |
1681 | |
1682 @kindex C-c C-n | |
1683 @findex c-forward-conditional | |
1684 @findex forward-conditional (c-) | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1685 @item @kbd{C-c C-n} (@code{c-forward-conditional}) |
25829 | 1686 Move point forward across a preprocessor conditional, leaving the mark |
1687 behind. A prefix argument acts as a repeat count. With a negative | |
1688 argument, move backward. | |
1689 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1690 @kindex M-a |
25829 | 1691 @findex c-beginning-of-statement |
1692 @findex beginning-of-statement (c-) | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1693 @item @kbd{M-a} (@code{c-beginning-of-statement}) |
25829 | 1694 Move point to the beginning of the innermost C statement. If point is |
1695 already at the beginning of a statement, it moves to the beginning of | |
1696 the closest preceding statement, even if that means moving into a block | |
1697 (you can use @kbd{M-C-b} to move over a balanced block). With prefix | |
1698 argument @var{n}, move back @var{n} @minus{} 1 statements. | |
1699 | |
1700 If point is within a comment, or next to a comment, this command moves | |
1701 by sentences instead of statements. | |
1702 | |
1703 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
|
1704 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
|
1705 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
|
1706 inside comments. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1707 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1708 @kindex M-e |
25829 | 1709 @findex c-end-of-statement |
1710 @findex end-of-statement (c-) | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1711 @item @kbd{M-e} (@code{c-end-of-statement}) |
25829 | 1712 Move point to the end of the innermost C statement. If point is at the |
1713 end of a statement, move to the end of the next statement, even if it's | |
1714 inside a nested block (use @kbd{M-C-f} to move to the other side of the | |
1715 block). With prefix argument @var{n}, move forward @var{n} @minus{} 1 | |
1716 statements. | |
1717 | |
1718 If point is within a comment, or next to a comment, this command moves | |
1719 by sentences instead of statements. | |
1720 | |
1721 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
|
1722 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
|
1723 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
|
1724 inside comments. |
25829 | 1725 |
1726 @findex c-forward-into-nomenclature | |
1727 @findex forward-into-nomenclature (c-) | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1728 @item @kbd{M-x c-forward-into-nomenclature} |
25829 | 1729 A popular programming style, especially for object-oriented languages |
1730 such as C++ is to write symbols in a mixed case format, where the first | |
1731 letter of each word is capitalized, and not separated by underscores. | |
1732 E.g. @samp{SymbolsWithMixedCaseAndNoUnderlines}. | |
1733 | |
1734 This command moves point forward to next capitalized word. With prefix | |
1735 argument @var{n}, move @var{n} times. | |
1736 | |
1737 @findex c-backward-into-nomenclature | |
1738 @findex backward-into-nomenclature (c-) | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1739 @item @kbd{M-x c-backward-into-nomenclature} |
25829 | 1740 Move point backward to beginning of the next capitalized |
1741 word. With prefix argument @var{n}, move @var{n} times. If | |
1742 @var{n} is negative, move forward. | |
1743 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1744 @end table |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1745 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1746 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1747 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1748 @node Other Commands, , Movement Commands, Commands |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1749 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1750 @section Other Commands |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1751 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1752 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1753 @ccmode{} contains a few other useful commands: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1754 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1755 @table @asis |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1756 |
25829 | 1757 @kindex C-c : |
1758 @findex c-scope-operator | |
1759 @findex scope-operator (c-) | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1760 @item @kbd{C-c :} (@code{c-scope-operator}) |
25829 | 1761 In C++, it is also sometimes desirable to insert the double-colon scope |
1762 operator without performing the electric behavior of colon insertion. | |
1763 @kbd{C-c :} does just this. | |
1764 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1765 @kindex C-c C-\ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1766 @findex c-backslash-region |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1767 @findex backslash-region (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1768 @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
|
1769 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
|
1770 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
|
1771 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
|
1772 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1773 @vindex c-backslash-column |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1774 @vindex backslash-column (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1775 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
|
1776 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
|
1777 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
|
1778 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1779 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
|
1780 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
|
1781 (if any) at the end of the previous line. |
25829 | 1782 |
1783 @end table | |
1784 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1785 |
25829 | 1786 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1787 @node Customizing Indentation, Syntactic Symbols, Commands, Top |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1788 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1789 @chapter Customizing Indentation |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1790 @cindex customizing indentation |
25829 | 1791 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
1792 | |
1793 @vindex c-offsets-alist | |
1794 @vindex offsets-alist (c-) | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1795 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
|
1796 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
|
1797 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
|
1798 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
|
1799 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
|
1800 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
|
1801 styles. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1802 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1803 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
|
1804 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
|
1805 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
|
1806 @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
|
1807 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
|
1808 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
|
1809 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
|
1810 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
|
1811 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1812 @kindex C-c C-o |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1813 @findex c-set-offset |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1814 @findex set-offset (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1815 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
|
1816 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
|
1817 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
|
1818 function call programmatically!}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1819 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1820 @vindex c-basic-offset |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1821 @vindex basic-offset (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1822 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
|
1823 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
|
1824 the following symbols: @code{+}, @code{-}, @code{++}, @code{--}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1825 @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
|
1826 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
|
1827 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
|
1828 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
|
1829 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
|
1830 the special symbols correspond to: |
25829 | 1831 |
1832 @table @code | |
1833 | |
1834 @item + | |
1835 @code{c-basic-offset} times 1 | |
1836 @item - | |
1837 @code{c-basic-offset} times -1 | |
1838 @item ++ | |
1839 @code{c-basic-offset} times 2 | |
1840 @item -- | |
1841 @code{c-basic-offset} times -2 | |
1842 @item * | |
1843 @code{c-basic-offset} times 0.5 | |
1844 @item / | |
1845 @code{c-basic-offset} times -0.5 | |
1846 | |
1847 @end table | |
1848 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1849 @cindex indentation functions |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1850 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1851 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
|
1852 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
|
1853 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
|
1854 @xref{Indentation Functions}, and @ref{Custom Indentation Functions}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1855 for details about them. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1856 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1857 @vindex c-strict-syntax-p |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1858 @vindex strict-syntax-p (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1859 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
|
1860 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
|
1861 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
|
1862 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
|
1863 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
|
1864 @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
|
1865 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
|
1866 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
|
1867 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
|
1868 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
|
1869 |
25829 | 1870 So, for example, because most of the default offsets are defined in |
1871 terms of @code{+}, @code{-}, and @code{0}, if you like the general | |
1872 indentation style, but you use 4 spaces instead of 2 spaces per level, | |
1873 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
|
1874 @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
|
1875 a C buffer by typing the text that appears in italics.}: |
25829 | 1876 @example |
1877 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1878 @emph{M-x set-variable RET} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1879 Set variable: @emph{c-basic-offset RET} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1880 Set c-basic-offset to value: @emph{4 RET} |
25829 | 1881 |
1882 @end example | |
1883 | |
1884 @noindent | |
1885 This would change | |
1886 @example | |
1887 @group | |
1888 | |
1889 int add( int val, int incr, int doit ) | |
1890 @{ | |
1891 if( doit ) | |
1892 @{ | |
1893 return( val + incr ); | |
1894 @} | |
1895 return( val ); | |
1896 @} | |
1897 | |
1898 @end group | |
1899 @end example | |
1900 @noindent | |
1901 to | |
1902 @example | |
1903 @group | |
1904 | |
1905 int add( int val, int incr, int doit ) | |
1906 @{ | |
1907 if( doit ) | |
1908 @{ | |
1909 return( val + incr ); | |
1910 @} | |
1911 return( val ); | |
1912 @} | |
1913 | |
1914 @end group | |
1915 @end example | |
1916 | |
1917 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
|
1918 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
|
1919 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
|
1920 your @file{.emacs} file so that your changes are more permanent. |
25829 | 1921 |
1922 @menu | |
1923 * Interactive Customization:: | |
1924 * Permanent Customization:: | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1925 * Hooks:: |
25829 | 1926 * Styles:: |
1927 * Advanced Customizations:: | |
1928 @end menu | |
1929 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1930 |
25829 | 1931 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1932 @node Interactive Customization, Permanent Customization, , Customizing Indentation |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1933 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1934 @section Interactive Customization |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1935 @cindex interactive customization |
25829 | 1936 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
1937 | |
1938 As an example of how to customize indentation, let's change the | |
1939 style of this example@footnote{In this an subsequent examples, the | |
1940 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
|
1941 indicated. @xref{Styles}.}: |
25829 | 1942 @example |
1943 @group | |
1944 | |
1945 1: int add( int val, int incr, int doit ) | |
1946 2: @{ | |
1947 3: if( doit ) | |
1948 4: @{ | |
1949 5: return( val + incr ); | |
1950 6: @} | |
1951 7: return( val ); | |
1952 8: @} | |
1953 | |
1954 @end group | |
1955 @end example | |
1956 @noindent | |
1957 to: | |
1958 @example | |
1959 @group | |
1960 | |
1961 1: int add( int val, int incr, int doit ) | |
1962 2: @{ | |
1963 3: if( doit ) | |
1964 4: @{ | |
1965 5: return( val + incr ); | |
1966 6: @} | |
1967 7: return( val ); | |
1968 8: @} | |
1969 | |
1970 @end group | |
1971 @end example | |
1972 | |
1973 In other words, we want to change the indentation of braces that open a | |
1974 block following a condition so that the braces line up under the | |
1975 conditional, instead of being indented. Notice that the construct we | |
1976 want to change starts on line 4. To change the indentation of a line, | |
1977 we need to see which syntactic components affect the offset calculations | |
1978 for that line. Hitting @kbd{C-c C-s} on line 4 yields: | |
1979 @example | |
1980 | |
1981 ((substatement-open . 44)) | |
1982 | |
1983 @end example | |
1984 | |
1985 @noindent | |
1986 so we know that to change the offset of the open brace, we need to | |
1987 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
|
1988 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
|
1989 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
|
1990 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
|
1991 syntactic symbol we want to change! |
25829 | 1992 |
1993 After you hit return, @ccmode{} will then prompt you for the new | |
1994 offset value, with the old value as the default. The default in this | |
1995 case is @samp{+}, but we want no extra indentation so enter | |
1996 @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
|
1997 syntactic symbol @code{substatement-open}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
1998 |
25829 | 1999 To check your changes quickly, just hit @kbd{C-c C-q} |
2000 (@code{c-indent-defun}) to reindent the entire function. The example | |
2001 should now look like: | |
2002 @example | |
2003 @group | |
2004 | |
2005 1: int add( int val, int incr, int doit ) | |
2006 2: @{ | |
2007 3: if( doit ) | |
2008 4: @{ | |
2009 5: return( val + incr ); | |
2010 6: @} | |
2011 7: return( val ); | |
2012 8: @} | |
2013 | |
2014 @end group | |
2015 @end example | |
2016 | |
2017 Notice how just changing the open brace offset on line 4 is all we | |
2018 needed to do. Since the other affected lines are indented relative to | |
2019 line 4, they are automatically indented the way you'd expect. For more | |
2020 complicated examples, this may not always work. The general approach to | |
2021 take is to always start adjusting offsets for lines higher up in the | |
2022 file, then re-indent and see if any following lines need further | |
2023 adjustments. | |
2024 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2025 |
25829 | 2026 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2027 @node Permanent Customization, Hooks, Interactive Customization, Customizing Indentation |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2028 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2029 @section Permanent Customization |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2030 @cindex permanent customization |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2031 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2032 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2033 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
|
2034 @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
|
2035 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
|
2036 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
|
2037 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
|
2038 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2039 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
|
2040 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
|
2041 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
|
2042 to the @file{.emacs} file: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2043 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2044 @group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2045 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2046 (require 'cc-mode) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2047 (c-set-offset 'substatement-open 0) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2048 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2049 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2050 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2051 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2052 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
|
2053 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
|
2054 defined. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2055 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2056 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
|
2057 this manual does not cover how that works. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2058 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2059 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
|
2060 all @ccmode{} buffers, regardless of language. The indentation style |
30396
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
2061 related variables, e.g. @code{c-basic-offset}, that you don't set this |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
2062 way get their value from the style system (@pxref{Styles}), and they |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
2063 therefore depend on the setting of @code{c-default-style}. Note that if |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
2064 you use Customize, this means that the greyed-out default values |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
2065 presented there might not be the ones you actually get, since the actual |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
2066 values depend on the style, which may very well be different for |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
2067 different languages. |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2068 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2069 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
|
2070 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
|
2071 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
|
2072 @ref{Styles}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2073 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2074 @vindex c-style-variables-are-local-p |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2075 @vindex style-variables-are-local-p (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2076 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
|
2077 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
|
2078 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
|
2079 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
|
2080 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
|
2081 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
|
2082 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
|
2083 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
|
2084 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
|
2085 without restarting Emacs. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2086 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2087 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2088 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2089 @node Hooks, Styles, Permanent Customization, Customizing Indentation |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2090 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2091 @section Hooks |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2092 @cindex hooks |
25829 | 2093 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2094 | |
2095 @vindex c-mode-common-hook | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2096 @vindex mode-common-hook (c-) |
25829 | 2097 @vindex c-mode-hook |
2098 @vindex c++-mode-hook | |
2099 @vindex objc-mode-hook | |
2100 @vindex java-mode-hook | |
2101 @vindex idl-mode-hook | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2102 @vindex pike-mode-hook |
25829 | 2103 @vindex c-initialization-hook |
2104 @vindex initialization-hook (c-) | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2105 @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
|
2106 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
|
2107 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
|
2108 general hook and one package initialization hook: |
25829 | 2109 |
2110 @itemize @bullet | |
2111 | |
2112 @item | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2113 @code{c-mode-hook} --- For C buffers only. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2114 @item |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2115 @code{c++-mode-hook} --- For C++ buffers only. |
25829 | 2116 @item |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2117 @code{objc-mode-hook} --- For Objective-C buffers only. |
25829 | 2118 @item |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2119 @code{java-mode-hook} --- For Java buffers only. |
25829 | 2120 @item |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2121 @code{idl-mode-hook} --- For CORBA IDL buffers only. |
25829 | 2122 @item |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2123 @code{pike-mode-hook} --- For Pike buffers only. |
25829 | 2124 @item |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2125 @code{c-mode-common-hook} --- Common across all languages. |
25829 | 2126 @item |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2127 @code{c-initialization-hook} --- Hook run only once per Emacs session, |
25829 | 2128 when @ccmode{} is initialized. |
2129 | |
2130 @end itemize | |
2131 | |
2132 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
|
2133 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
|
2134 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
|
2135 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
|
2136 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
|
2137 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
|
2138 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
|
2139 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
|
2140 @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
|
2141 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
|
2142 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
|
2143 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
|
2144 @code{c-default-style}, for details.} |
25829 | 2145 |
2146 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
|
2147 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
|
2148 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
|
2149 @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
|
2150 file. |
25829 | 2151 @example |
2152 @group | |
2153 | |
2154 (defun my-c-mode-common-hook () | |
2155 ;; 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
|
2156 (no-case-fold-search) |
25829 | 2157 ) |
2158 (add-hook 'c-mode-common-hook 'my-c-mode-common-hook) | |
2159 | |
2160 @end group | |
2161 @end example | |
2162 | |
2163 | |
2164 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2165 @node Styles, Advanced Customizations, Hooks, Customizing Indentation |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2166 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2167 @section Styles |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2168 @cindex styles |
25829 | 2169 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2170 | |
2171 Most people only need to edit code formatted in just a few well-defined | |
2172 and consistent styles. For example, their organization might impose a | |
2173 ``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
|
2174 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
|
2175 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
|
2176 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
|
2177 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
|
2178 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
|
2179 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
|
2180 existing code using these styles. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2181 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2182 @cindex style variables |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2183 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
|
2184 variables}. They are handled specially in several ways: |
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 @itemize @bullet |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2187 @item |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2188 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
|
2189 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
|
2190 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
|
2191 non-@code{nil} before @ccmode{} is initialized. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2192 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2193 @vindex c-old-style-variable-behavior |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2194 @vindex old-style-variable-behavior (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2195 @item |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2196 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
|
2197 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
|
2198 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
|
2199 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
|
2200 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
|
2201 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
|
2202 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
|
2203 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
|
2204 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
|
2205 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
|
2206 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2207 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
|
2208 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
|
2209 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
|
2210 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
|
2211 value. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2212 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2213 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
|
2214 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
|
2215 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
|
2216 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
|
2217 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
|
2218 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2219 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
|
2220 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
|
2221 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
|
2222 in version 5.26.}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2223 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2224 @item |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2225 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
|
2226 @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
|
2227 @xref{Built-in Styles}, for details. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2228 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2229 @end itemize |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2230 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2231 The style variables are: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2232 @code{c-basic-offset}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2233 @code{c-comment-only-line-offset}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2234 @code{c-block-comment-prefix}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2235 @code{c-comment-prefix-regexp}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2236 @code{c-cleanup-list}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2237 @code{c-hanging-braces-alist}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2238 @code{c-hanging-colons-alist}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2239 @code{c-hanging-semi&comma-criteria}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2240 @code{c-backslash-column}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2241 @code{c-special-indent-hook}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2242 @code{c-label-minimum-indentation}, and |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2243 @code{c-offsets-alist}. |
25829 | 2244 |
2245 @menu | |
2246 * Built-in Styles:: | |
2247 * Adding Styles:: | |
2248 * File Styles:: | |
2249 @end menu | |
2250 | |
2251 | |
2252 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2253 @node Built-in Styles, Adding Styles, , Styles |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2254 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2255 @subsection Built-in Styles |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2256 @cindex built-in styles |
25829 | 2257 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2258 | |
2259 If you're lucky, one of @ccmode{}'s built-in styles might be just | |
2260 what you're looking for. These include: | |
2261 | |
2262 @itemize @bullet | |
2263 @cindex GNU style | |
2264 @item | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2265 @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
|
2266 for C code in GNU programs. |
25829 | 2267 |
2268 @cindex K&R style | |
2269 @item | |
2270 @code{k&r} --- The classic Kernighan and Ritchie style for C code. | |
2271 | |
2272 @cindex BSD style | |
2273 @item | |
2274 @code{bsd} --- Also known as ``Allman style'' after Eric Allman. | |
2275 | |
2276 @cindex Whitesmith style | |
2277 @item | |
2278 @code{whitesmith} --- Popularized by the examples that came with | |
2279 Whitesmiths C, an early commercial C compiler. | |
2280 | |
2281 @cindex Stroustrup style | |
2282 @item | |
2283 @code{stroustrup} --- The classic Stroustrup style for C++ code. | |
2284 | |
2285 @cindex Ellemtel style | |
2286 @item | |
2287 @code{ellemtel} --- Popular C++ coding standards as defined by | |
2288 ``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
|
2289 Henricson, Ellemtel@footnote{This document is available at |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2290 @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
|
2291 places.}. |
25829 | 2292 |
2293 @cindex Linux style | |
2294 @item | |
2295 @code{linux} --- C coding standard for Linux development. | |
2296 | |
2297 @cindex Python style | |
2298 @item | |
2299 @code{python} --- C coding standard for Python extension | |
2300 modules@footnote{Python is a high level scripting language with a C/C++ | |
2301 foreign function interface. For more information, see | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2302 @uref{http://www.python.org/}.}. |
25829 | 2303 |
2304 @cindex Java style | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2305 @findex java-mode |
25829 | 2306 @item |
2307 @code{java} --- The style for editing Java code. Note that this style is | |
2308 automatically installed when you enter @code{java-mode}. | |
2309 | |
2310 @cindex User style | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2311 @item |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2312 @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
|
2313 @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
|
2314 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
|
2315 @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
|
2316 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
|
2317 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
|
2318 (@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
|
2319 your new style and @code{user} style. |
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 @end itemize |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2322 |
25829 | 2323 @vindex c-default-style |
2324 @vindex default-style (c-) | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2325 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
|
2326 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
|
2327 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
|
2328 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
|
2329 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
|
2330 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
|
2331 effect of these settings. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2332 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2333 @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
|
2334 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
|
2335 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
|
2336 mode. Here are the rules: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2337 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2338 @vindex c-style-alist |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2339 @vindex style-alist (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2340 @vindex c-mode-common-hook |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2341 @vindex mode-common-hook (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2342 @enumerate |
25829 | 2343 @item |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2344 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
|
2345 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
|
2346 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
|
2347 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
|
2348 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
|
2349 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2350 @item |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2351 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
|
2352 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
|
2353 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
|
2354 style does not exist. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2355 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2356 @item |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2357 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
|
2358 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
|
2359 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
|
2360 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2361 @item |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2362 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
|
2363 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2364 @item |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2365 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
|
2366 @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
|
2367 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
|
2368 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
|
2369 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2370 @end enumerate |
25829 | 2371 |
2372 @findex c-set-style | |
2373 @findex set-style (c-) | |
2374 @kindex C-c . | |
2375 If you'd like to experiment with these built-in styles you can simply | |
2376 type the following in a @ccmode{} buffer: | |
2377 @example | |
2378 @group | |
2379 | |
2380 @kbd{C-c . @var{STYLE-NAME} RET} | |
2381 | |
2382 @end group | |
2383 @end example | |
2384 @noindent | |
2385 @kbd{C-c .} runs the command @code{c-set-style}. Note that all style | |
2386 names are case insensitive, even the ones you define. | |
2387 | |
2388 Setting a style in this way does @emph{not} automatically re-indent your | |
2389 file. For commands that you can use to view the effect of your changes, | |
2390 see @ref{Commands}. | |
2391 | |
2392 @vindex c-indentation-style | |
2393 @vindex indentation-style (c-) | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2394 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
|
2395 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
|
2396 @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
|
2397 @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
|
2398 @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
|
2399 @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
|
2400 name, as a string. |
25829 | 2401 |
2402 | |
2403 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2404 @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
|
2405 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2406 @subsection Adding Styles |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2407 @cindex adding styles |
25829 | 2408 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2409 | |
2410 @vindex c-style-alist | |
2411 @vindex style-alist (c-) | |
2412 @findex c-add-style | |
2413 @findex add-style (c-) | |
2414 If none of the built-in styles is appropriate, you'll probably want to | |
2415 add a new @dfn{style definition}. Styles are kept in the | |
2416 @code{c-style-alist} variable, but you should never modify this variable | |
2417 directly. Instead, @ccmode{} provides the function | |
2418 @code{c-add-style} that you can use to easily add new styles or change | |
2419 existing styles. This function takes two arguments, a @var{stylename} | |
2420 string, and an association list @var{description} of style | |
2421 customizations. If @var{stylename} is not already in | |
2422 @code{c-style-alist}, the new style is added, otherwise the style is | |
2423 changed to the new @var{description}. | |
2424 This function also takes an optional third argument, which if | |
2425 non-@code{nil}, automatically applies the new style to the current | |
2426 buffer. | |
2427 | |
2428 @comment TBD: The next paragraph is bogus. I really need to better | |
2429 @comment document adding styles, including setting up inherited styles. | |
2430 | |
2431 The sample @file{.emacs} file provides a concrete example of how a new | |
2432 style can be added and automatically set. @xref{Sample .emacs File}. | |
2433 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2434 |
25829 | 2435 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2436 @node File Styles, , Adding Styles, Styles |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2437 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2438 @subsection File Styles |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2439 @cindex file styles |
25829 | 2440 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2441 | |
2442 @cindex local variables | |
2443 | |
2444 The Emacs manual describes how you can customize certain variables on a | |
2445 per-file basis by including a @dfn{Local Variable} block at the end of | |
2446 the file. So far, you've only seen a functional interface to @ccmode{} | |
2447 customization, which is highly inconvenient for use in a Local Variable | |
2448 block. @ccmode{} provides two variables that make it easier for you to | |
2449 customize your style on a per-file basis. | |
2450 | |
2451 @vindex c-file-style | |
2452 @vindex file-style (c-) | |
2453 @vindex c-file-offsets | |
2454 @vindex file-offsets (c-) | |
2455 | |
2456 The variable @code{c-file-style} can be set to a style name string. | |
2457 When the file is visited, @ccmode{} will automatically set the | |
2458 file's style to this style using @code{c-set-style}. | |
2459 | |
2460 Another variable, @code{c-file-offsets}, takes an association list | |
2461 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
|
2462 visited, @ccmode{} will automatically institute these offsets using |
25829 | 2463 @code{c-set-offset}. |
2464 | |
2465 Note that file style settings (i.e. @code{c-file-style}) are applied | |
2466 before file offset settings (i.e. @code{c-file-offsets}). Also, if | |
2467 either of these are set in a file's local variable section, all the | |
2468 style variable values are made local to that buffer. | |
2469 | |
2470 | |
2471 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2472 @node Advanced Customizations, , Styles, Customizing Indentation |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2473 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2474 @section Advanced Customizations |
25829 | 2475 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2476 | |
2477 @vindex c-style-alist | |
2478 @vindex style-alist (c-) | |
2479 For most users, @ccmode{} will support their coding styles with | |
2480 very little need for more advanced customizations. Usually, one of the | |
2481 standard styles defined in @code{c-style-alist} will do the trick. At | |
2482 most, perhaps one of the syntactic symbol offsets will need to be | |
2483 tweaked slightly, or maybe @code{c-basic-offset} will need to be | |
2484 changed. However, some styles require a more flexible framework for | |
2485 customization, and one of the real strengths of @ccmode{} is that | |
2486 the syntactic analysis model provides just such a framework. This allows | |
2487 you to implement custom indentation calculations for situations not | |
2488 handled by the mode directly. | |
2489 | |
2490 @menu | |
2491 * Custom Indentation Functions:: | |
2492 * Custom Brace and Colon Hanging:: | |
2493 * Customizing Semi-colons and Commas:: | |
2494 * Other Special Indentations:: | |
2495 @end menu | |
2496 | |
2497 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2498 @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
|
2499 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2500 @subsection Custom Indentation Functions |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2501 @cindex custom indentation functions |
25829 | 2502 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2503 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2504 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
|
2505 indentation functions, and associating them with specific syntactic |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2506 symbols (@pxref{Syntactic Symbols}). @ccmode{} itself uses indentation |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2507 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
|
2508 lining up C++ stream operator blocks: |
25829 | 2509 @example |
2510 @group | |
2511 | |
2512 1: void main(int argc, char**) | |
2513 2: @{ | |
2514 3: cout << "There were " | |
2515 4: << argc | |
2516 5: << "arguments passed to the program" | |
2517 6: << endl; | |
2518 7: @} | |
2519 | |
2520 @end group | |
2521 @end example | |
2522 | |
2523 In this example, lines 4 through 6 are assigned the @code{stream-op} | |
2524 syntactic symbol. Here, @code{stream-op} has an offset of @code{+}, and | |
2525 with a @code{c-basic-offset} of 2, you can see that lines 4 through 6 | |
2526 are simply indented two spaces to the right of line 3. But perhaps we'd | |
2527 like @ccmode{} to be a little more intelligent so that it aligns | |
2528 all the @samp{<<} symbols in lines 3 through 6. To do this, we have | |
2529 to write a custom indentation function which finds the column of first | |
2530 stream operator on the first line of the statement. Here is sample | |
2531 lisp code implementing this: | |
2532 @example | |
2533 @group | |
2534 | |
2535 (defun c-lineup-streamop (langelem) | |
2536 ;; lineup stream operators | |
2537 (save-excursion | |
2538 (let* ((relpos (cdr langelem)) | |
2539 (curcol (progn (goto-char relpos) | |
2540 (current-column)))) | |
2541 (re-search-forward "<<\\|>>" (c-point 'eol) 'move) | |
2542 (goto-char (match-beginning 0)) | |
2543 (- (current-column) curcol)))) | |
2544 | |
2545 @end group | |
2546 @end example | |
2547 @noindent | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2548 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
|
2549 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
|
2550 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
|
2551 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
|
2552 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
|
2553 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
|
2554 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
|
2555 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
|
2556 added in twice. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2557 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2558 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
|
2559 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
|
2560 expression (@pxref{Customizing Indentation}), that will cause @ccmode{} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2561 to go on and check the next entry in the list. |
25829 | 2562 |
2563 @cindex stream-op syntactic symbol | |
2564 @findex c-lineup-streamop | |
2565 @findex lineup-streamop (c-) | |
2566 Now, to associate the function @code{c-lineup-streamop} with the | |
2567 @code{stream-op} syntactic symbol, we can add something like the | |
2568 following to our @code{c++-mode-hook}@footnote{It probably makes more | |
2569 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
|
2570 since stream operators are only relevant for C++.}: |
25829 | 2571 @example |
2572 | |
2573 (c-set-offset 'stream-op 'c-lineup-streamop) | |
2574 | |
2575 @end example | |
2576 | |
2577 Now the function looks like this after re-indenting (using @kbd{C-c | |
2578 C-q}): | |
2579 @example | |
2580 @group | |
2581 | |
2582 1: void main(int argc, char**) | |
2583 2: @{ | |
2584 3: cout << "There were " | |
2585 4: << argc | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2586 5: << " arguments passed to the program" |
25829 | 2587 6: << endl; |
2588 7: @} | |
2589 | |
2590 @end group | |
2591 @end example | |
2592 | |
2593 Custom indentation functions can be as simple or as complex as you like, | |
2594 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
|
2595 a custom indentation function associated with it. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2596 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2597 @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
|
2598 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
|
2599 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
|
2600 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
|
2601 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
|
2602 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
|
2603 |
25829 | 2604 |
2605 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2606 @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
|
2607 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2608 @subsection Custom Brace and Colon Hanging |
25829 | 2609 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2610 | |
2611 @vindex c-hanging-braces-alist | |
2612 @vindex hanging-braces-alist (c-) | |
2613 Syntactic symbols aren't the only place where you can customize | |
2614 @ccmode{} with the lisp equivalent of callback functions. Brace | |
2615 ``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
|
2616 syntactic symbols on the @code{c-hanging-braces-alist} style variable. |
25829 | 2617 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
|
2618 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
|
2619 (@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
|
2620 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
|
2621 is entered. |
25829 | 2622 |
2623 @cindex customizing brace hanging | |
2624 These @var{ACTION} functions are called with two arguments: the | |
2625 syntactic symbol for the brace, and the buffer position at which the | |
2626 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
|
2627 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
|
2628 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
|
2629 normal brace hanging semantics. |
25829 | 2630 |
2631 As an example, @ccmode{} itself uses this feature to dynamically | |
2632 determine the hanginess of braces which close ``do-while'' | |
2633 constructs: | |
2634 @example | |
2635 @group | |
2636 | |
2637 void do_list( int count, char** atleast_one_string ) | |
2638 @{ | |
2639 int i=0; | |
2640 do @{ | |
2641 handle_string( atleast_one_string[i] ); | |
2642 i++; | |
2643 @} while( i < count ); | |
2644 @} | |
2645 | |
2646 @end group | |
2647 @end example | |
2648 | |
2649 @findex c-snug-do-while | |
2650 @findex snug-do-while (c-) | |
2651 @ccmode{} assigns the @code{block-close} syntactic symbol to the | |
2652 brace that closes the @code{do} construct, and normally we'd like the | |
2653 line that follows a @code{block-close} brace to begin on a separate | |
2654 line. However, with ``do-while'' constructs, we want the | |
2655 @code{while} clause to follow the closing brace. To do this, we | |
2656 associate the @code{block-close} symbol with the @var{ACTION} function | |
2657 @code{c-snug-do-while}: | |
2658 @example | |
2659 | |
2660 (defun c-snug-do-while (syntax pos) | |
2661 "Dynamically calculate brace hanginess for do-while statements. | |
2662 Using this function, `while' clauses that end a `do-while' block will | |
2663 remain on the same line as the brace that closes that block. | |
2664 | |
2665 See `c-hanging-braces-alist' for how to utilize this function as an | |
2666 ACTION associated with `block-close' syntax." | |
2667 (save-excursion | |
2668 (let (langelem) | |
2669 (if (and (eq syntax 'block-close) | |
2670 (setq langelem (assq 'block-close c-syntactic-context)) | |
2671 (progn (goto-char (cdr langelem)) | |
2672 (if (= (following-char) ?@{) | |
2673 (forward-sexp -1)) | |
2674 (looking-at "\\<do\\>[^_]"))) | |
2675 '(before) | |
2676 '(before after))))) | |
2677 | |
2678 @end example | |
2679 | |
2680 This function simply looks to see if the brace closes a ``do-while'' | |
2681 clause and if so, returns the list @samp{(before)} indicating | |
2682 that a newline should be inserted before the brace, but not after it. | |
2683 In all other cases, it returns the list @samp{(before after)} so | |
2684 that the brace appears on a line by itself. | |
2685 | |
2686 @vindex c-syntactic-context | |
2687 @vindex syntactic-context (c-) | |
2688 During the call to the brace hanging @var{ACTION} function, the variable | |
2689 @code{c-syntactic-context} is bound to the full syntactic analysis list. | |
2690 | |
2691 @cindex customizing colon hanging | |
2692 @vindex c-hanging-colon-alist | |
2693 @vindex hanging-colon-alist (c-) | |
2694 Note that for symmetry, colon hanginess should be customizable by | |
2695 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
|
2696 @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
|
2697 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
|
2698 |
25829 | 2699 |
2700 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2701 @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
|
2702 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2703 @subsection Customizing Semi-colons and Commas |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2704 @cindex customizing semi-colons and commas |
25829 | 2705 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2706 | |
2707 @vindex c-hanging-semi&comma-criteria | |
2708 @vindex hanging-semi&comma-criteria (c-) | |
2709 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
|
2710 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
|
2711 Modes}). This is controlled by the style variable |
25829 | 2712 @code{c-hanging-semi&comma-criteria}, which contains a list of functions |
2713 that are called in the order they appear. Each function is called with | |
2714 zero arguments, and is expected to return one of the following values: | |
2715 | |
2716 @itemize @bullet | |
2717 @item | |
2718 non-@code{nil} --- A newline is inserted, and no more functions from the | |
2719 list are called. | |
2720 | |
2721 @item | |
2722 @code{stop} --- No more functions from the list are called, but no | |
2723 newline is inserted. | |
2724 | |
2725 @item | |
2726 @code{nil} --- No determination is made, and the next function in the | |
2727 list is called. | |
2728 | |
2729 @end itemize | |
2730 | |
2731 If every function in the list is called without a determination being | |
2732 made, then no newline is added. The default value for this variable is a | |
2733 list containing a single function which inserts newlines only after | |
2734 semi-colons which do not appear inside parenthesis lists (i.e. those | |
2735 that separate @code{for}-clause statements). | |
2736 | |
2737 @findex c-semi&comma-no-newlines-before-nonblanks | |
2738 @findex semi&comma-no-newlines-before-nonblanks (c-) | |
2739 Here's an example of a criteria function, provided by @ccmode{}, that | |
2740 will prevent newlines from being inserted after semicolons when there is | |
2741 a non-blank following line. Otherwise, it makes no determination. To | |
2742 use, add this to the front of the @code{c-hanging-semi&comma-criteria} | |
2743 list. | |
2744 | |
2745 @example | |
2746 @group | |
2747 | |
2748 (defun c-semi&comma-no-newlines-before-nonblanks () | |
2749 (save-excursion | |
2750 (if (and (eq last-command-char ?\;) | |
2751 (zerop (forward-line 1)) | |
2752 (not (looking-at "^[ \t]*$"))) | |
2753 'stop | |
2754 nil))) | |
2755 | |
2756 @end group | |
2757 @end example | |
2758 | |
2759 @findex c-semi&comma-inside-parenlist | |
2760 @findex c-semi&comma-no-newlines-for-oneline-inliners | |
2761 @findex semi&comma-inside-parenlist (c-) | |
2762 @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
|
2763 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
|
2764 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
|
2765 statements. In addition to |
25829 | 2766 @code{c-semi&comma-no-newlines-before-nonblanks} described above, |
2767 @ccmode{} also comes with the criteria function | |
2768 @code{c-semi&comma-no-newlines-for-oneline-inliners}, which suppresses | |
2769 newlines after semicolons inside one-line inline method definitions | |
2770 (i.e. in C++ or Java). | |
2771 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2772 |
25829 | 2773 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2774 @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
|
2775 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2776 @subsection Other Special Indentations |
25829 | 2777 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2778 | |
2779 @vindex c-label-minimum-indentation | |
2780 @vindex label-minimum-indentation (c-) | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2781 In @samp{gnu} style (@pxref{Built-in Styles}), a minimum indentation |
25829 | 2782 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
|
2783 indentation is controlled by the style variable |
25829 | 2784 @code{c-label-minimum-indentation}. The default value for this variable |
2785 is 1. | |
2786 | |
2787 @vindex c-special-indent-hook | |
2788 @vindex special-indent-hook (c-) | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2789 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
|
2790 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
|
2791 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
|
2792 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
|
2793 dictates, such as adding extra indentation to constructors or destructor |
25829 | 2794 declarations in a class definition, etc. Note however, that you should |
2795 not change point or mark inside your @code{c-special-indent-hook} | |
2796 functions (i.e. you'll probably want to wrap your function in a | |
2797 @code{save-excursion}). | |
2798 | |
2799 Setting @code{c-special-indent-hook} in your style definition is handled | |
2800 slightly differently than other variables. In your style definition, | |
2801 you should set the value for | |
2802 @code{c-special-indent-hook} to a function or list of functions, which | |
2803 will be appended to @code{c-special-indent-hook} using @code{add-hook}. | |
2804 That way, the current setting for the buffer local value of | |
2805 @code{c-special-indent-hook} won't be overridden. | |
2806 | |
2807 @kindex M-; | |
2808 @findex indent-for-comment | |
2809 @vindex c-indent-comments-syntactically-p | |
2810 @vindex indent-comments-syntactically-p (c-) | |
2811 @vindex comment-column | |
2812 Normally, the standard Emacs command @kbd{M-;} | |
2813 (@code{indent-for-comment}) will indent comment only lines to | |
2814 @code{comment-column}. Some users however, prefer that @kbd{M-;} act | |
2815 just like @kbd{TAB} for purposes of indenting comment-only lines; | |
2816 i.e. they want the comments to always indent as they would for normal | |
2817 code, regardless of whether @kbd{TAB} or @kbd{M-;} were used. This | |
2818 behavior is controlled by the variable | |
2819 @code{c-indent-comments-syntactically-p}. When @code{nil} (the | |
2820 default), @kbd{M-;} indents comment-only lines to @code{comment-column}, | |
2821 otherwise, they are indented just as they would be if @kbd{TAB} were | |
2822 typed. | |
2823 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2824 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
|
2825 @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
|
2826 start at @code{comment-column}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2827 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2828 |
25829 | 2829 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2830 @node Syntactic Symbols, Indentation Functions, Customizing Indentation, Top |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2831 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2832 @chapter Syntactic Symbols |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2833 @cindex syntactic symbols |
25829 | 2834 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2835 | |
2836 @vindex c-offsets-alist | |
2837 @vindex offsets-alist (c-) | |
2838 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
|
2839 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
|
2840 description. More detailed descriptions follow. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2841 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2842 @table @code |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2843 @item string |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2844 Inside a multi-line string. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2845 @item c |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2846 Inside a multi-line C style block comment. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2847 @item defun-open |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2848 Brace that opens a top-level function definition. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2849 @item defun-close |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2850 Brace that closes a top-level function definition. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2851 @item defun-block-intro |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2852 The first line in a top-level defun. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2853 @item class-open |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2854 Brace that opens a class definition. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2855 @item class-close |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2856 Brace that closes a class definition. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2857 @item inline-open |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2858 Brace that opens an in-class inline method. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2859 @item inline-close |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2860 Brace that closes an in-class inline method. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2861 @item func-decl-cont |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2862 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
|
2863 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
|
2864 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
|
2865 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
|
2866 here. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2867 @item knr-argdecl-intro |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2868 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
|
2869 @item knr-argdecl |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2870 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
|
2871 @item topmost-intro |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2872 The first line in a ``topmost'' definition. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2873 @item topmost-intro-cont |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2874 Topmost definition continuation lines. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2875 @item member-init-intro |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2876 First line in a member initialization list. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2877 @item member-init-cont |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2878 Subsequent member initialization list lines. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2879 @item inher-intro |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2880 First line of a multiple inheritance list. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2881 @item inher-cont |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2882 Subsequent multiple inheritance lines. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2883 @item block-open |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2884 Statement block open brace. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2885 @item block-close |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2886 Statement block close brace. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2887 @item brace-list-open |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2888 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
|
2889 @item brace-list-close |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2890 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
|
2891 @item brace-list-intro |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2892 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
|
2893 @item brace-list-entry |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2894 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
|
2895 @item brace-entry-open |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2896 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
|
2897 with an open brace. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2898 @item statement |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2899 A statement. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2900 @item statement-cont |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2901 A continuation of a statement. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2902 @item statement-block-intro |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2903 The first line in a new statement block. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2904 @item statement-case-intro |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2905 The first line in a case block. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2906 @item statement-case-open |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2907 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
|
2908 @item substatement |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2909 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
|
2910 @item substatement-open |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2911 The brace that opens a substatement block. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2912 @item case-label |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2913 A @code{case} or @code{default} label. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2914 @item access-label |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2915 C++ access control label. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2916 @item label |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2917 Any non-special C label. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2918 @item do-while-closure |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2919 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
|
2920 @item else-clause |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2921 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
|
2922 @item catch-clause |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2923 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
|
2924 @code{try}-@code{catch} construct. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2925 @item comment-intro |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2926 A line containing only a comment introduction. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2927 @item arglist-intro |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2928 The first line in an argument list. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2929 @item arglist-cont |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2930 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
|
2931 as the the arglist opening paren. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2932 @item arglist-cont-nonempty |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2933 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
|
2934 same line as the arglist opening paren. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2935 @item arglist-close |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2936 The solo close paren of an argument list. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2937 @item stream-op |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2938 Lines continuing a stream operator (C++ only). |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2939 @item inclass |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2940 The line is nested inside a class definition. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2941 @item cpp-macro |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2942 The start of a C preprocessor macro definition. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2943 @item cpp-macro-cont |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2944 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
|
2945 @item friend |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2946 A C++ friend declaration. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2947 @item objc-method-intro |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2948 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
|
2949 @item objc-method-args-cont |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2950 Lines continuing an Objective-C method. definition |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2951 @item objc-method-call-cont |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2952 Lines continuing an Objective-C method call. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2953 @item extern-lang-open |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2954 Brace that opens an external language block. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2955 @item extern-lang-close |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2956 Brace that closes an external language block. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2957 @item inextern-lang |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2958 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
|
2959 language blocks (e.g. @code{extern "C" @{}). |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2960 @item namespace-open |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2961 Brace that opens a C++ namespace block. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2962 @item namespace-close |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2963 Brace that closes a C++ namespace block. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2964 @item innamespace |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2965 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
|
2966 namespace blocks. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2967 @item template-args-cont |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2968 C++ template argument list continuations. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2969 @item inlambda |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2970 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
|
2971 (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
|
2972 @item lambda-intro-cont |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2973 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
|
2974 @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
|
2975 @item inexpr-statement |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2976 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
|
2977 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
|
2978 statement block as an argument in Pike. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2979 @item inexpr-class |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2980 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
|
2981 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
|
2982 Java. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
2983 @end table |
25829 | 2984 |
2985 @cindex -open syntactic symbols | |
2986 @cindex -close syntactic symbols | |
2987 Most syntactic symbol names follow a general naming convention. When a | |
2988 line begins with an open or close brace, the syntactic symbol will | |
2989 contain the suffix @code{-open} or @code{-close} respectively. | |
2990 | |
2991 @cindex -intro syntactic symbols | |
2992 @cindex -cont syntactic symbols | |
2993 @cindex -block-intro syntactic symbols | |
2994 Usually, a distinction is made between the first line that introduces a | |
2995 construct and lines that continue a construct, and the syntactic symbols | |
2996 that represent these lines will contain the suffix @code{-intro} or | |
2997 @code{-cont} respectively. As a sub-classification of this scheme, a | |
2998 line which is the first of a particular brace block construct will | |
2999 contain the suffix @code{-block-intro}. | |
3000 | |
3001 Let's look at some examples to understand how this works. Remember that | |
3002 you can check the syntax of any line by using @kbd{C-c C-s}. | |
3003 @example | |
3004 @group | |
3005 | |
3006 1: void | |
3007 2: swap( int& a, int& b ) | |
3008 3: @{ | |
3009 4: int tmp = a; | |
3010 5: a = b; | |
3011 6: b = tmp; | |
3012 7: int ignored = | |
3013 8: a + b; | |
3014 9: @} | |
3015 | |
3016 @end group | |
3017 @end example | |
3018 | |
3019 @cindex topmost-intro syntactic symbol | |
3020 @cindex topmost-intro-cont syntactic symbol | |
3021 @cindex defun-open syntactic symbol | |
3022 @cindex defun-close syntactic symbol | |
3023 @cindex defun-block-intro syntactic symbol | |
3024 Line 1 shows a @code{topmost-intro} since it is the first line that | |
3025 introduces a top-level construct. Line 2 is a continuation of the | |
3026 top-level construct introduction so it has the syntax | |
3027 @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
|
3028 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
|
3029 corresponding |
25829 | 3030 @code{defun-close} since it contains the brace that closes the top-level |
3031 function definition. Line 4 is a @code{defun-block-intro}, i.e. it is | |
3032 the first line of a brace-block, enclosed in a | |
3033 top-level function definition. | |
3034 | |
3035 @cindex statement syntactic symbol | |
3036 @cindex statement-cont syntactic symbol | |
3037 Lines 5, 6, and 7 are all given @code{statement} syntax since there | |
3038 isn't much special about them. Note however that line 8 is given | |
3039 @code{statement-cont} syntax since it continues the statement begun | |
3040 on the previous line. | |
3041 | |
3042 Here's another example, which illustrates some C++ class syntactic | |
3043 symbols: | |
3044 @example | |
3045 @group | |
3046 | |
3047 1: class Bass | |
3048 2: : public Guitar, | |
3049 3: public Amplifiable | |
3050 4: @{ | |
3051 5: public: | |
3052 6: Bass() | |
3053 7: : eString( new BassString( 0.105 )), | |
3054 8: aString( new BassString( 0.085 )), | |
3055 9: dString( new BassString( 0.065 )), | |
3056 10: gString( new BassString( 0.045 )) | |
3057 11: @{ | |
3058 12: eString.tune( 'E' ); | |
3059 13: aString.tune( 'A' ); | |
3060 14: dString.tune( 'D' ); | |
3061 15: gString.tune( 'G' ); | |
3062 16: @} | |
3063 17: friend class Luthier; | |
3064 18: @} | |
3065 | |
3066 @end group | |
3067 @end example | |
3068 | |
3069 @cindex class-open syntactic symbol | |
3070 @cindex class-close syntactic symbol | |
3071 As in the previous example, line 1 has the @code{topmost-intro} syntax. | |
3072 Here however, the brace that opens a C++ class definition on line 4 is | |
3073 assigned the @code{class-open} syntax. Note that in C++, classes, | |
3074 structs, and unions are essentially equivalent syntactically (and are | |
3075 very similar semantically), so replacing the @code{class} keyword in the | |
3076 example above with @code{struct} or @code{union} would still result in a | |
3077 syntax of @code{class-open} for line 4 @footnote{This is the case even | |
3078 for C and Objective-C. For consistency, structs in all supported | |
3079 languages are syntactically equivalent to classes. Note however that | |
3080 the keyword @code{class} is meaningless in C and Objective-C.}. | |
3081 Similarly, line 18 is assigned @code{class-close} syntax. | |
3082 | |
3083 @cindex inher-intro syntactic symbol | |
3084 @cindex inher-cont syntactic symbol | |
3085 Line 2 introduces the inheritance list for the class so it is assigned | |
3086 the @code{inher-intro} syntax, and line 3, which continues the | |
3087 inheritance list is given @code{inher-cont} syntax. | |
3088 | |
3089 @cindex access-label syntactic symbol | |
3090 @cindex inclass syntactic symbol | |
3091 Hitting @kbd{C-c C-s} on line 5 shows the following analysis: | |
3092 | |
3093 @example | |
3094 @group | |
3095 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3096 @code{((inclass . 58) (access-label . 67))} |
25829 | 3097 |
3098 @end group | |
3099 @end example | |
3100 | |
3101 @noindent | |
3102 The primary syntactic symbol for this line is @code{access-label} as | |
3103 this a label keyword that specifies access protection in C++. However, | |
3104 because this line is also a top-level construct inside a class | |
3105 definition, the analysis actually shows two syntactic symbols. The | |
3106 other syntactic symbol assigned to this line is @code{inclass}. | |
3107 Similarly, line 6 is given both @code{inclass} and @code{topmost-intro} | |
3108 syntax: | |
3109 | |
3110 @example | |
3111 @group | |
3112 | |
3113 @code{((inclass . 58) (topmost-intro . 60))} | |
3114 | |
3115 @end group | |
3116 @end example | |
3117 | |
3118 @cindex member-init-intro syntactic symbol | |
3119 @cindex member-init-cont syntactic symbol | |
3120 Line 7 introduces a C++ member initialization list and as such is given | |
3121 @code{member-init-intro} syntax. Note that in this case it is | |
3122 @emph{not} assigned @code{inclass} since this is not considered a | |
3123 top-level construct. Lines 8 through 10 are all assigned | |
3124 @code{member-init-cont} since they continue the member initialization | |
3125 list started on line 7. | |
3126 | |
3127 @cindex in-class inline methods | |
3128 @cindex inline-open syntactic symbol | |
3129 @cindex inline-close syntactic symbol | |
3130 Line 11's analysis is a bit more complicated: | |
3131 | |
3132 @example | |
3133 @group | |
3134 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3135 @code{((inclass . 58) (inline-open))} |
25829 | 3136 |
3137 @end group | |
3138 @end example | |
3139 | |
3140 This line is assigned a syntax of both @code{inline-open} and | |
3141 @code{inclass} because it opens an @dfn{in-class} C++ inline method | |
3142 definition. This is distinct from, but related to, the C++ notion of an | |
3143 inline function in that its definition occurs inside an enclosing class | |
3144 definition, which in C++ implies that the function should be inlined. | |
3145 If though, the definition of the @code{Bass} constructor appeared | |
3146 outside the class definition, the construct would be given the | |
3147 @code{defun-open} syntax, even if the keyword @code{inline} appeared | |
3148 before the method name, as in: | |
3149 @example | |
3150 @group | |
3151 | |
3152 class Bass | |
3153 : public Guitar, | |
3154 public Amplifiable | |
3155 @{ | |
3156 public: | |
3157 Bass(); | |
3158 @} | |
3159 | |
3160 inline | |
3161 Bass::Bass() | |
3162 : eString( new BassString( 0.105 )), | |
3163 aString( new BassString( 0.085 )), | |
3164 dString( new BassString( 0.065 )), | |
3165 gString( new BassString( 0.045 )) | |
3166 @{ | |
3167 eString.tune( 'E' ); | |
3168 aString.tune( 'A' ); | |
3169 dString.tune( 'D' ); | |
3170 gString.tune( 'G' ); | |
3171 @} | |
3172 | |
3173 @end group | |
3174 @end example | |
3175 | |
3176 @cindex friend syntactic symbol | |
3177 Returning to the previous example, line 16 is given @code{inline-close} | |
3178 syntax, while line 12 is given @code{defun-block-open} syntax, and lines | |
3179 13 through 15 are all given @code{statement} syntax. Line 17 is | |
3180 interesting in that its syntactic analysis list contains three | |
3181 elements: | |
3182 | |
3183 @example | |
3184 | |
3185 @code{((friend) (inclass . 58) (topmost-intro . 380))} | |
3186 | |
3187 @end example | |
3188 | |
3189 The @code{friend} syntactic symbol is a modifier that typically does not | |
3190 have a relative buffer position. | |
3191 | |
3192 Template definitions introduce yet another syntactic symbol: | |
3193 | |
3194 @example | |
3195 @group | |
3196 | |
3197 1: ThingManager <int, | |
3198 2: Framework::Callback *, | |
3199 3: Mutex> framework_callbacks; | |
3200 | |
3201 @end group | |
3202 @end example | |
3203 | |
3204 Here, line 1 is analyzed as a @code{topmost-intro}, but lines 2 and 3 | |
3205 are both analyzed as @code{template-args-cont} lines. | |
3206 | |
3207 Here is another (totally contrived) example which illustrates how syntax | |
3208 is assigned to various conditional constructs: | |
3209 @example | |
3210 @group | |
3211 | |
3212 1: void spam( int index ) | |
3213 2: @{ | |
3214 3: for( int i=0; i<index; i++ ) | |
3215 4: @{ | |
3216 5: if( i == 10 ) | |
3217 6: @{ | |
3218 7: do_something_special(); | |
3219 8: @} | |
3220 9: else | |
3221 10: do_something( i ); | |
3222 11: @} | |
3223 12: do @{ | |
3224 13: another_thing( i-- ); | |
3225 14: @} | |
3226 15: while( i > 0 ); | |
3227 16: @} | |
3228 | |
3229 | |
3230 @end group | |
3231 @end example | |
3232 | |
3233 @noindent | |
3234 Only the lines that illustrate new syntactic symbols will be discussed. | |
3235 | |
3236 @cindex substatement-open syntactic symbol | |
3237 @cindex substatement-block-intro syntactic symbol | |
3238 @cindex block-close syntactic symbol | |
3239 Line 4 has a brace which opens a conditional's substatement block. It | |
3240 is thus assigned @code{substatement-open} syntax, and since line 5 is | |
3241 the first line in the substatement block, it is assigned | |
3242 @code{substatement-block-intro} syntax. Lines 6 and 7 are assigned | |
3243 similar syntax. Line 8 contains the brace that closes the inner | |
3244 substatement block. It is given the syntax @code{block-close}, | |
3245 as are lines 11 and 14. | |
3246 | |
3247 @cindex else-clause syntactic symbol | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3248 @cindex catch-clause syntactic symbol |
25829 | 3249 Line 9 is a little different --- since it contains the keyword |
3250 @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
|
3251 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
|
3252 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
|
3253 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
|
3254 marked with @code{catch-clause}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3255 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3256 @cindex substatement syntactic symbol |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3257 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
|
3258 conditional introducing keyword @footnote{The list of conditional |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3259 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
|
3260 @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
|
3261 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
|
3262 @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
|
3263 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
|
3264 line 10 is assigned the @code{substatement} syntax. |
25829 | 3265 |
3266 @cindex do-while-closure syntactic symbol | |
3267 One other difference is seen on line 15. The @code{while} construct | |
3268 that closes a @code{do} conditional is given the special syntax | |
3269 @code{do-while-closure} if it appears on a line by itself. Note that if | |
3270 the @code{while} appeared on the same line as the preceding close brace, | |
3271 that line would have been assigned @code{block-close} syntax instead. | |
3272 | |
3273 Switch statements have their own set of syntactic symbols. Here's an | |
3274 example: | |
3275 @example | |
3276 @group | |
3277 | |
3278 1: void spam( enum Ingredient i ) | |
3279 2: @{ | |
3280 3: switch( i ) @{ | |
3281 4: case Ham: | |
3282 5: be_a_pig(); | |
3283 6: break; | |
3284 7: case Salt: | |
3285 8: drink_some_water(); | |
3286 9: break; | |
3287 10: default: | |
3288 11: @{ | |
3289 12: what_is_it(); | |
3290 13: break; | |
3291 14: @} | |
3292 15: @} | |
3293 14: @} | |
3294 | |
3295 @end group | |
3296 @end example | |
3297 | |
3298 @cindex case-label syntactic symbol | |
3299 @cindex statement-case-intro syntactic symbol | |
3300 @cindex statement-case-open syntactic symbol | |
3301 Here, lines 4, 7, and 10 are all assigned @code{case-label} syntax, | |
3302 while lines 5 and 8 are assigned @code{statement-case-intro}. Line 11 | |
3303 is treated slightly differently since it contains a brace that opens a | |
3304 block --- it is given @code{statement-case-open} syntax. | |
3305 | |
3306 @cindex brace lists | |
3307 There are a set of syntactic symbols that are used to recognize | |
3308 constructs inside of brace lists. A brace list is defined as an | |
3309 @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
|
3310 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
|
3311 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
|
3312 brace lists too. An example: |
25829 | 3313 @example |
3314 @group | |
3315 | |
3316 1: static char* ingredients[] = | |
3317 2: @{ | |
3318 3: "Ham", | |
3319 4: "Salt", | |
3320 5: NULL | |
3321 6: @} | |
3322 | |
3323 @end group | |
3324 @end example | |
3325 | |
3326 @cindex brace-list-open syntactic symbol | |
3327 @cindex brace-list-intro syntactic symbol | |
3328 @cindex brace-list-close syntactic symbol | |
3329 @cindex brace-list-entry syntactic symbol | |
3330 Following convention, line 2 in this example is assigned | |
3331 @code{brace-list-open} syntax, and line 3 is assigned | |
3332 @code{brace-list-intro} syntax. Likewise, line 6 is assigned | |
3333 @code{brace-list-close} syntax. Lines 4 and 5 however, are assigned | |
3334 @code{brace-list-entry} syntax, as would all subsequent lines in this | |
3335 initializer list. | |
3336 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3337 @cindex brace-entry-open syntactic symbol |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3338 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
|
3339 example: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3340 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3341 @group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3342 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3343 1: struct intpairs[] = |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3344 2: @{ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3345 3: @{ 1, 2 @}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3346 4: @{ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3347 5: 3, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3348 6: 4 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3349 7: @} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3350 8: @{ 1, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3351 9: 2 @}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3352 10: @{ 3, 4 @} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3353 11: @} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3354 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3355 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3356 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3357 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3358 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
|
3359 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
|
3360 @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
|
3361 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
|
3362 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
|
3363 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
|
3364 line 10. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3365 |
25829 | 3366 External language definition blocks also have their own syntactic |
3367 symbols. In this example: | |
3368 @example | |
3369 @group | |
3370 | |
3371 1: extern "C" | |
3372 2: @{ | |
3373 3: int thing_one( int ); | |
3374 4: int thing_two( double ); | |
3375 5: @} | |
3376 | |
3377 @end group | |
3378 @end example | |
3379 | |
3380 @cindex extern-lang-open syntactic symbol | |
3381 @cindex extern-lang-close syntactic symbol | |
3382 @cindex inextern-lang syntactic symbol | |
3383 @cindex inclass syntactic symbol | |
3384 @noindent | |
3385 line 2 is given the @code{extern-lang-open} syntax, while line 5 is given | |
3386 the @code{extern-lang-close} syntax. The analysis for line 3 yields: | |
3387 @code{((inextern-lang) (topmost-intro . 14))}, where | |
3388 @code{inextern-lang} is a modifier similar in purpose to @code{inclass}. | |
3389 | |
3390 Similarly, C++ namespace constructs have their own associated syntactic | |
3391 symbols. In this example: | |
3392 @example | |
3393 @group | |
3394 | |
3395 1: namespace foo | |
3396 2: @{ | |
3397 3: void xxx() @{@} | |
3398 4: @} | |
3399 | |
3400 @end group | |
3401 @end example | |
3402 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3403 @cindex namespace-open syntactic symbol |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3404 @cindex namespace-close syntactic symbol |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3405 @cindex innamespace syntactic symbol |
25829 | 3406 @noindent |
3407 line 2 is given the @code{namespace-open} syntax, while line 4 is given | |
3408 the @code{namespace-close} syntax. The analysis for line 3 yields: | |
3409 @code{((innamespace) (topmost-intro . 17))}, where @code{innamespace} is | |
3410 a modifier similar in purpose to @code{inextern-lang} and @code{inclass}. | |
3411 | |
3412 A number of syntactic symbols are associated with parenthesis lists, | |
3413 a.k.a argument lists, as found in function declarations and function | |
3414 calls. This example illustrates these: | |
3415 @example | |
3416 @group | |
3417 | |
3418 1: void a_function( int line1, | |
3419 2: int line2 ); | |
3420 3: | |
3421 4: void a_longer_function( | |
3422 5: int line1, | |
3423 6: int line2 | |
3424 7: ); | |
3425 8: | |
3426 9: void call_them( int line1, int line2 ) | |
3427 10: @{ | |
3428 11: a_function( | |
3429 12: line1, | |
3430 13: line2 | |
3431 14: ); | |
3432 15: | |
3433 16: a_longer_function( line1, | |
3434 17: line2 ); | |
3435 18: @} | |
3436 | |
3437 @end group | |
3438 @end example | |
3439 | |
3440 @cindex arglist-intro syntactic symbol | |
3441 @cindex arglist-close syntactic symbol | |
3442 Lines 5 and 12 are assigned @code{arglist-intro} syntax since they are | |
3443 the first line following the open parenthesis, and lines 7 and 14 are | |
3444 assigned @code{arglist-close} syntax since they contain the parenthesis | |
3445 that closes the argument list. | |
3446 | |
3447 @cindex arglist-cont-nonempty syntactic symbol | |
3448 @cindex arglist-cont syntactic symbol | |
3449 Lines that continue argument lists can be assigned one of two syntactic | |
3450 symbols. For example, Lines 2 and 17 | |
3451 are assigned @code{arglist-cont-nonempty} syntax. What this means | |
3452 is that they continue an argument list, but that the line containing the | |
3453 parenthesis that opens the list is @emph{not empty} following the open | |
3454 parenthesis. Contrast this against lines 6 and 13 which are assigned | |
3455 @code{arglist-cont} syntax. This is because the parenthesis that opens | |
3456 their argument lists is the last character on that line. | |
3457 | |
3458 Note that there is no @code{arglist-open} syntax. This is because any | |
3459 parenthesis that opens an argument list, appearing on a separate line, | |
3460 is assigned the @code{statement-cont} syntax instead. | |
3461 | |
3462 A few miscellaneous syntactic symbols that haven't been previously | |
3463 covered are illustrated by this C++ example: | |
3464 @example | |
3465 @group | |
3466 | |
3467 1: void Bass::play( int volume ) | |
3468 2: const | |
3469 3: @{ | |
3470 4: /* this line starts a multi-line | |
3471 5: * comment. This line should get `c' syntax */ | |
3472 6: | |
3473 7: char* a_multiline_string = "This line starts a multi-line \ | |
3474 8: string. This line should get `string' syntax."; | |
3475 9: | |
3476 10: note: | |
3477 11: @{ | |
3478 12: #ifdef LOCK | |
3479 13: Lock acquire(); | |
3480 14: #endif // LOCK | |
3481 15: slap_pop(); | |
3482 16: cout << "I played " | |
3483 17: << "a note\n"; | |
3484 18: @} | |
3485 19: @} | |
3486 | |
3487 @end group | |
3488 @end example | |
3489 | |
3490 The lines to note in this example include: | |
3491 | |
3492 @itemize @bullet | |
3493 | |
3494 @cindex func-decl-cont syntactic symbol | |
3495 @item | |
30396
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3496 Line 2 is assigned the @code{func-decl-cont} syntax. |
25829 | 3497 |
3498 @cindex comment-intro syntactic symbol | |
3499 @item | |
30396
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3500 Line 4 is assigned both @code{defun-block-intro} @emph{and} |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3501 @code{comment-intro} syntax. |
25829 | 3502 |
3503 @cindex c syntactic symbol | |
3504 @item | |
30396
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3505 Line 5 is assigned @code{c} syntax. |
25829 | 3506 |
3507 @item | |
3508 @cindex syntactic whitespace | |
30396
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3509 Line 6 which, even though it contains nothing but whitespace, is |
25829 | 3510 assigned @code{defun-block-intro}. Note that the appearance of the |
3511 comment on lines 4 and 5 do not cause line 6 to be assigned | |
3512 @code{statement} syntax because comments are considered to be | |
3513 @dfn{syntactic whitespace}, which are ignored when analyzing | |
30396
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3514 code. |
25829 | 3515 |
3516 @cindex string syntactic symbol | |
3517 @item | |
30396
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3518 Line 8 is assigned @code{string} syntax. |
25829 | 3519 |
3520 @cindex label syntactic symbol | |
3521 @item | |
30396
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3522 Line 10 is assigned @code{label} syntax. |
25829 | 3523 |
3524 @cindex block-open syntactic symbol | |
3525 @item | |
30396
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3526 Line 11 is assigned @code{block-open} syntax. |
25829 | 3527 |
3528 @cindex cpp-macro syntactic symbol | |
3529 @cindex cpp-macro-cont syntactic symbol | |
3530 @item | |
30396
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3531 Lines 12 and 14 are assigned @code{cpp-macro} syntax in addition to the |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3532 normal syntactic symbols (@code{statement-block-intro} and |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3533 @code{statement}, respectively). Normally @code{cpp-macro} is |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3534 configured to cancel out the normal syntactic context to make all |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3535 preprocessor directives stick to the first column, but that's easily |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3536 changed if you want preprocessor directives to be indented like the rest |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3537 of the code. |
25829 | 3538 |
3539 @cindex stream-op syntactic symbol | |
3540 @item | |
30396
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3541 Line 17 is assigned @code{stream-op} syntax. |
25829 | 3542 |
3543 @end itemize | |
3544 | |
3545 @cindex multi-line macros | |
3546 @cindex syntactic whitespace | |
3547 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
|
3548 @ccmode{} now recognizes the fact that it is inside a multi-line macro, |
25829 | 3549 and it properly skips such macros as syntactic whitespace. In this |
3550 example: | |
3551 @example | |
3552 @group | |
3553 | |
3554 1: #define LIST_LOOP(cons, listp) \ | |
3555 2: for (cons = listp; !NILP (cons); cons = XCDR (cons)) \ | |
3556 3: if (!CONSP (cons)) \ | |
3557 4: signal_error ("Invalid list format", listp); \ | |
3558 5: else | |
3559 | |
3560 @end group | |
3561 @end example | |
3562 @noindent | |
3563 line 1 is given the syntactic symbol @code{cpp-macro}. This first line | |
3564 of a macro is always given this symbol. The second and subsequent lines | |
3565 (e.g. lines 2 through 5) are given the @code{cpp-macro-cont} syntactic | |
3566 symbol, with a relative buffer position pointing to the @code{#} which | |
3567 starts the macro definition. | |
3568 | |
3569 In Objective-C buffers, there are three additional syntactic symbols | |
3570 assigned to various message calling constructs. Here's an example | |
3571 illustrating these: | |
3572 @example | |
3573 @group | |
3574 | |
3575 1: - (void)setDelegate:anObject | |
3576 2: withStuff:stuff | |
3577 3: @{ | |
3578 4: [delegate masterWillRebind:self | |
3579 5: toDelegate:anObject | |
3580 6: withExtraStuff:stuff]; | |
3581 7: @} | |
3582 | |
3583 @end group | |
3584 @end example | |
3585 | |
3586 @cindex objc-method-intro syntactic symbol | |
3587 @cindex objc-method-args-cont syntactic symbol | |
3588 @cindex objc-method-call-cont syntactic symbol | |
3589 Here, line 1 is assigned @code{objc-method-intro} syntax, and line 2 is | |
3590 assigned @code{objc-method-args-cont} syntax. Lines 5 and 6 are both | |
3591 assigned @code{objc-method-call-cont} syntax. | |
3592 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3593 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
|
3594 this: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3595 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3596 @group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3597 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3598 1: public void watch(Observable o) @{ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3599 2: o.addObserver(new Observer() @{ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3600 3: public void update(Observable o, Object arg) @{ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3601 4: history.addElement(arg); |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3602 5: @} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3603 6: @}); |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3604 7: @} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3605 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3606 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3607 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3608 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3609 @cindex inexpr-class syntactic symbol |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3610 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
|
3611 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
|
3612 @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
|
3613 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
|
3614 @code{inexpr-class}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3615 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3616 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
|
3617 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
|
3618 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3619 @group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3620 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3621 1: int res = (@{ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3622 2: int y = foo (); int z; |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3623 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
|
3624 4: z; |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3625 5: @}); |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3626 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3627 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3628 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3629 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3630 @cindex inexpr-statement syntactic symbol |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3631 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
|
3632 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
|
3633 @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
|
3634 indentation. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3635 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3636 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
|
3637 statements, as illustrated here: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3638 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3639 @group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3640 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3641 1: array itgob() |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3642 2: @{ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3643 3: string s = map (backtrace()[-2][3..], |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3644 4: lambda |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3645 5: (mixed arg) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3646 6: @{ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3647 7: return sprintf ("%t", arg); |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3648 8: @}) * ", " + "\n"; |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3649 9: return catch @{ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3650 10: write (s + "\n"); |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3651 11: @}; |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3652 12: @} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3653 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3654 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3655 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3656 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3657 @cindex inlambda syntactic symbol |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3658 @cindex lambda-intro-cont syntactic symbol |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3659 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
|
3660 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
|
3661 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
|
3662 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
|
3663 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
|
3664 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
|
3665 @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
|
3666 @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
|
3667 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
|
3668 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
|
3669 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
|
3670 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3671 @cindex inexpr-statement syntactic symbol |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3672 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
|
3673 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
|
3674 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
|
3675 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
|
3676 handled like this too. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3677 |
25829 | 3678 @cindex knr-argdecl-intro syntactic symbol |
3679 @cindex knr-argdecl syntactic symbol | |
3680 Two other syntactic symbols can appear in old style, non-prototyped C | |
3681 code @footnote{a.k.a. K&R C, or Kernighan & Ritchie C}: | |
3682 @example | |
3683 @group | |
3684 | |
3685 1: int add_three_integers(a, b, c) | |
3686 2: int a; | |
3687 3: int b; | |
3688 4: int c; | |
3689 5: @{ | |
3690 6: return a + b + c; | |
3691 7: @} | |
3692 | |
3693 @end group | |
3694 @end example | |
3695 | |
3696 Here, line 2 is the first line in an argument declaration list and so is | |
3697 given the @code{knr-argdecl-intro} syntactic symbol. Subsequent lines | |
3698 (i.e. lines 3 and 4 in this example), are given @code{knr-argdecl} | |
3699 syntax. | |
3700 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3701 |
25829 | 3702 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3703 @node Indentation Functions, Performance Issues, Syntactic Symbols, Top |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3704 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3705 @chapter Indentation Functions |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3706 @cindex indentation functions |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3707 @cindex line-up functions |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3708 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3709 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3710 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
|
3711 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
|
3712 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
|
3713 for a syntactic symbol. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3714 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3715 @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
|
3716 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
|
3717 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
|
3718 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
|
3719 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
|
3720 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3721 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
|
3722 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
|
3723 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3724 @macro workswith |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3725 @emph{Works with:} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3726 @end macro |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3727 @ifinfo |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3728 @unmacro workswith |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3729 @macro workswith |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3730 Works with: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3731 @end macro |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3732 @end ifinfo |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3733 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3734 @table @code |
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 @findex c-lineup-arglist |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3737 @findex lineup-arglist (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3738 @item c-lineup-arglist |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3739 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
|
3740 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3741 @workswith @code{arglist-cont-nonempty}. |
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 @findex c-lineup-arglist-intro-after-paren |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3744 @findex lineup-arglist-intro-after-paren (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3745 @item c-lineup-arglist-intro-after-paren |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3746 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
|
3747 brace block. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3748 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3749 @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
|
3750 @code{statement-block-intro}, @code{statement-case-intro}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3751 @code{arglist-intro}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3752 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3753 @findex c-lineup-arglist-close-under-paren |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3754 @findex lineup-arglist-close-under-paren (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3755 @item c-lineup-arglist-close-under-paren |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3756 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
|
3757 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
|
3758 under the parenthesis that opened the argument list. |
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{defun-close}, @code{class-close}, @code{inline-close}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3761 @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
|
3762 @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
|
3763 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
|
3764 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3765 @findex c-lineup-close-paren |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3766 @findex lineup-close-paren (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3767 @item c-lineup-close-paren |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3768 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
|
3769 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
|
3770 indentation is added. E.g: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3771 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3772 @group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3773 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3774 main (int, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3775 char ** |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3776 ) // c-lineup-close-paren |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3777 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3778 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3779 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3780 @noindent |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3781 and |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3782 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3783 @group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3784 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3785 main ( |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3786 int, char ** |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3787 ) // c-lineup-close-paren |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3788 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3789 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3790 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3791 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3792 @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
|
3793 @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
|
3794 @code{extern-lang-close}, @code{namespace-close}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3795 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3796 @findex c-lineup-streamop |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3797 @findex lineup-streamop (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3798 @item c-lineup-streamop |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3799 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
|
3800 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3801 @workswith @code{stream-op}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3802 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3803 @findex c-lineup-multi-inher |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3804 @findex lineup-multi-inher (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3805 @item c-lineup-multi-inher |
30396
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3806 Line up the classes in C++ multiple inheritance clauses and member |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3807 initializers under each other. E.g: |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3808 @example |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3809 @group |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3810 |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3811 Foo::Foo (int a, int b): |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3812 Cyphr (a), |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3813 Bar (b) // c-lineup-multi-inher |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3814 |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3815 @end group |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3816 @end example |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3817 @noindent |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3818 and |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3819 @example |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3820 @group |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3821 |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3822 class Foo |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3823 : public Cyphr, |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3824 public Bar // c-lineup-multi-inher |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3825 |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3826 @end group |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3827 @end example |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3828 @noindent |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3829 and |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3830 @example |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3831 @group |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3832 |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3833 Foo::Foo (int a, int b) |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3834 : Cyphr (a) |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3835 , Bar (b) // c-lineup-multi-inher |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3836 |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3837 @end group |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3838 @end example |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3839 |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
3840 @workswith @code{inher-cont}, @code{member-init-cont}. |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3841 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3842 @findex c-lineup-java-inher |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3843 @findex lineup-java-inher (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3844 @item c-lineup-java-inher |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3845 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
|
3846 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
|
3847 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
|
3848 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
|
3849 E.g: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3850 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3851 @group |
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 class Foo |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3854 extends |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3855 Bar // c-lineup-java-inher |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3856 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3857 <--> c-basic-offset |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3858 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3859 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3860 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3861 @noindent |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3862 and |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3863 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3864 @group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3865 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3866 class Foo |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3867 extends Cyphr, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3868 Bar // c-lineup-java-inher |
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 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3871 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3872 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3873 @workswith @code{inher-cont}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3874 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3875 @findex c-lineup-java-throws |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3876 @findex lineup-java-throws (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3877 @item c-lineup-java-throws |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3878 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
|
3879 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
|
3880 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
|
3881 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
|
3882 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
|
3883 start if it doesn't hang. E.g: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3884 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3885 @group |
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 int foo() |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3888 throws // c-lineup-java-throws |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3889 Bar // c-lineup-java-throws |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3890 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3891 <--><--> c-basic-offset |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3892 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3893 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3894 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3895 @noindent |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3896 and |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3897 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3898 @group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3899 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3900 int foo() throws Cyphr, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3901 Bar, // c-lineup-java-throws |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3902 Vlod // c-lineup-java-throws |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3903 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3904 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3905 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3906 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3907 @workswith @code{func-decl-cont}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3908 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3909 @findex c-indent-one-line-block |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3910 @findex indent-one-line-block (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3911 @item c-indent-one-line-block |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3912 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
|
3913 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3914 @group |
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 if (n > 0) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3917 @{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
|
3918 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3919 <--> c-basic-offset |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3920 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3921 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3922 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3923 @noindent |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3924 and |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3925 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3926 @group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3927 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3928 if (n > 0) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3929 @{ // c-indent-one-line-block |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3930 m+=n; n=0; |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3931 @} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3932 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3933 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3934 @end example |
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 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
|
3937 @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
|
3938 which makes the function usable in list expressions. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3939 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3940 @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
|
3941 @code{-open} symbols. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3942 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3943 @findex c-indent-multi-line-block |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3944 @findex indent-multi-line-block (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3945 @item c-indent-multi-line-block |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3946 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
|
3947 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3948 @group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3949 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3950 int *foo[] = @{ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3951 NULL, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3952 @{17@}, // c-indent-multi-line-block |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3953 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3954 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3955 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3956 @noindent |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3957 and |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3958 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3959 @group |
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 int *foo[] = @{ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3962 NULL, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3963 @{ // c-indent-multi-line-block |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3964 17 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3965 @}, |
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 <--> c-basic-offset |
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 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3970 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3971 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3972 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
|
3973 @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
|
3974 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
|
3975 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3976 @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
|
3977 @code{-open} symbols. |
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 @findex c-lineup-C-comments |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3980 @findex lineup-C-comments (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3981 @item c-lineup-C-comments |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3982 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
|
3983 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
|
3984 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3985 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3986 @group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3987 /* /** /* |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3988 * text * text text |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3989 */ */ */ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3990 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3991 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3992 @group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3993 /* text /* /** |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3994 text ** text ** text |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3995 */ */ */ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3996 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3997 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3998 @group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
3999 /************************************************** |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4000 * text |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4001 *************************************************/ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4002 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4003 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4004 @vindex comment-start-skip |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4005 @group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4006 /************************************************** |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4007 Free form text comments: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4008 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
|
4009 start, the indentation is kept unchanged for lines |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4010 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
|
4011 delimiter line is whatever matches the |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4012 @code{comment-start-skip} regexp. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4013 **************************************************/ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4014 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4015 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4016 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4017 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4018 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
|
4019 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
|
4020 line inside a comment. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4021 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4022 @workswith The @code{c} syntactic symbol. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4023 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4024 @findex c-lineup-comment |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4025 @findex lineup-comment (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4026 @item c-lineup-comment |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4027 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
|
4028 @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
|
4029 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
|
4030 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4031 @vindex c-comment-only-line-offset |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4032 @vindex comment-only-line-offset (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4033 @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
|
4034 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
|
4035 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4036 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4037 (@r{<non-anchored-offset>} . @r{<anchored-offset>}) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4038 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4039 @end example |
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 @noindent |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4042 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
|
4043 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
|
4044 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
|
4045 is equivalent to @code{(@r{<value>} . -1000)}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4046 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4047 @workswith @code{comment-intro}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4048 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4049 @findex c-lineup-runin-statements |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4050 @findex lineup-runin-statements (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4051 @item c-lineup-runin-statements |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4052 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
|
4053 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
|
4054 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
|
4055 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
|
4056 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4057 @group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4058 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4059 int main() |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4060 @{ puts (\"Hello world!\"); |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4061 return 0; // c-lineup-runin-statements |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4062 @} |
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 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4065 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4066 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4067 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
|
4068 @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
|
4069 expressions. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4070 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4071 @workswith The @code{statement} syntactic symbol. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4072 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4073 @findex c-lineup-math |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4074 @findex lineup-math (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4075 @item c-lineup-math |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4076 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
|
4077 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
|
4078 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
|
4079 first one. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4080 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4081 @workswith @code{statement-cont}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4082 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4083 @findex c-lineup-template-args |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4084 @findex lineup-template-args (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4085 @item c-lineup-template-args |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4086 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
|
4087 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
|
4088 opening @samp{<}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4089 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4090 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
|
4091 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
|
4092 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4093 @workswith @code{template-args-cont}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4094 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4095 @findex c-lineup-ObjC-method-call |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4096 @findex lineup-ObjC-method-call (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4097 @item c-lineup-ObjC-method-call |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4098 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
|
4099 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
|
4100 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
|
4101 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
|
4102 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
|
4103 lineup the current line with it. |
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 @workswith @code{objc-method-call-cont}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4106 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4107 @findex c-lineup-ObjC-method-args |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4108 @findex lineup-ObjC-method-args (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4109 @item c-lineup-ObjC-method-args |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4110 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
|
4111 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
|
4112 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4113 @workswith @code{objc-method-args-cont}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4114 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4115 @findex c-lineup-ObjC-method-args-2 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4116 @findex lineup-ObjC-method-args-2 (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4117 @item c-lineup-ObjC-method-args-2 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4118 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
|
4119 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
|
4120 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4121 @workswith @code{objc-method-args-cont}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4122 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4123 @findex c-lineup-inexpr-block |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4124 @findex lineup-inexpr-block (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4125 @item c-lineup-inexpr-block |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4126 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
|
4127 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
|
4128 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
|
4129 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
|
4130 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
|
4131 construct. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4132 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4133 @workswith @code{inlambda}, @code{inexpr-statement}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4134 @code{inexpr-class}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4135 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4136 @findex c-lineup-whitesmith-in-block |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4137 @findex lineup-whitesmith-in-block (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4138 @item c-lineup-whitesmith-in-block |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4139 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
|
4140 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
|
4141 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4142 @group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4143 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4144 something |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4145 @{ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4146 foo; // c-lineup-whitesmith-in-block |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4147 @} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4148 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4149 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4150 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4151 @noindent |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4152 and |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4153 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4154 @group |
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 something @{ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4157 foo; // c-lineup-whitesmith-in-block |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4158 @} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4159 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4160 <--> c-basic-offset |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4161 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4162 @end group |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4163 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4164 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4165 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
|
4166 @code{c-basic-offset} is added. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4167 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4168 @workswith @code{defun-close}, @code{defun-block-intro}, |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4169 @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
|
4170 @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
|
4171 @code{innamespace}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4172 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4173 @findex c-lineup-dont-change |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4174 @findex lineup-dont-change (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4175 @item c-lineup-dont-change |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4176 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
|
4177 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
|
4178 @code{cpp-macro-cont} lines. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4179 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4180 @workswith Any syntactic symbol. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4181 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4182 @end table |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4183 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4184 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4185 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4186 @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
|
4187 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4188 @chapter Performance Issues |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4189 @cindex performance issues |
25829 | 4190 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
4191 | |
4192 C and its derivative languages are highly complex creatures. Often, | |
4193 ambiguous code situations arise that require @ccmode{} to scan | |
4194 large portions of the buffer to determine syntactic context. Such | |
4195 pathological code@footnote{such as the output of @code{lex(1)}!} | |
4196 can cause @ccmode{} to perform fairly badly. | |
4197 This section identifies some of the coding styles to watch out for, and | |
4198 suggests some workarounds that you can use to improve performance. | |
4199 | |
4200 Because @ccmode{} has to scan the buffer backwards from the current | |
4201 insertion point, and because C's syntax is fairly difficult to parse in | |
4202 the backwards direction, @ccmode{} often tries to find the nearest | |
4203 position higher up in the buffer from which to begin a forward scan. | |
4204 The farther this position is from the current insertion point, the | |
4205 slower the mode gets. Some coding styles can even force @ccmode{} | |
4206 to scan from the beginning of the buffer for every line of code! | |
4207 | |
4208 @findex beginning-of-defun | |
4209 @findex defun-prompt-regexp | |
4210 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
|
4211 any brace that opens a top-level construct@footnote{E.g. a function in |
25829 | 4212 C, or outermost class definition in C++ or Java.} always appears in the |
4213 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
|
4214 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
|
4215 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
|
4216 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
|
4217 to something reasonable, however that ``something reasonable'' is |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4218 difficult to define, so @ccmode{} doesn't do it for you. |
25829 | 4219 |
4220 @vindex c-Java-defun-prompt-regexp | |
4221 @vindex Java-defun-prompt-regexp (c-) | |
4222 A special note about @code{defun-prompt-regexp} in Java mode: while much | |
4223 of the early sample Java code seems to encourage a style where the brace | |
4224 that opens a class is hung on the right side of the line, this is not a | |
4225 good style to pursue in Emacs. @ccmode{} comes with a variable | |
4226 @code{c-Java-defun-prompt-regexp} which tries to define a regular | |
4227 expression usable for this style, but there are problems with it. In | |
4228 some cases it can cause @code{beginning-of-defun} to hang@footnote{This | |
4229 has been observed in Emacs 19.34 and XEmacs 19.15.}. For this reason, | |
4230 it is not used by default, but if you feel adventurous, you can set | |
4231 @code{defun-prompt-regexp} to it in your mode hook. In any event, | |
4232 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
|
4233 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
|
4234 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
|
4235 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4236 @vindex c-enable-xemacs-performance-kludge-p |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4237 @vindex enable-xemacs-performance-kludge-p (c-) |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4238 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
|
4239 @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
|
4240 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
|
4241 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
|
4242 @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
|
4243 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
|
4244 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
|
4245 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
|
4246 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
|
4247 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
|
4248 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
|
4249 should be more common (and |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4250 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
|
4251 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
|
4252 this writing 27-Apr-1998). |
25829 | 4253 |
4254 You will probably notice pathological behavior from @ccmode{} when | |
4255 working in files containing large amounts of C preprocessor macros. | |
4256 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
|
4257 as it can comments. |
25829 | 4258 |
4259 @vindex c-recognize-knr-p | |
4260 @vindex recognize-knr-p (c-) | |
4261 Previous versions of @ccmode{} had potential performance problems | |
4262 when recognizing K&R style function argument declarations. This was | |
4263 because there are ambiguities in the C syntax when K&R style argument | |
4264 lists are used@footnote{It is hard to distinguish them from top-level | |
4265 declarations.}. @ccmode{} has adopted BOCM's convention for | |
4266 limiting the search: it assumes that argdecls are indented at least one | |
4267 space, and that the function headers are not indented at all. With | |
4268 current versions of @ccmode{}, user customization of | |
4269 @code{c-recognize-knr-p} is deprecated. Just don't put argdecls in | |
4270 column zero! | |
4271 | |
4272 @cindex @file{cc-lobotomy.el} file | |
4273 @vindex cc-lobotomy-pith-list | |
4274 You might want to investigate the speed-ups contained in the | |
4275 file @file{cc-lobotomy.el}, which comes as part of the @ccmode{} | |
4276 distribution, but is completely unsupported. | |
4277 As mentioned previous, @ccmode{} always trades speed for accuracy, | |
4278 however it is recognized that sometimes you need speed and can sacrifice | |
4279 some accuracy in indentation. The file @file{cc-lobotomy.el} contains | |
4280 hacks that will ``dumb down'' @ccmode{} in some specific ways, making | |
4281 that trade-off of accurancy for speed. I won't go into details of its | |
4282 use here; you should read the comments at the top of the file, and look | |
4283 at the variable @code{cc-lobotomy-pith-list} for details. | |
4284 | |
4285 | |
4286 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4287 @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
|
4288 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4289 @chapter Frequently Asked Questions |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4290 @cindex frequently asked questions |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4291 @cindex FAQ |
25829 | 4292 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
4293 | |
4294 @kindex C-x h | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4295 @kindex C-M-\ |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4296 @kindex C-M-x |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4297 @kindex C-M-q |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4298 @kindex C-M-u |
25829 | 4299 @kindex RET |
4300 @kindex C-j | |
4301 @quotation | |
4302 | |
4303 @strong{Q.} @emph{How do I re-indent the whole file?} | |
4304 | |
4305 @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
|
4306 buffer. Then hit @kbd{C-M-\}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4307 |
25829 | 4308 @sp 1 |
4309 @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
|
4310 @kbd{C-M-x} doesn't work.} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4311 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4312 @strong{A.} @kbd{C-M-x} is reserved for future Emacs use. |
25829 | 4313 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
|
4314 |
25829 | 4315 @sp 1 |
4316 @strong{Q.} @emph{How do I re-indent the current block?} | |
4317 | |
4318 @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
|
4319 @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
|
4320 @kbd{C-M-q}. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4321 |
25829 | 4322 @sp 1 |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4323 @strong{Q.} @emph{Why doesn't the @kbd{RET} key indent the new line?} |
25829 | 4324 |
4325 @strong{A.} Emacs' convention is that @kbd{RET} just adds a newline, | |
4326 and that @kbd{C-j} adds a newline and indents it. You can make | |
4327 @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
|
4328 @code{c-mode-common-hook}: |
25829 | 4329 @example |
4330 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4331 (define-key c-mode-base-map "\C-m" 'c-context-line-break) |
25829 | 4332 |
4333 @end example | |
4334 | |
4335 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
|
4336 behavior, don't lobby me, lobby RMS! @t{:-)} |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4337 |
25829 | 4338 @sp 1 |
4339 @strong{Q.} @emph{I put @code{(c-set-offset 'substatement-open 0)} | |
4340 in my @file{.emacs} file but I get an error saying that | |
4341 @code{c-set-offset}'s function definition is void.} | |
4342 | |
4343 @strong{A.} This means that @ccmode{} wasn't loaded into your | |
4344 Emacs session by the time the @code{c-set-offset} call was reached, | |
4345 mostly likely because @ccmode{} is being autoloaded. Instead | |
4346 of putting the @code{c-set-offset} line in your top-level | |
4347 @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
|
4348 simply modify @code{c-offsets-alist} directly: |
25829 | 4349 @example |
30396
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
4350 |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
4351 (setq c-offsets-alist '((substatement-open . 0))) |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
4352 |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4353 @end example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4354 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4355 @sp 1 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4356 @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
|
4357 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
|
4358 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4359 @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
|
4360 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
|
4361 on @code{c-default-style}: |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4362 @example |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4363 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4364 (setq c-default-style '((other . "my-style"))) |
25829 | 4365 |
4366 @end example | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4367 @noindent |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4368 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
|
4369 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
|
4370 this causes "my-style" to be used in every mode. |
25829 | 4371 |
4372 @sp 1 | |
4373 @strong{Q.} @emph{How do I make strings, comments, keywords, and other | |
4374 constructs appear in different colors, or in bold face, etc.?} | |
4375 | |
4376 @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
|
4377 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
|
4378 font-lock definitions for any of its supported languages. |
25829 | 4379 |
4380 @sp 1 | |
4381 @strong{Q.} @emph{@kbd{M-a} and @kbd{M-e} used to move over entire | |
4382 balanced brace lists, but now they move into blocks. How do I get the | |
4383 old behavior back?} | |
4384 | |
4385 @strong{A.} Use @kbd{C-M-f} and @kbd{C-M-b} to move over balanced brace | |
4386 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
|
4387 also move into blocks. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4388 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4389 @sp 1 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4390 @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
|
4391 ``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
|
4392 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
|
4393 gives?} |
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 @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
|
4396 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
|
4397 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
|
4398 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
|
4399 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
|
4400 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
|
4401 @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
|
4402 in the @file{README} file. |
25829 | 4403 |
4404 @end quotation | |
4405 | |
4406 | |
4407 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4408 @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
|
4409 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4410 @chapter Getting the Latest CC Mode Release |
25829 | 4411 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
4412 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4413 @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
|
4414 XEmacs since 19.16. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4415 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4416 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
|
4417 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
|
4418 @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
|
4419 compatibility, etc. are all available via the Web at: |
25829 | 4420 |
4421 @example | |
4422 @group | |
4423 | |
30396
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
4424 @uref{http://cc-mode.sourceforge.net/} |
25829 | 4425 |
4426 @end group | |
4427 @end example | |
4428 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4429 @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
|
4430 |
25829 | 4431 There are many files under these directories; you can pick up the entire |
4432 distribution (named @code{cc-mode.tar.gz}; a gzip'd tar file), or any of | |
4433 the individual files, including PostScript documentation. | |
4434 | |
4435 | |
4436 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4437 @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
|
4438 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4439 @chapter Sample .emacs file |
25829 | 4440 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
4441 | |
4442 @example | |
4443 ;; Here's a sample .emacs file that might help you along the way. Just | |
4444 ;; copy this region and paste it into your .emacs file. You may want to | |
4445 ;; change some of the actual values. | |
4446 | |
4447 (defconst my-c-style | |
4448 '((c-tab-always-indent . t) | |
4449 (c-comment-only-line-offset . 4) | |
4450 (c-hanging-braces-alist . ((substatement-open after) | |
4451 (brace-list-open))) | |
4452 (c-hanging-colons-alist . ((member-init-intro before) | |
4453 (inher-intro) | |
4454 (case-label after) | |
4455 (label after) | |
4456 (access-label after))) | |
4457 (c-cleanup-list . (scope-operator | |
4458 empty-defun-braces | |
4459 defun-close-semi)) | |
4460 (c-offsets-alist . ((arglist-close . c-lineup-arglist) | |
4461 (substatement-open . 0) | |
4462 (case-label . 4) | |
4463 (block-open . 0) | |
4464 (knr-argdecl-intro . -))) | |
4465 (c-echo-syntactic-information-p . t) | |
4466 ) | |
4467 "My C Programming Style") | |
4468 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4469 ;; offset customizations not in my-c-style |
30396
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
4470 (setq c-offsets-alist '((member-init-intro . ++))) |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4471 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4472 ;; Customizations for all modes in CC Mode. |
25829 | 4473 (defun my-c-mode-common-hook () |
4474 ;; add my personal style and set it for the current buffer | |
4475 (c-add-style "PERSONAL" my-c-style t) | |
4476 ;; other customizations | |
4477 (setq tab-width 8 | |
4478 ;; this will make sure spaces are used instead of tabs | |
4479 indent-tabs-mode nil) | |
4480 ;; we like auto-newline and hungry-delete | |
4481 (c-toggle-auto-hungry-state 1) | |
4482 ;; keybindings for all supported languages. We can put these in | |
4483 ;; 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
|
4484 ;; 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
|
4485 (define-key c-mode-base-map "\C-m" 'c-context-line-break) |
25829 | 4486 ) |
4487 | |
4488 (add-hook 'c-mode-common-hook 'my-c-mode-common-hook) | |
4489 @end example | |
4490 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4491 |
25829 | 4492 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4493 @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
|
4494 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4495 @chapter Limitations and Known Bugs |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4496 @cindex limitations |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4497 @cindex bugs |
25829 | 4498 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
4499 | |
4500 @itemize @bullet | |
4501 @item | |
4502 Re-indenting large regions or expressions can be slow. | |
4503 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4504 @findex c-indent-exp |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4505 @findex indent-exp (c-) |
25829 | 4506 @item |
4507 @code{c-indent-exp} has not been fully optimized. It essentially | |
4508 equivalent to hitting @kbd{TAB} (@code{c-indent-command}) on every | |
4509 line. Some information is cached from line to line, but such caching | |
4510 invariable causes inaccuracies in analysis in some bizarre situations. | |
4511 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4512 @vindex signal-error-on-buffer-boundary |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4513 @item |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4514 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
|
4515 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
|
4516 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
|
4517 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
|
4518 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
|
4519 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
|
4520 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
|
4521 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
|
4522 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
|
4523 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
|
4524 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
|
4525 |
25829 | 4526 @end itemize |
4527 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4528 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4529 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4530 @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
|
4531 @comment node-name, next, previous, up |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4532 @chapter Mailing Lists and Submitting Bug Reports |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4533 @cindex mailing lists |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4534 @cindex reporting bugs |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4535 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
25829 | 4536 |
4537 @kindex C-c C-b | |
4538 @findex c-submit-bug-report | |
4539 @findex submit-bug-report (c-) | |
4540 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
|
4541 command. This provides vital information we need to reproduce your |
25829 | 4542 problem. Make sure you include a concise, but complete code example. |
4543 Please try to boil your example down to just the essential code needed | |
4544 to reproduce the problem, and include an exact recipe of steps needed to | |
4545 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
|
4546 @emph{before} your bug example, if you think it might affect our ability |
25829 | 4547 to reproduce it. |
4548 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4549 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
|
4550 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
|
4551 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
|
4552 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
|
4553 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
|
4554 the bug and include it in your report. |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4555 |
25829 | 4556 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
|
4557 @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
|
4558 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
|
4559 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
|
4560 @email{bug-cc-mode@@gnu.org}, or @email{help-gnu-emacs@@gnu.org} which is |
30396
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
4561 mirrored on newsgroup @code{gnu.emacs.help}. |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4562 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4563 @cindex beta testers mailing list |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4564 @cindex announcement mailing list |
30396
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
4565 If you want to get announcements of new @ccmode{} releases, send the |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
4566 word @emph{subscribe} in the body of a message to |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
4567 @email{cc-mode-announce-request@@lists.sourceforge.net}. Announcements |
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
4568 will also be posted to the Usenet newsgroups @code{gnu.emacs.sources}, |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4569 @code{comp.emacs}, @code{comp.emacs.xemacs}, and possibly some of the |
30396
460a86ced57c
@setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents:
30044
diff
changeset
|
4570 language oriented newsgroups. |
25829 | 4571 |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4572 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4573 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4574 @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
|
4575 @comment node-name, next, previous, up |
25829 | 4576 @unnumbered Concept Index |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4577 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
25829 | 4578 |
4579 @printindex cp | |
4580 | |
4581 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4582 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4583 @node Command Index, Key Index, Concept Index, Top |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4584 @comment node-name, next, previous, up |
25829 | 4585 @unnumbered Command Index |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4586 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4587 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4588 Since most @ccmode{} commands are prepended with the string |
25829 | 4589 @samp{c-}, each appears under its @code{c-@var{<thing>}} name and its |
4590 @code{@var{<thing>} (c-)} name. | |
4591 @iftex | |
4592 @sp 2 | |
4593 @end iftex | |
4594 @printindex fn | |
4595 | |
4596 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4597 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4598 @node Key Index, Variable Index, Command Index, Top |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4599 @comment node-name, next, previous, up |
25829 | 4600 @unnumbered Key Index |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4601 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
25829 | 4602 |
4603 @printindex ky | |
4604 | |
4605 | |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4606 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4607 @node Variable Index, , Key Index, Top |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4608 @comment node-name, next, previous, up |
25829 | 4609 @unnumbered Variable Index |
26819
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4610 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4611 |
a19be798eaea
Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents:
26490
diff
changeset
|
4612 Since most @ccmode{} variables are prepended with the string |
25829 | 4613 @samp{c-}, each appears under its @code{c-@var{<thing>}} name and its |
4614 @code{@var{<thing>} (c-)} name. | |
4615 @iftex | |
4616 @sp 2 | |
4617 @end iftex | |
4618 @printindex vr | |
4619 @page | |
4620 @summarycontents | |
4621 @contents | |
4622 @bye |