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