annotate man/cc-mode.texi @ 41887:8c0b69283972

Fix some 8-bit-graphic characters. Use iso2022 encoding. (latin1-char-displayable-p): Doc fix. (latin1-display-ucs-per-lynx): New option. (latin1-display-ucs-per-lynx): New command. (latin1-display-reset): Special-case arabic. (ucs-tables): Require. (latin1-display-sets, latin1-display-setup): Add arabic. (latin1-display) <variable>: Use function latin1-display. (latin1-display) <function>: Add mule-unicode stuff. (latin1-display-check-font): Don't lose if `info' is nil.
author Dave Love <fx@gnu.org>
date Fri, 07 Dec 2001 18:08:15 +0000
parents 421e0a91a1d1
children 82d113655734
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1 \input texinfo
Dave Love <fx@gnu.org>
parents:
diff changeset
2
Dave Love <fx@gnu.org>
parents:
diff changeset
3 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
4 @comment %**start of header (This is for running Texinfo on a region)
Dave Love <fx@gnu.org>
parents:
diff changeset
5 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
6
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
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
11 @settitle CC Mode Manual
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
12 @footnotestyle end
Dave Love <fx@gnu.org>
parents:
diff changeset
13
Dave Love <fx@gnu.org>
parents:
diff changeset
14 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
15 @comment @setchapternewpage odd !! we don't want blank pages !!
Dave Love <fx@gnu.org>
parents:
diff changeset
16 @comment %**end of header (This is for running Texinfo on a region)
Dave Love <fx@gnu.org>
parents:
diff changeset
17 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
18
Dave Love <fx@gnu.org>
parents:
diff changeset
19
Dave Love <fx@gnu.org>
parents:
diff changeset
20 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
21 @comment
Dave Love <fx@gnu.org>
parents:
diff changeset
22 @comment Texinfo manual for CC Mode
Dave Love <fx@gnu.org>
parents:
diff changeset
23 @comment Generated from the original README file by Krishna Padmasola
Dave Love <fx@gnu.org>
parents:
diff changeset
24 @comment <krishna@earth-gw.njit.edu>
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
25 @comment
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
26 @comment Authors:
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
27 @comment Barry A. Warsaw
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
28 @comment Martin Stjernholm
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
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>
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
31 @comment
Dave Love <fx@gnu.org>
parents:
diff changeset
32 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
33
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
34 @macro copyrightblurb
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
35 Copyright @copyright{} 1995, 96, 97, 98, 99, 2000, 01 Free Software Foundation, Inc.
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
36 @end macro
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
37
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
38 @comment Info directory entry for use by install-info. The indentation
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
39 @comment here is by request from the FSF folks.
30396
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
40 @dircategory Emacs
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
41 @direntry
36924
28d23bbdd2cf Version merged with the one from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36923
diff changeset
42 * CC Mode: (ccmode). Emacs mode for editing C, C++, Objective-C,
34239
Dave Love <fx@gnu.org>
parents: 34151
diff changeset
43 Java, Pike, and IDL code.
30396
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
44 @end direntry
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
45
Dave Love <fx@gnu.org>
parents:
diff changeset
46 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
47 @comment The following lines inserts the copyright notice
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
48 @comment into the Info file.
Dave Love <fx@gnu.org>
parents:
diff changeset
49 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
50
34239
Dave Love <fx@gnu.org>
parents: 34151
diff changeset
51 @ifnottex
36924
28d23bbdd2cf Version merged with the one from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36923
diff changeset
52 Copyright @copyright{} 1995, 96, 97, 98, 99, 2000, 2001 Free Software Foundation, Inc.
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 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
55 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
56 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
57 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
58 ``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
59 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
60 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
61 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
62
28d23bbdd2cf Version merged with the one from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36923
diff changeset
63 (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
64 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
65 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
66
28d23bbdd2cf Version merged with the one from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36923
diff changeset
67 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
68 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
69 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
70 license to the document, as described in section 6 of the license.
34239
Dave Love <fx@gnu.org>
parents: 34151
diff changeset
71 @end ifnottex
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
72
Dave Love <fx@gnu.org>
parents:
diff changeset
73 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
74 @comment TeX title page
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
75 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
76
Dave Love <fx@gnu.org>
parents:
diff changeset
77 @titlepage
Dave Love <fx@gnu.org>
parents:
diff changeset
78 @sp 10
Dave Love <fx@gnu.org>
parents:
diff changeset
79
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
80 @center @titlefont{CC Mode 5.28}
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
81 @sp 2
Dave Love <fx@gnu.org>
parents:
diff changeset
82 @center @subtitlefont{A GNU Emacs mode for editing C and C-like languages}
Dave Love <fx@gnu.org>
parents:
diff changeset
83 @sp 2
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
84 @center Barry A. Warsaw, Martin Stjernholm
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
85
Dave Love <fx@gnu.org>
parents:
diff changeset
86 @page
Dave Love <fx@gnu.org>
parents:
diff changeset
87 @vskip 0pt plus 1filll
36924
28d23bbdd2cf Version merged with the one from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36923
diff changeset
88 Copyright @copyright{} 1995, 96, 97, 98, 99, 2000, 2001 Free Software Foundation, Inc.
28d23bbdd2cf Version merged with the one from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36923
diff changeset
89 @sp 1
28d23bbdd2cf Version merged with the one from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36923
diff changeset
90 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
91 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
92 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
93 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
94 ``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
95 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
96 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
97 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
98
28d23bbdd2cf Version merged with the one from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36923
diff changeset
99 (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
100 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
101 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
102
28d23bbdd2cf Version merged with the one from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36923
diff changeset
103 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
104 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
105 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
106 license to the document, as described in section 6 of the license.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
107 @end titlepage
Dave Love <fx@gnu.org>
parents:
diff changeset
108
Dave Love <fx@gnu.org>
parents:
diff changeset
109 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
110 @comment The Top node contains the master menu for the Info file.
Dave Love <fx@gnu.org>
parents:
diff changeset
111 @comment This appears only in the Info file, not the printed manual.
Dave Love <fx@gnu.org>
parents:
diff changeset
112 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
113
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
114 @node Top, Introduction, (dir), (dir)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
115 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
116
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
117 @macro ccmode
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
118 CC Mode
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
119 @end macro
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
120
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
121 @ifinfo
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
122 @top @ccmode{}
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
123
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
124 @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
125 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
126 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
127 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
128 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
129 @end ifinfo
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
130
Dave Love <fx@gnu.org>
parents:
diff changeset
131 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
132 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
133
Dave Love <fx@gnu.org>
parents:
diff changeset
134 @menu
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
135 * Introduction::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
136 * Getting Connected::
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
137 * New Indentation Engine::
Dave Love <fx@gnu.org>
parents:
diff changeset
138 * Minor Modes::
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
139 * Text Filling and Line Breaking::
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
140 * Commands::
Dave Love <fx@gnu.org>
parents:
diff changeset
141 * Customizing Indentation::
Dave Love <fx@gnu.org>
parents:
diff changeset
142 * Syntactic Symbols::
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
143 * Indentation Functions::
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
144 * Performance Issues::
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
145 * Limitations and Known Bugs::
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
146 * Frequently Asked Questions::
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
147 * Getting the Latest CC Mode Release::
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
148 * Mailing Lists and Submitting Bug Reports::
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
149 * Sample .emacs File::
26819
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 --- Indices ---
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
152
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
153 * Concept Index::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
154 * Command Index::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
155 * Key Index::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
156 * Variable Index::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
157
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
158 --- The Detailed Node Listing ---
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
159
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
160 New Indentation Engine
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
161
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
162 * Syntactic Analysis::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
163 * Indentation Calculation::
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 Minor Modes
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
166
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
167 * Auto-newline Insertion::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
168 * Hungry-deletion of Whitespace::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
169
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
170 Auto-newline Insertion
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
171
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
172 * Hanging Braces::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
173 * Hanging Colons::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
174 * Hanging Semi-colons and Commas::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
175 * Other Electric Commands::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
176 * Clean-ups::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
177
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
178 Commands
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
179
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
180 * Indentation Commands::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
181 * Movement Commands::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
182 * Other Commands::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
183
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
184 Customizing Indentation
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
185
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
186 * Interactive Customization::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
187 * Permanent Customization::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
188 * Hooks::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
189 * Styles::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
190 * Advanced Customizations::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
191
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
192 Styles
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
193
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
194 * Built-in Styles::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
195 * Adding Styles::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
196 * File Styles::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
197
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
198 Advanced Customizations
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
199
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
200 * Custom Indentation Functions::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
201 * Custom Brace and Colon Hanging::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
202 * Customizing Semi-colons and Commas::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
203 * Other Special Indentations::
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
204 @end menu
Dave Love <fx@gnu.org>
parents:
diff changeset
205
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
206
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
207 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
208 @node Introduction, Getting Connected, Top, Top
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
209 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
210 @chapter Introduction
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
211 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
212
Dave Love <fx@gnu.org>
parents:
diff changeset
213 @cindex BOCM
Dave Love <fx@gnu.org>
parents:
diff changeset
214
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
215 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
216 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
217 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
218 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
219 been maintaining since 1992. @ccmode{} represents a significant
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
220 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
221 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
222 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
223 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
224 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
225
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
226 This manual describes @ccmode{}
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
227 @comment The following line must appear on its own, so that the automated
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
228 version 5.28.
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
229 @comment Release.py script can update the version number automatically
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
230
Dave Love <fx@gnu.org>
parents:
diff changeset
231 @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
232 @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
233 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
234 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
235 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
236 @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
237 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
238 @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
239 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
240 modes. Font-locking is handled by other Emacs packages.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
241
Dave Love <fx@gnu.org>
parents:
diff changeset
242 This manual will describe the following:
Dave Love <fx@gnu.org>
parents:
diff changeset
243
Dave Love <fx@gnu.org>
parents:
diff changeset
244 @itemize @bullet
Dave Love <fx@gnu.org>
parents:
diff changeset
245 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
246 How to get started using @ccmode{}.
Dave Love <fx@gnu.org>
parents:
diff changeset
247
Dave Love <fx@gnu.org>
parents:
diff changeset
248 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
249 How the new indentation engine works.
Dave Love <fx@gnu.org>
parents:
diff changeset
250
Dave Love <fx@gnu.org>
parents:
diff changeset
251 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
252 How to customize the new indentation engine.
Dave Love <fx@gnu.org>
parents:
diff changeset
253
Dave Love <fx@gnu.org>
parents:
diff changeset
254 @end itemize
Dave Love <fx@gnu.org>
parents:
diff changeset
255
Dave Love <fx@gnu.org>
parents:
diff changeset
256 @findex c-mode
Dave Love <fx@gnu.org>
parents:
diff changeset
257 @findex c++-mode
Dave Love <fx@gnu.org>
parents:
diff changeset
258 @findex objc-mode
Dave Love <fx@gnu.org>
parents:
diff changeset
259 @findex java-mode
Dave Love <fx@gnu.org>
parents:
diff changeset
260 @findex idl-mode
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
261 @findex pike-mode
36924
28d23bbdd2cf Version merged with the one from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36923
diff changeset
262 Note that the name of this package is ``@ccmode{},'' but there is no top
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
263 level @code{cc-mode} entry point. All of the variables, commands, and
Dave Love <fx@gnu.org>
parents:
diff changeset
264 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
265 @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
266 @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
267 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
268 @file{c++-mode.el}.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
269
Dave Love <fx@gnu.org>
parents:
diff changeset
270 @cindex @file{cc-compat.el} file
Dave Love <fx@gnu.org>
parents:
diff changeset
271 This distribution also contains a file
Dave Love <fx@gnu.org>
parents:
diff changeset
272 called @file{cc-compat.el} which should ease your transition from BOCM
Dave Love <fx@gnu.org>
parents:
diff changeset
273 to @ccmode{}. If you have a BOCM configuration you are really happy
Dave Love <fx@gnu.org>
parents:
diff changeset
274 with, and want to postpone learning how to configure @ccmode{}, take a
Dave Love <fx@gnu.org>
parents:
diff changeset
275 look at that file. It maps BOCM configuration variables to @ccmode{}'s
Dave Love <fx@gnu.org>
parents:
diff changeset
276 new indentation model. It is not actively supported so for the long
Dave Love <fx@gnu.org>
parents:
diff changeset
277 run, you should learn how to customize @ccmode{} to support your coding
Dave Love <fx@gnu.org>
parents:
diff changeset
278 style.
Dave Love <fx@gnu.org>
parents:
diff changeset
279
Dave Love <fx@gnu.org>
parents:
diff changeset
280 A special word of thanks goes to Krishna Padmasola for his work in
Dave Love <fx@gnu.org>
parents:
diff changeset
281 converting the original @file{README} file to Texinfo format. I'd also
Dave Love <fx@gnu.org>
parents:
diff changeset
282 like to thank all the @ccmode{} victims who help enormously during the
Dave Love <fx@gnu.org>
parents:
diff changeset
283 early beta stages of @ccmode{}'s development.
Dave Love <fx@gnu.org>
parents:
diff changeset
284
Dave Love <fx@gnu.org>
parents:
diff changeset
285
Dave Love <fx@gnu.org>
parents:
diff changeset
286 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
287 @node Getting Connected, New Indentation Engine, Introduction, Top
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
288 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
289 @chapter Getting Connected
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
290 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
291
Dave Love <fx@gnu.org>
parents:
diff changeset
292 If you got this version of @ccmode{} with Emacs or XEmacs, it should
Dave Love <fx@gnu.org>
parents:
diff changeset
293 work just fine right out of the box. Note however that you may not have
Dave Love <fx@gnu.org>
parents:
diff changeset
294 the latest @ccmode{} release and may want to upgrade your copy.
Dave Love <fx@gnu.org>
parents:
diff changeset
295
Dave Love <fx@gnu.org>
parents:
diff changeset
296 If you are upgrading an existing @ccmode{} installation, please see the
Dave Love <fx@gnu.org>
parents:
diff changeset
297 @file{README} file for installation details. @ccmode{} may not work
Dave Love <fx@gnu.org>
parents:
diff changeset
298 with older versions of Emacs or XEmacs. See the @ccmode{} release notes
Dave Love <fx@gnu.org>
parents:
diff changeset
299 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
300 compatibility (@pxref{Getting the Latest CC Mode Release}).
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
301
Dave Love <fx@gnu.org>
parents:
diff changeset
302 @cindex @file{cc-mode-18.el} file
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
303 @emph{Note that @ccmode{} no longer
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
304 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
305 you are out of luck.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
306
Dave Love <fx@gnu.org>
parents:
diff changeset
307 @findex c-version
Dave Love <fx@gnu.org>
parents:
diff changeset
308 @findex version (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
309 You can find out what version of @ccmode{} you are using by visiting a C
Dave Love <fx@gnu.org>
parents:
diff changeset
310 file and entering @kbd{M-x c-version RET}. You should see this message in
Dave Love <fx@gnu.org>
parents:
diff changeset
311 the echo area:
Dave Love <fx@gnu.org>
parents:
diff changeset
312 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
313
Dave Love <fx@gnu.org>
parents:
diff changeset
314 Using CC Mode version 5.XX
Dave Love <fx@gnu.org>
parents:
diff changeset
315
Dave Love <fx@gnu.org>
parents:
diff changeset
316 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
317
Dave Love <fx@gnu.org>
parents:
diff changeset
318 @noindent
Dave Love <fx@gnu.org>
parents:
diff changeset
319 where @samp{XX} is the minor release number.
Dave Love <fx@gnu.org>
parents:
diff changeset
320
Dave Love <fx@gnu.org>
parents:
diff changeset
321
Dave Love <fx@gnu.org>
parents:
diff changeset
322 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
323 @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
324 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
325 @chapter New Indentation Engine
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
326 @cindex indentation engine
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
327 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
328
Dave Love <fx@gnu.org>
parents:
diff changeset
329 @ccmode{} has a new indentation engine, providing a simplified, yet
Dave Love <fx@gnu.org>
parents:
diff changeset
330 flexible and general mechanism for customizing indentation. It separates
Dave Love <fx@gnu.org>
parents:
diff changeset
331 indentation calculation into two steps: first, @ccmode{} analyzes the
Dave Love <fx@gnu.org>
parents:
diff changeset
332 line of code being indented to determine the kind of language construct
Dave Love <fx@gnu.org>
parents:
diff changeset
333 it's looking at, then it applies user defined offsets to the current
Dave Love <fx@gnu.org>
parents:
diff changeset
334 line based on this analysis.
Dave Love <fx@gnu.org>
parents:
diff changeset
335
Dave Love <fx@gnu.org>
parents:
diff changeset
336 This section will briefly cover how indentation is calculated in
Dave Love <fx@gnu.org>
parents:
diff changeset
337 @ccmode{}. It is important to understand the indentation model
Dave Love <fx@gnu.org>
parents:
diff changeset
338 being used so that you will know how to customize @ccmode{} for
Dave Love <fx@gnu.org>
parents:
diff changeset
339 your personal coding style.
Dave Love <fx@gnu.org>
parents:
diff changeset
340
Dave Love <fx@gnu.org>
parents:
diff changeset
341 @menu
Dave Love <fx@gnu.org>
parents:
diff changeset
342 * Syntactic Analysis::
Dave Love <fx@gnu.org>
parents:
diff changeset
343 * Indentation Calculation::
Dave Love <fx@gnu.org>
parents:
diff changeset
344 @end menu
Dave Love <fx@gnu.org>
parents:
diff changeset
345
Dave Love <fx@gnu.org>
parents:
diff changeset
346
Dave Love <fx@gnu.org>
parents:
diff changeset
347 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
348 @node Syntactic Analysis, Indentation Calculation, , New Indentation Engine
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
349 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
350 @section Syntactic Analysis
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
351 @cindex syntactic analysis
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
352 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
353
Dave Love <fx@gnu.org>
parents:
diff changeset
354 @cindex relative buffer position
Dave Love <fx@gnu.org>
parents:
diff changeset
355 @cindex syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
356 @cindex syntactic component
Dave Love <fx@gnu.org>
parents:
diff changeset
357 @cindex syntactic component list
Dave Love <fx@gnu.org>
parents:
diff changeset
358 The first thing @ccmode{} does when indenting a line of code, is to
Dave Love <fx@gnu.org>
parents:
diff changeset
359 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
360 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
361 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
362 is a @dfn{syntactic symbol}, and the second part is a @dfn{relative
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
363 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
364 @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
365 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
366 @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
367 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
368 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
369 list of currently supported syntactic symbols.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
370
Dave Love <fx@gnu.org>
parents:
diff changeset
371 Conceptually, a line of C code is always indented relative to the
Dave Love <fx@gnu.org>
parents:
diff changeset
372 indentation of some line higher up in the buffer. This is represented
Dave Love <fx@gnu.org>
parents:
diff changeset
373 by the relative buffer position in the syntactic component.
Dave Love <fx@gnu.org>
parents:
diff changeset
374
Dave Love <fx@gnu.org>
parents:
diff changeset
375 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
376 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
377 don't actually appear in the buffer, of course!}:
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
378 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
379 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
380
Dave Love <fx@gnu.org>
parents:
diff changeset
381 1: void swap( int& a, int& b )
Dave Love <fx@gnu.org>
parents:
diff changeset
382 2: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
383 3: int tmp = a;
Dave Love <fx@gnu.org>
parents:
diff changeset
384 4: a = b;
Dave Love <fx@gnu.org>
parents:
diff changeset
385 5: b = tmp;
Dave Love <fx@gnu.org>
parents:
diff changeset
386 6: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
387
Dave Love <fx@gnu.org>
parents:
diff changeset
388 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
389 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
390
Dave Love <fx@gnu.org>
parents:
diff changeset
391 @kindex C-c C-s
Dave Love <fx@gnu.org>
parents:
diff changeset
392 @findex c-show-syntactic-information
Dave Love <fx@gnu.org>
parents:
diff changeset
393 @findex show-syntactic-information (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
394 We can use the command @kbd{C-c C-s}
Dave Love <fx@gnu.org>
parents:
diff changeset
395 (@code{c-show-syntactic-information}) to simply report what the
Dave Love <fx@gnu.org>
parents:
diff changeset
396 syntactic analysis is for the current line. Running this command on
Dave Love <fx@gnu.org>
parents:
diff changeset
397 line 4 of this example, we'd see in the echo area@footnote{With a universal
Dave Love <fx@gnu.org>
parents:
diff changeset
398 argument (i.e. @kbd{C-u C-c C-s}) the analysis is inserted into the
Dave Love <fx@gnu.org>
parents:
diff changeset
399 buffer as a comment
Dave Love <fx@gnu.org>
parents:
diff changeset
400 on the current line.}:
Dave Love <fx@gnu.org>
parents:
diff changeset
401 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
402
Dave Love <fx@gnu.org>
parents:
diff changeset
403 ((statement . 35))
Dave Love <fx@gnu.org>
parents:
diff changeset
404
Dave Love <fx@gnu.org>
parents:
diff changeset
405 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
406
Dave Love <fx@gnu.org>
parents:
diff changeset
407 This tells us that the line is a statement and it is indented relative
Dave Love <fx@gnu.org>
parents:
diff changeset
408 to buffer position 35, which happens to be the @samp{i} in @code{int} on
Dave Love <fx@gnu.org>
parents:
diff changeset
409 line 3. If you were to move point to line 3 and hit @kbd{C-c C-s}, you
Dave Love <fx@gnu.org>
parents:
diff changeset
410 would see:
Dave Love <fx@gnu.org>
parents:
diff changeset
411 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
412
Dave Love <fx@gnu.org>
parents:
diff changeset
413 ((defun-block-intro . 29))
Dave Love <fx@gnu.org>
parents:
diff changeset
414
Dave Love <fx@gnu.org>
parents:
diff changeset
415 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
416
Dave Love <fx@gnu.org>
parents:
diff changeset
417 This indicates that the @samp{int} line is the first statement in a top
Dave Love <fx@gnu.org>
parents:
diff changeset
418 level function block, and is indented relative to buffer position 29,
Dave Love <fx@gnu.org>
parents:
diff changeset
419 which is the brace just after the function header.
Dave Love <fx@gnu.org>
parents:
diff changeset
420
Dave Love <fx@gnu.org>
parents:
diff changeset
421 Here's another example:
Dave Love <fx@gnu.org>
parents:
diff changeset
422 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
423 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
424
Dave Love <fx@gnu.org>
parents:
diff changeset
425 1: int add( int val, int incr, int doit )
Dave Love <fx@gnu.org>
parents:
diff changeset
426 2: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
427 3: if( doit )
Dave Love <fx@gnu.org>
parents:
diff changeset
428 4: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
429 5: return( val + incr );
Dave Love <fx@gnu.org>
parents:
diff changeset
430 6: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
431 7: return( val );
Dave Love <fx@gnu.org>
parents:
diff changeset
432 8: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
433
Dave Love <fx@gnu.org>
parents:
diff changeset
434 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
435 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
436
Dave Love <fx@gnu.org>
parents:
diff changeset
437 @noindent
Dave Love <fx@gnu.org>
parents:
diff changeset
438 Hitting @kbd{C-c C-s} on line 4 gives us:
Dave Love <fx@gnu.org>
parents:
diff changeset
439 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
440
Dave Love <fx@gnu.org>
parents:
diff changeset
441 ((substatement-open . 46))
Dave Love <fx@gnu.org>
parents:
diff changeset
442
Dave Love <fx@gnu.org>
parents:
diff changeset
443 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
444
Dave Love <fx@gnu.org>
parents:
diff changeset
445 @cindex substatement
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
446 @cindex substatement block
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
447 @noindent
Dave Love <fx@gnu.org>
parents:
diff changeset
448 which tells us that this is a brace that @emph{opens} a substatement
Dave Love <fx@gnu.org>
parents:
diff changeset
449 block. @footnote{A @dfn{substatement} is the line after a
Dave Love <fx@gnu.org>
parents:
diff changeset
450 conditional statement, such as @code{if}, @code{else}, @code{while},
Dave Love <fx@gnu.org>
parents:
diff changeset
451 @code{do}, @code{switch}, etc. A @dfn{substatement
Dave Love <fx@gnu.org>
parents:
diff changeset
452 block} is a brace block following one of these conditional statements.}
Dave Love <fx@gnu.org>
parents:
diff changeset
453
Dave Love <fx@gnu.org>
parents:
diff changeset
454 @cindex comment-only line
Dave Love <fx@gnu.org>
parents:
diff changeset
455 Syntactic component lists can contain more than one component, and
Dave Love <fx@gnu.org>
parents:
diff changeset
456 individual syntactic components need not have relative buffer positions.
Dave Love <fx@gnu.org>
parents:
diff changeset
457 The most common example of this is a line that contains a @dfn{comment
Dave Love <fx@gnu.org>
parents:
diff changeset
458 only line}.
Dave Love <fx@gnu.org>
parents:
diff changeset
459 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
460 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
461
Dave Love <fx@gnu.org>
parents:
diff changeset
462 1: void draw_list( List<Drawables>& drawables )
Dave Love <fx@gnu.org>
parents:
diff changeset
463 2: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
464 3: // call the virtual draw() method on each element in list
Dave Love <fx@gnu.org>
parents:
diff changeset
465 4: for( int i=0; i < drawables.count(), ++i )
Dave Love <fx@gnu.org>
parents:
diff changeset
466 5: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
467 6: drawables[i].draw();
Dave Love <fx@gnu.org>
parents:
diff changeset
468 7: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
469 8: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
470
Dave Love <fx@gnu.org>
parents:
diff changeset
471 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
472 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
473
Dave Love <fx@gnu.org>
parents:
diff changeset
474 @noindent
Dave Love <fx@gnu.org>
parents:
diff changeset
475 Hitting @kbd{C-c C-s} on line 3 of this example gives:
Dave Love <fx@gnu.org>
parents:
diff changeset
476 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
477
Dave Love <fx@gnu.org>
parents:
diff changeset
478 ((comment-intro) (defun-block-intro . 46))
Dave Love <fx@gnu.org>
parents:
diff changeset
479
Dave Love <fx@gnu.org>
parents:
diff changeset
480 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
481
Dave Love <fx@gnu.org>
parents:
diff changeset
482 @noindent
Dave Love <fx@gnu.org>
parents:
diff changeset
483 and you can see that the syntactic component list contains two syntactic
Dave Love <fx@gnu.org>
parents:
diff changeset
484 components. Also notice that the first component,
Dave Love <fx@gnu.org>
parents:
diff changeset
485 @samp{(comment-intro)} has no relative buffer position.
Dave Love <fx@gnu.org>
parents:
diff changeset
486
Dave Love <fx@gnu.org>
parents:
diff changeset
487
Dave Love <fx@gnu.org>
parents:
diff changeset
488 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
489 @node Indentation Calculation, , Syntactic Analysis, New Indentation Engine
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
490 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
491 @section Indentation Calculation
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
492 @cindex indentation calculation
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
493 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
494
Dave Love <fx@gnu.org>
parents:
diff changeset
495 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
496 component list derived in step 1 above (@pxref{Syntactic Analysis}).
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
497 Each component contributes to the final total indentation of the line in
Dave Love <fx@gnu.org>
parents:
diff changeset
498 two ways.
Dave Love <fx@gnu.org>
parents:
diff changeset
499
Dave Love <fx@gnu.org>
parents:
diff changeset
500 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
501 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
502 the offsets to apply for those symbols. These offsets are added to a
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
503 running total.
Dave Love <fx@gnu.org>
parents:
diff changeset
504
Dave Love <fx@gnu.org>
parents:
diff changeset
505 Second, if the component has a relative buffer position, @ccmode{}
Dave Love <fx@gnu.org>
parents:
diff changeset
506 adds the column number of that position to the running total. By adding
Dave Love <fx@gnu.org>
parents:
diff changeset
507 up the offsets and columns for every syntactic component on the list,
Dave Love <fx@gnu.org>
parents:
diff changeset
508 the final total indentation for the current line is computed.
Dave Love <fx@gnu.org>
parents:
diff changeset
509
Dave Love <fx@gnu.org>
parents:
diff changeset
510 Let's use our two code examples above to see how this works. Here is
Dave Love <fx@gnu.org>
parents:
diff changeset
511 our first example again:
Dave Love <fx@gnu.org>
parents:
diff changeset
512 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
513 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
514
Dave Love <fx@gnu.org>
parents:
diff changeset
515 1: void swap( int& a, int& b )
Dave Love <fx@gnu.org>
parents:
diff changeset
516 2: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
517 3: int tmp = a;
Dave Love <fx@gnu.org>
parents:
diff changeset
518 4: a = b;
Dave Love <fx@gnu.org>
parents:
diff changeset
519 5: b = tmp;
Dave Love <fx@gnu.org>
parents:
diff changeset
520 6: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
521
Dave Love <fx@gnu.org>
parents:
diff changeset
522 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
523 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
524
Dave Love <fx@gnu.org>
parents:
diff changeset
525 Let's say point is on line 3 and we hit the @kbd{TAB} key to re-indent
Dave Love <fx@gnu.org>
parents:
diff changeset
526 the line. Remember that the syntactic component list for that
Dave Love <fx@gnu.org>
parents:
diff changeset
527 line is:
Dave Love <fx@gnu.org>
parents:
diff changeset
528 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
529
Dave Love <fx@gnu.org>
parents:
diff changeset
530 ((defun-block-intro . 29))
Dave Love <fx@gnu.org>
parents:
diff changeset
531
Dave Love <fx@gnu.org>
parents:
diff changeset
532 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
533
Dave Love <fx@gnu.org>
parents:
diff changeset
534 @noindent
Dave Love <fx@gnu.org>
parents:
diff changeset
535 @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
536 @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
537 @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
538 yielding a running total indentation of 4 spaces.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
539
Dave Love <fx@gnu.org>
parents:
diff changeset
540 Next @ccmode{} goes to buffer position 29 and asks for the current
Dave Love <fx@gnu.org>
parents:
diff changeset
541 column. This brace is in column zero, so @ccmode{}
Dave Love <fx@gnu.org>
parents:
diff changeset
542 adds @samp{0} to the running total. Since there is only one syntactic
Dave Love <fx@gnu.org>
parents:
diff changeset
543 component on the list for this line, indentation calculation is
Dave Love <fx@gnu.org>
parents:
diff changeset
544 complete, and the total indentation for the line
Dave Love <fx@gnu.org>
parents:
diff changeset
545 is 4 spaces.
Dave Love <fx@gnu.org>
parents:
diff changeset
546
Dave Love <fx@gnu.org>
parents:
diff changeset
547 Here's another example:
Dave Love <fx@gnu.org>
parents:
diff changeset
548 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
549 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
550
Dave Love <fx@gnu.org>
parents:
diff changeset
551 1: int add( int val, int incr, int doit )
Dave Love <fx@gnu.org>
parents:
diff changeset
552 2: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
553 3: if( doit )
Dave Love <fx@gnu.org>
parents:
diff changeset
554 4: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
555 5: return( val + incr );
Dave Love <fx@gnu.org>
parents:
diff changeset
556 6: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
557 7: return( val );
Dave Love <fx@gnu.org>
parents:
diff changeset
558 8: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
559
Dave Love <fx@gnu.org>
parents:
diff changeset
560 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
561 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
562
Dave Love <fx@gnu.org>
parents:
diff changeset
563 If we were to hit @kbd{TAB} on line 4 in the above example, the same
Dave Love <fx@gnu.org>
parents:
diff changeset
564 basic process is performed, despite the differences in the syntactic
Dave Love <fx@gnu.org>
parents:
diff changeset
565 component list. Remember that the list for this line is:
Dave Love <fx@gnu.org>
parents:
diff changeset
566 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
567
Dave Love <fx@gnu.org>
parents:
diff changeset
568 ((substatement-open . 46))
Dave Love <fx@gnu.org>
parents:
diff changeset
569
Dave Love <fx@gnu.org>
parents:
diff changeset
570 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
571
Dave Love <fx@gnu.org>
parents:
diff changeset
572 Here, @ccmode{} first looks up the @code{substatement-open} symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
573 in @code{c-offsets-alist}. Let's say it finds the value @samp{4}. This
Dave Love <fx@gnu.org>
parents:
diff changeset
574 yields a running total of 4. @ccmode{} then goes to
Dave Love <fx@gnu.org>
parents:
diff changeset
575 buffer position 46, which is the @samp{i} in @code{if} on line 3. This
Dave Love <fx@gnu.org>
parents:
diff changeset
576 character is in the fourth column on that line so adding this to the
Dave Love <fx@gnu.org>
parents:
diff changeset
577 running total yields an indentation for the line of 8 spaces.
Dave Love <fx@gnu.org>
parents:
diff changeset
578
Dave Love <fx@gnu.org>
parents:
diff changeset
579 Simple, huh?
Dave Love <fx@gnu.org>
parents:
diff changeset
580
Dave Love <fx@gnu.org>
parents:
diff changeset
581 Actually, the mode usually just does The Right Thing without you having
Dave Love <fx@gnu.org>
parents:
diff changeset
582 to think about it in this much detail. But when customizing
Dave Love <fx@gnu.org>
parents:
diff changeset
583 indentation, it's helpful to understand the general indentation model
Dave Love <fx@gnu.org>
parents:
diff changeset
584 being used.
Dave Love <fx@gnu.org>
parents:
diff changeset
585
Dave Love <fx@gnu.org>
parents:
diff changeset
586 @vindex c-echo-syntactic-information-p
Dave Love <fx@gnu.org>
parents:
diff changeset
587 @vindex echo-syntactic-information-p (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
588 As you configure @ccmode{}, you might want to set the variable
Dave Love <fx@gnu.org>
parents:
diff changeset
589 @code{c-echo-syntactic-information-p} to non-@code{nil} so that the
Dave Love <fx@gnu.org>
parents:
diff changeset
590 syntactic component list and calculated offset will always be echoed in
Dave Love <fx@gnu.org>
parents:
diff changeset
591 the minibuffer when you hit @kbd{TAB}.
Dave Love <fx@gnu.org>
parents:
diff changeset
592
Dave Love <fx@gnu.org>
parents:
diff changeset
593
Dave Love <fx@gnu.org>
parents:
diff changeset
594 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
595 @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
596 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
597 @chapter Minor Modes
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
598 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
599
Dave Love <fx@gnu.org>
parents:
diff changeset
600 @ccmode{} contains two minor-mode-like features that you should
Dave Love <fx@gnu.org>
parents:
diff changeset
601 find useful while you enter new C code. The first is called
Dave Love <fx@gnu.org>
parents:
diff changeset
602 @dfn{auto-newline} mode, and the second is called @dfn{hungry-delete}
Dave Love <fx@gnu.org>
parents:
diff changeset
603 mode. These minor modes can be toggled on and off independently, and
Dave Love <fx@gnu.org>
parents:
diff changeset
604 @ccmode{} can be configured so that it starts up with any
Dave Love <fx@gnu.org>
parents:
diff changeset
605 combination of these minor modes. By default, both of these minor modes
Dave Love <fx@gnu.org>
parents:
diff changeset
606 are turned off.
Dave Love <fx@gnu.org>
parents:
diff changeset
607
Dave Love <fx@gnu.org>
parents:
diff changeset
608 The state of the minor modes is always reflected in the minor mode list
Dave Love <fx@gnu.org>
parents:
diff changeset
609 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
610 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
611 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
612 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
613 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
614 you'd see @samp{C/ah}.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
615
Dave Love <fx@gnu.org>
parents:
diff changeset
616 @kindex C-c C-a
Dave Love <fx@gnu.org>
parents:
diff changeset
617 @kindex C-c C-d
Dave Love <fx@gnu.org>
parents:
diff changeset
618 @kindex C-c C-t
Dave Love <fx@gnu.org>
parents:
diff changeset
619 @findex c-toggle-hungry-state
Dave Love <fx@gnu.org>
parents:
diff changeset
620 @findex c-toggle-auto-state
Dave Love <fx@gnu.org>
parents:
diff changeset
621 @findex c-toggle-auto-hungry-state
Dave Love <fx@gnu.org>
parents:
diff changeset
622 @findex toggle-hungry-state (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
623 @findex toggle-auto-state (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
624 @findex toggle-auto-hungry-state (c-)
39267
a8c0a02f6129 Spelling corrections.
Richard M. Stallman <rms@gnu.org>
parents: 36924
diff changeset
625 @ccmode{} provides key bindings which allow you to toggle the minor
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
626 modes on the fly while editing code. To toggle just the auto-newline
Dave Love <fx@gnu.org>
parents:
diff changeset
627 state, hit @kbd{C-c C-a} (@code{c-toggle-auto-state}). When you do
Dave Love <fx@gnu.org>
parents:
diff changeset
628 this, you should see the @samp{a} indicator either appear or disappear
Dave Love <fx@gnu.org>
parents:
diff changeset
629 on the modeline. Similarly, to toggle just the hungry-delete state, use
Dave Love <fx@gnu.org>
parents:
diff changeset
630 @kbd{C-c C-d} (@code{c-toggle-hungry-state}), and to toggle both states,
Dave Love <fx@gnu.org>
parents:
diff changeset
631 use @kbd{C-c C-t} (@code{c-toggle-auto-hungry-state}).
Dave Love <fx@gnu.org>
parents:
diff changeset
632
Dave Love <fx@gnu.org>
parents:
diff changeset
633 To set up the auto-newline and hungry-delete states to your preferred
Dave Love <fx@gnu.org>
parents:
diff changeset
634 values, you would need to add some lisp to your @file{.emacs} file that
Dave Love <fx@gnu.org>
parents:
diff changeset
635 called one of the @code{c-toggle-*-state} functions directly. When
Dave Love <fx@gnu.org>
parents:
diff changeset
636 called programmatically, each function takes a numeric value, where
Dave Love <fx@gnu.org>
parents:
diff changeset
637 a positive number enables the minor mode, a negative number disables the
Dave Love <fx@gnu.org>
parents:
diff changeset
638 mode, and zero toggles the current state of the mode.
Dave Love <fx@gnu.org>
parents:
diff changeset
639
Dave Love <fx@gnu.org>
parents:
diff changeset
640 So for example, if you wanted to enable both auto-newline and
Dave Love <fx@gnu.org>
parents:
diff changeset
641 hungry-delete for all your C file editing, you could add the following
Dave Love <fx@gnu.org>
parents:
diff changeset
642 to your @file{.emacs} file:
Dave Love <fx@gnu.org>
parents:
diff changeset
643 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
644
Dave Love <fx@gnu.org>
parents:
diff changeset
645 (add-hook 'c-mode-common-hook
34151
33df9c2e70bf Don't quote lambdas.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30396
diff changeset
646 (lambda () (c-toggle-auto-hungry-state 1)))
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
647
Dave Love <fx@gnu.org>
parents:
diff changeset
648 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
649
Dave Love <fx@gnu.org>
parents:
diff changeset
650
Dave Love <fx@gnu.org>
parents:
diff changeset
651 @cindex electric characters
Dave Love <fx@gnu.org>
parents:
diff changeset
652
Dave Love <fx@gnu.org>
parents:
diff changeset
653 @menu
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
654 * Auto-newline Insertion::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
655 * Hungry-deletion of Whitespace::
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
656 @end menu
Dave Love <fx@gnu.org>
parents:
diff changeset
657
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
658
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
659 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
660 @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
661 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
662 @section Auto-newline Insertion
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
663 @cindex auto-newline insertion
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
664 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
665
Dave Love <fx@gnu.org>
parents:
diff changeset
666 @cindex electric commands
Dave Love <fx@gnu.org>
parents:
diff changeset
667 Auto-newline minor mode works by enabling certain @dfn{electric
Dave Love <fx@gnu.org>
parents:
diff changeset
668 commands}. Electric commands are typically bound to special characters
Dave Love <fx@gnu.org>
parents:
diff changeset
669 such as the left and right braces, colons, semi-colons, etc., which when
Dave Love <fx@gnu.org>
parents:
diff changeset
670 typed, perform some magic formatting in addition to inserting the typed
Dave Love <fx@gnu.org>
parents:
diff changeset
671 character. As a general rule, electric commands are only electric when
Dave Love <fx@gnu.org>
parents:
diff changeset
672 the following conditions apply:
Dave Love <fx@gnu.org>
parents:
diff changeset
673
Dave Love <fx@gnu.org>
parents:
diff changeset
674 @itemize @bullet
Dave Love <fx@gnu.org>
parents:
diff changeset
675 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
676 Auto-newline minor mode is enabled, as evidenced by a @samp{C/a} or
Dave Love <fx@gnu.org>
parents:
diff changeset
677 @samp{C/ah} indicator on the modeline.
Dave Love <fx@gnu.org>
parents:
diff changeset
678
Dave Love <fx@gnu.org>
parents:
diff changeset
679 @cindex literal
Dave Love <fx@gnu.org>
parents:
diff changeset
680 @cindex syntactic whitespace
Dave Love <fx@gnu.org>
parents:
diff changeset
681 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
682 The character was not typed inside of a literal @footnote{A
Dave Love <fx@gnu.org>
parents:
diff changeset
683 @dfn{literal} is defined as any comment, string, or C preprocessor macro
Dave Love <fx@gnu.org>
parents:
diff changeset
684 definition. These constructs are also known as @dfn{syntactic
Dave Love <fx@gnu.org>
parents:
diff changeset
685 whitespace} since they are usually ignored when scanning C code.}.
Dave Love <fx@gnu.org>
parents:
diff changeset
686
Dave Love <fx@gnu.org>
parents:
diff changeset
687 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
688 @kindex C-u
Dave Love <fx@gnu.org>
parents:
diff changeset
689 No numeric argument was supplied to the command (i.e. it was typed as
Dave Love <fx@gnu.org>
parents:
diff changeset
690 normal, with no @kbd{C-u} prefix).
Dave Love <fx@gnu.org>
parents:
diff changeset
691
Dave Love <fx@gnu.org>
parents:
diff changeset
692 @end itemize
Dave Love <fx@gnu.org>
parents:
diff changeset
693
Dave Love <fx@gnu.org>
parents:
diff changeset
694 @menu
Dave Love <fx@gnu.org>
parents:
diff changeset
695 * Hanging Braces::
Dave Love <fx@gnu.org>
parents:
diff changeset
696 * Hanging Colons::
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
697 * Hanging Semi-colons and Commas::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
698 * Other Electric Commands::
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
699 * Clean-ups::
Dave Love <fx@gnu.org>
parents:
diff changeset
700 @end menu
Dave Love <fx@gnu.org>
parents:
diff changeset
701
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
702
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
703 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
704 @node Hanging Braces, Hanging Colons, , Auto-newline Insertion
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
705 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
706 @subsection Hanging Braces
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
707 @cindex hanging braces
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
708 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
709
Dave Love <fx@gnu.org>
parents:
diff changeset
710 @findex c-electric-brace
Dave Love <fx@gnu.org>
parents:
diff changeset
711 @findex electric-brace (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
712 @vindex c-hanging-braces-alist
Dave Love <fx@gnu.org>
parents:
diff changeset
713 @vindex hanging-braces-alist (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
714 When you type either an open or close brace (i.e. @kbd{@{} or @kbd{@}}),
Dave Love <fx@gnu.org>
parents:
diff changeset
715 the electric command @code{c-electric-brace} gets run. This command has
Dave Love <fx@gnu.org>
parents:
diff changeset
716 two electric formatting behaviors. First, it will perform some
Dave Love <fx@gnu.org>
parents:
diff changeset
717 re-indentation of the line the brace was typed on, and second, it will
Dave Love <fx@gnu.org>
parents:
diff changeset
718 add various newlines before and/or after the typed brace.
Dave Love <fx@gnu.org>
parents:
diff changeset
719 Re-indentation occurs automatically whenever the electric behavior is
Dave Love <fx@gnu.org>
parents:
diff changeset
720 enabled. If the brace ends up on a line other than the one it was typed
Dave Love <fx@gnu.org>
parents:
diff changeset
721 on, then that line is also re-indented.
Dave Love <fx@gnu.org>
parents:
diff changeset
722
Dave Love <fx@gnu.org>
parents:
diff changeset
723 @cindex class-open syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
724 @cindex class-close syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
725 @cindex defun-open syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
726 @cindex defun-close syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
727 @cindex inline-open syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
728 @cindex inline-close syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
729 @cindex brace-list-open syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
730 @cindex brace-list-close syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
731 @cindex brace-list-intro syntactic symbol
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
732 @cindex brace-entry-open syntactic symbol
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
733 @cindex block-open syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
734 @cindex block-close syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
735 @cindex substatement-open syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
736 @cindex statement-case-open syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
737 @cindex extern-lang-open syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
738 @cindex extern-lang-close syntactic symbol
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
739 @cindex namespace-open syntactic symbol
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
740 @cindex namespace-close syntactic symbol
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
741 @cindex inexpr-class-open symbol
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
742 @cindex inexpr-class-close symbol
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
743
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
744 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
745 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
746 @code{c-hanging-braces-alist} style variable. This variable contains a
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
747 mapping between syntactic symbols related to braces, and a list of
Dave Love <fx@gnu.org>
parents:
diff changeset
748 places to insert a newline. The syntactic symbols that are useful for
Dave Love <fx@gnu.org>
parents:
diff changeset
749 this list are: @code{class-open}, @code{class-close}, @code{defun-open},
Dave Love <fx@gnu.org>
parents:
diff changeset
750 @code{defun-close}, @code{inline-open}, @code{inline-close},
Dave Love <fx@gnu.org>
parents:
diff changeset
751 @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
752 @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
753 @code{block-close}, @code{substatement-open},
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
754 @code{statement-case-open}, @code{extern-lang-open},
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
755 @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
756 @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
757 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
758 @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
759 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
760 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
761 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
762 description of these syntactic symbols, except for
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
763 @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
764 actual syntactic symbols.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
765
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
766 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
767 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
768 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
769 braces of anonymous classes produces a combination of
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
770 @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
771 normal indentation analysis.}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
772
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
773 The value associated with each syntactic symbol in this association list
Dave Love <fx@gnu.org>
parents:
diff changeset
774 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
775 @xref{Custom Brace and Colon Hanging}, for a more detailed discussion of
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
776 using a function as a brace hanging @var{ACTION}.
Dave Love <fx@gnu.org>
parents:
diff changeset
777
Dave Love <fx@gnu.org>
parents:
diff changeset
778 When the @var{ACTION} is a list, it can contain any combination of the
Dave Love <fx@gnu.org>
parents:
diff changeset
779 symbols @code{before} and @code{after}, directing @ccmode{} where to
Dave Love <fx@gnu.org>
parents:
diff changeset
780 put newlines in relationship to the brace being inserted. Thus, if the
Dave Love <fx@gnu.org>
parents:
diff changeset
781 list contains only the symbol @code{after}, then the brace is said to
Dave Love <fx@gnu.org>
parents:
diff changeset
782 @dfn{hang} on the right side of the line, as in:
Dave Love <fx@gnu.org>
parents:
diff changeset
783 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
784 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
785
Dave Love <fx@gnu.org>
parents:
diff changeset
786 // here, open braces always `hang'
Dave Love <fx@gnu.org>
parents:
diff changeset
787 void spam( int i ) @{
Dave Love <fx@gnu.org>
parents:
diff changeset
788 if( i == 7 ) @{
Dave Love <fx@gnu.org>
parents:
diff changeset
789 dosomething(i);
Dave Love <fx@gnu.org>
parents:
diff changeset
790 @}
Dave Love <fx@gnu.org>
parents:
diff changeset
791 @}
Dave Love <fx@gnu.org>
parents:
diff changeset
792
Dave Love <fx@gnu.org>
parents:
diff changeset
793
Dave Love <fx@gnu.org>
parents:
diff changeset
794 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
795 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
796
Dave Love <fx@gnu.org>
parents:
diff changeset
797 When the list contains both @code{after} and @code{before}, the braces
Dave Love <fx@gnu.org>
parents:
diff changeset
798 will appear on a line by themselves, as shown by the close braces in the
Dave Love <fx@gnu.org>
parents:
diff changeset
799 above example. The list can also be empty, in which case no newlines
Dave Love <fx@gnu.org>
parents:
diff changeset
800 are added either before or after the brace.
Dave Love <fx@gnu.org>
parents:
diff changeset
801
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
802 If a syntactic symbol is missing entirely from
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
803 @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
804 @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
805 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
806
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
807 For example, the default value of @code{c-hanging-braces-alist} is:
Dave Love <fx@gnu.org>
parents:
diff changeset
808 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
809 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
810
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
811 ((brace-list-open)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
812 (brace-entry-open)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
813 (substatement-open after)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
814 (block-close . c-snug-do-while)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
815 (extern-lang-open after)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
816 (inexpr-class-open after)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
817 (inexpr-class-close before))
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
818
Dave Love <fx@gnu.org>
parents:
diff changeset
819 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
820 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
821
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
822 @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
823 @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
824 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
825 @code{substatement-open}, @code{extern-lang-open}, and
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
826 @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
827 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
828 @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
829 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
830 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
831 other cases, braces are put on a line by themselves.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
832
Dave Love <fx@gnu.org>
parents:
diff changeset
833 A word of caution: it is not a good idea to hang top-level construct
Dave Love <fx@gnu.org>
parents:
diff changeset
834 introducing braces, such as @code{class-open} or @code{defun-open}.
Dave Love <fx@gnu.org>
parents:
diff changeset
835 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
836 zero, hanging them can introduce performance problems.
26490
2b08d829af86 Fix complaints from makeinfo 4.0.
Eli Zaretskii <eliz@gnu.org>
parents: 25829
diff changeset
837 @xref{Performance Issues}, for more information.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
838
Dave Love <fx@gnu.org>
parents:
diff changeset
839
Dave Love <fx@gnu.org>
parents:
diff changeset
840 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
841 @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
842 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
843 @subsection Hanging Colons
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
844 @cindex hanging colons
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
845 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
846
Dave Love <fx@gnu.org>
parents:
diff changeset
847 @vindex hanging-colons-alist (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
848 @vindex c-hanging-colons-alist
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
849 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
850 colons can also be made to hang using the style variable
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
851 @code{c-hanging-colons-alist}. The syntactic symbols appropriate for
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
852 this association list are: @code{case-label}, @code{label},
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
853 @code{access-label}, @code{member-init-intro}, and @code{inher-intro}.
Dave Love <fx@gnu.org>
parents:
diff changeset
854 Note however that for @code{c-hanging-colons-alist}, @var{ACTION}s as
Dave Love <fx@gnu.org>
parents:
diff changeset
855 functions are not supported. See also @ref{Custom Brace and Colon
Dave Love <fx@gnu.org>
parents:
diff changeset
856 Hanging} for details.
Dave Love <fx@gnu.org>
parents:
diff changeset
857
Dave Love <fx@gnu.org>
parents:
diff changeset
858 In C++, double-colons are used as a scope operator but because these
Dave Love <fx@gnu.org>
parents:
diff changeset
859 colons always appear right next to each other, newlines before and after
Dave Love <fx@gnu.org>
parents:
diff changeset
860 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
861 @ccmode{}. @xref{Clean-ups}, for details.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
862
Dave Love <fx@gnu.org>
parents:
diff changeset
863
Dave Love <fx@gnu.org>
parents:
diff changeset
864 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
865 @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
866 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
867 @subsection Hanging Semi-colons and Commas
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
868 @cindex hanging semi-colons
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
869 @cindex hanging commas
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
870 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
871
Dave Love <fx@gnu.org>
parents:
diff changeset
872 Semicolons and commas are also electric in @ccmode{}, but since
Dave Love <fx@gnu.org>
parents:
diff changeset
873 these characters do not correspond directly to syntactic symbols, a
Dave Love <fx@gnu.org>
parents:
diff changeset
874 different mechanism is used to determine whether newlines should be
Dave Love <fx@gnu.org>
parents:
diff changeset
875 automatically inserted after these characters. @xref{Customizing
26490
2b08d829af86 Fix complaints from makeinfo 4.0.
Eli Zaretskii <eliz@gnu.org>
parents: 25829
diff changeset
876 Semi-colons and Commas}, for details.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
877
Dave Love <fx@gnu.org>
parents:
diff changeset
878
Dave Love <fx@gnu.org>
parents:
diff changeset
879 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
880 @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
881 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
882 @subsection Other Electric Commands
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
883 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
884
Dave Love <fx@gnu.org>
parents:
diff changeset
885 @kindex #
Dave Love <fx@gnu.org>
parents:
diff changeset
886 @findex c-electric-pound
Dave Love <fx@gnu.org>
parents:
diff changeset
887 @vindex c-electric-pound-behavior
Dave Love <fx@gnu.org>
parents:
diff changeset
888 @findex electric-pound (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
889 @vindex electric-pound-behavior (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
890 A few other keys also provide electric behavior. For example
Dave Love <fx@gnu.org>
parents:
diff changeset
891 @kbd{#} (@code{c-electric-pound}) is electric when typed as
Dave Love <fx@gnu.org>
parents:
diff changeset
892 the first non-whitespace character on a line. In this case, the
Dave Love <fx@gnu.org>
parents:
diff changeset
893 variable @code{c-electric-pound-behavior} is consulted for the electric
Dave Love <fx@gnu.org>
parents:
diff changeset
894 behavior. This variable takes a list value, although the only element
Dave Love <fx@gnu.org>
parents:
diff changeset
895 currently defined is @code{alignleft}, which tells this command to force
Dave Love <fx@gnu.org>
parents:
diff changeset
896 the @samp{#} character into column zero. This is useful for entering
Dave Love <fx@gnu.org>
parents:
diff changeset
897 C preprocessor macro definitions.
Dave Love <fx@gnu.org>
parents:
diff changeset
898
Dave Love <fx@gnu.org>
parents:
diff changeset
899 @findex c-electric-star
Dave Love <fx@gnu.org>
parents:
diff changeset
900 @findex c-electric-slash
Dave Love <fx@gnu.org>
parents:
diff changeset
901 @findex electric-star (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
902 @findex electric-slash (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
903 Stars and slashes (i.e. @kbd{*} and @kbd{/}, @code{c-electric-star} and
Dave Love <fx@gnu.org>
parents:
diff changeset
904 @code{c-electric-slash} respectively) are also electric under
Dave Love <fx@gnu.org>
parents:
diff changeset
905 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
906 a C style block comment on a comment-only line, then the comment
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
907 delimiter is indented as defined by @code{c-offsets-alist}. A
Dave Love <fx@gnu.org>
parents:
diff changeset
908 comment-only line is defined as a line which contains only a comment, as
Dave Love <fx@gnu.org>
parents:
diff changeset
909 in:
Dave Love <fx@gnu.org>
parents:
diff changeset
910 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
911 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
912
Dave Love <fx@gnu.org>
parents:
diff changeset
913 void spam( int i )
Dave Love <fx@gnu.org>
parents:
diff changeset
914 @{
Dave Love <fx@gnu.org>
parents:
diff changeset
915 // this is a comment-only line...
Dave Love <fx@gnu.org>
parents:
diff changeset
916 if( i == 7 ) // but this is not
Dave Love <fx@gnu.org>
parents:
diff changeset
917 @{
Dave Love <fx@gnu.org>
parents:
diff changeset
918 dosomething(i);
Dave Love <fx@gnu.org>
parents:
diff changeset
919 @}
Dave Love <fx@gnu.org>
parents:
diff changeset
920 @}
Dave Love <fx@gnu.org>
parents:
diff changeset
921
Dave Love <fx@gnu.org>
parents:
diff changeset
922 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
923 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
924
Dave Love <fx@gnu.org>
parents:
diff changeset
925 Likewise, if a slash is inserted as the second slash in a C++ style line
Dave Love <fx@gnu.org>
parents:
diff changeset
926 comment (also only on a comment-only line), then the line is indented as
Dave Love <fx@gnu.org>
parents:
diff changeset
927 defined by @code{c-offsets-alist}.
Dave Love <fx@gnu.org>
parents:
diff changeset
928
Dave Love <fx@gnu.org>
parents:
diff changeset
929 @findex c-electric-lt-gt
Dave Love <fx@gnu.org>
parents:
diff changeset
930 @findex electric-lt-gt (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
931 @kindex <
Dave Love <fx@gnu.org>
parents:
diff changeset
932 @kindex >
Dave Love <fx@gnu.org>
parents:
diff changeset
933 Less-than and greater-than signs (@code{c-electric-lt-gt}) are also
Dave Love <fx@gnu.org>
parents:
diff changeset
934 electric, but only in C++ mode. Hitting the second of two @kbd{<} or
Dave Love <fx@gnu.org>
parents:
diff changeset
935 @kbd{>} keys re-indents the line if it is a C++ style stream operator.
Dave Love <fx@gnu.org>
parents:
diff changeset
936
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
937 @findex c-electric-paren
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
938 @findex electric-paren (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
939 @kindex (
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
940 @kindex )
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
941 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
942 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
943 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
944 automatically.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
945
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
946
Dave Love <fx@gnu.org>
parents:
diff changeset
947 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
948 @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
949 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
950 @subsection Clean-ups
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
951 @cindex clean-ups
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
952 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
953
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
954 @dfn{Clean-ups} are mechanisms complementary to colon and brace hanging.
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
955 On the surface, it would seem that clean-ups overlap the functionality
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
956 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
957 however used to adjust code ``after-the-fact,'' i.e. to adjust the
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
958 whitespace in constructs after they are typed.
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
959
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
960 Most of the clean-ups are only applicable to counteract automatically
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
961 inserted newlines, and will therefore only have any effect if the
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
962 auto-newline minor mode is turned on. Others will work all the time.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
963
Dave Love <fx@gnu.org>
parents:
diff changeset
964 @vindex c-cleanup-list
Dave Love <fx@gnu.org>
parents:
diff changeset
965 @vindex cleanup-list (c-)
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
966 @cindex literal
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
967 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
968 @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
969 @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
970 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
971 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
972 (@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
973 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
974
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
975 These are the clean-ups that only are active in the auto-newline minor
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
976 mode:
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
977
Dave Love <fx@gnu.org>
parents:
diff changeset
978 @itemize @bullet
Dave Love <fx@gnu.org>
parents:
diff changeset
979 @item
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
980 @code{brace-else-brace} --- Clean up @samp{@} else @{} constructs by
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
981 placing the entire construct on a single line. Clean-up occurs when the
Dave Love <fx@gnu.org>
parents:
diff changeset
982 open brace after the @samp{else} is typed. So for example, this:
Dave Love <fx@gnu.org>
parents:
diff changeset
983 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
984 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
985
Dave Love <fx@gnu.org>
parents:
diff changeset
986 void spam(int i)
Dave Love <fx@gnu.org>
parents:
diff changeset
987 @{
Dave Love <fx@gnu.org>
parents:
diff changeset
988 if( i==7 )
Dave Love <fx@gnu.org>
parents:
diff changeset
989 @{
Dave Love <fx@gnu.org>
parents:
diff changeset
990 dosomething();
Dave Love <fx@gnu.org>
parents:
diff changeset
991 @}
Dave Love <fx@gnu.org>
parents:
diff changeset
992 else
Dave Love <fx@gnu.org>
parents:
diff changeset
993 @{
Dave Love <fx@gnu.org>
parents:
diff changeset
994
Dave Love <fx@gnu.org>
parents:
diff changeset
995 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
996 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
997 @noindent
Dave Love <fx@gnu.org>
parents:
diff changeset
998 appears like this after the open brace is typed:
Dave Love <fx@gnu.org>
parents:
diff changeset
999 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
1000 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
1001
Dave Love <fx@gnu.org>
parents:
diff changeset
1002 void spam(int i)
Dave Love <fx@gnu.org>
parents:
diff changeset
1003 @{
Dave Love <fx@gnu.org>
parents:
diff changeset
1004 if( i==7 ) @{
Dave Love <fx@gnu.org>
parents:
diff changeset
1005 dosomething();
Dave Love <fx@gnu.org>
parents:
diff changeset
1006 @} else @{
Dave Love <fx@gnu.org>
parents:
diff changeset
1007
Dave Love <fx@gnu.org>
parents:
diff changeset
1008 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
1009 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
1010
Dave Love <fx@gnu.org>
parents:
diff changeset
1011 @item
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1012 @code{brace-elseif-brace} --- Similar to the @code{brace-else-brace}
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1013 clean-up, but this cleans up @samp{@} else if (...) @{} constructs. For
Dave Love <fx@gnu.org>
parents:
diff changeset
1014 example:
Dave Love <fx@gnu.org>
parents:
diff changeset
1015 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
1016 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
1017
Dave Love <fx@gnu.org>
parents:
diff changeset
1018 void spam(int i)
Dave Love <fx@gnu.org>
parents:
diff changeset
1019 @{
Dave Love <fx@gnu.org>
parents:
diff changeset
1020 if( i==7 )
Dave Love <fx@gnu.org>
parents:
diff changeset
1021 @{
Dave Love <fx@gnu.org>
parents:
diff changeset
1022 dosomething();
Dave Love <fx@gnu.org>
parents:
diff changeset
1023 @}
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1024 else if( i==3 )
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1025 @{
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1026
Dave Love <fx@gnu.org>
parents:
diff changeset
1027 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
1028 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
1029 @noindent
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1030 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
1031 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1032 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1033
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1034 void spam(int i)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1035 @{
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1036 if( i==7 ) @{
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1037 dosomething();
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1038 @} else if( i==3 )
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
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1041 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1042 @end example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1043 @noindent
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1044 and like this after the open brace is typed:
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1045 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
1046 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
1047
Dave Love <fx@gnu.org>
parents:
diff changeset
1048 void spam(int i)
Dave Love <fx@gnu.org>
parents:
diff changeset
1049 @{
Dave Love <fx@gnu.org>
parents:
diff changeset
1050 if( i==7 ) @{
Dave Love <fx@gnu.org>
parents:
diff changeset
1051 dosomething();
Dave Love <fx@gnu.org>
parents:
diff changeset
1052 @} else if( i==3 ) @{
Dave Love <fx@gnu.org>
parents:
diff changeset
1053
Dave Love <fx@gnu.org>
parents:
diff changeset
1054 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
1055 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
1056
Dave Love <fx@gnu.org>
parents:
diff changeset
1057 @item
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1058 @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
1059 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
1060
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1061 @item
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1062 @code{empty-defun-braces} --- Clean up braces following a top-level
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1063 function or class definition that contains no body. Clean up occurs
Dave Love <fx@gnu.org>
parents:
diff changeset
1064 when the closing brace is typed. Thus the following:
Dave Love <fx@gnu.org>
parents:
diff changeset
1065 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
1066 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
1067
Dave Love <fx@gnu.org>
parents:
diff changeset
1068 class Spam
Dave Love <fx@gnu.org>
parents:
diff changeset
1069 @{
Dave Love <fx@gnu.org>
parents:
diff changeset
1070 @}
Dave Love <fx@gnu.org>
parents:
diff changeset
1071
Dave Love <fx@gnu.org>
parents:
diff changeset
1072 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
1073 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
1074 @noindent
Dave Love <fx@gnu.org>
parents:
diff changeset
1075 is transformed into this when the close brace is typed:
Dave Love <fx@gnu.org>
parents:
diff changeset
1076 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
1077 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
1078
Dave Love <fx@gnu.org>
parents:
diff changeset
1079 class Spam
Dave Love <fx@gnu.org>
parents:
diff changeset
1080 @{@}
Dave Love <fx@gnu.org>
parents:
diff changeset
1081
Dave Love <fx@gnu.org>
parents:
diff changeset
1082 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
1083 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
1084
Dave Love <fx@gnu.org>
parents:
diff changeset
1085 @item
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1086 @code{defun-close-semi} --- Clean up the terminating semi-colon on
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1087 top-level function or class definitions when they follow a close
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1088 brace. Clean up occurs when the semi-colon is typed.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1089 So for example, the following:
Dave Love <fx@gnu.org>
parents:
diff changeset
1090 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
1091 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
1092
Dave Love <fx@gnu.org>
parents:
diff changeset
1093 class Spam
Dave Love <fx@gnu.org>
parents:
diff changeset
1094 @{
Dave Love <fx@gnu.org>
parents:
diff changeset
1095 @}
Dave Love <fx@gnu.org>
parents:
diff changeset
1096 ;
Dave Love <fx@gnu.org>
parents:
diff changeset
1097
Dave Love <fx@gnu.org>
parents:
diff changeset
1098 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
1099 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
1100 @noindent
Dave Love <fx@gnu.org>
parents:
diff changeset
1101 is transformed into this when the semi-colon is typed:
Dave Love <fx@gnu.org>
parents:
diff changeset
1102
Dave Love <fx@gnu.org>
parents:
diff changeset
1103 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
1104 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
1105
Dave Love <fx@gnu.org>
parents:
diff changeset
1106 class Spam
Dave Love <fx@gnu.org>
parents:
diff changeset
1107 @{
Dave Love <fx@gnu.org>
parents:
diff changeset
1108 @};
Dave Love <fx@gnu.org>
parents:
diff changeset
1109
Dave Love <fx@gnu.org>
parents:
diff changeset
1110 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
1111 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
1112
Dave Love <fx@gnu.org>
parents:
diff changeset
1113 @item
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1114 @code{list-close-comma} --- Clean up commas following braces in array
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1115 and aggregate initializers. Clean up occurs when the comma is typed.
Dave Love <fx@gnu.org>
parents:
diff changeset
1116
Dave Love <fx@gnu.org>
parents:
diff changeset
1117 @item
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1118 @code{scope-operator} --- Clean up double colons which may designate a
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1119 C++ scope operator split across multiple lines@footnote{Certain C++
Dave Love <fx@gnu.org>
parents:
diff changeset
1120 constructs introduce ambiguous situations, so @code{scope-operator}
Dave Love <fx@gnu.org>
parents:
diff changeset
1121 clean-ups may not always be correct. This usually only occurs when
Dave Love <fx@gnu.org>
parents:
diff changeset
1122 scoped identifiers appear in switch label tags.}. Clean up occurs when
Dave Love <fx@gnu.org>
parents:
diff changeset
1123 the second colon is typed. You will always want @code{scope-operator}
Dave Love <fx@gnu.org>
parents:
diff changeset
1124 in the @code{c-cleanup-list} when you are editing C++ code.
Dave Love <fx@gnu.org>
parents:
diff changeset
1125
Dave Love <fx@gnu.org>
parents:
diff changeset
1126 @end itemize
Dave Love <fx@gnu.org>
parents:
diff changeset
1127
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1128 The following clean-ups are always active when they occur on
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1129 @code{c-cleanup-list}, and are thus not affected by the auto-newline
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1130 minor mode:
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1131
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1132 @itemize @bullet
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1133 @item
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1134 @code{space-before-funcall} --- Insert a space between the function name
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1135 and the opening parenthesis of a function call. This produces function
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1136 calls in the style mandated by the GNU coding standards,
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1137 e.g. @samp{signal (SIGINT, SIG_IGN)} and @samp{abort ()}. Clean up
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1138 occurs when the opening parenthesis is typed.
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1139
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1140 @item
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1141 @code{compact-empty-funcall} --- Clean up any space between the function
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1142 name and the opening parenthesis of a function call that have no
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1143 arguments. This is typically used together with
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1144 @code{space-before-funcall} if you prefer the GNU function call style
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1145 for functions with arguments but think it looks ugly when it's only an
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1146 empty parenthesis pair. I.e. you will get @samp{signal (SIGINT,
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1147 SIG_IGN)}, but @samp{abort()}. Clean up occurs when the closing
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1148 parenthesis is typed.
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1149
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1150 @end itemize
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1151
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1152
Dave Love <fx@gnu.org>
parents:
diff changeset
1153 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1154 @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
1155 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1156 @section Hungry-deletion of Whitespace
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1157 @cindex hungry-deletion of whitespace
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1158 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
1159
Dave Love <fx@gnu.org>
parents:
diff changeset
1160 Hungry deletion of whitespace, or as it more commonly called,
Dave Love <fx@gnu.org>
parents:
diff changeset
1161 @dfn{hungry-delete mode}, is a simple feature that some people find
Dave Love <fx@gnu.org>
parents:
diff changeset
1162 extremely useful. In fact, you might find yourself wanting
Dave Love <fx@gnu.org>
parents:
diff changeset
1163 hungry-delete in @strong{all} your editing modes!
Dave Love <fx@gnu.org>
parents:
diff changeset
1164
Dave Love <fx@gnu.org>
parents:
diff changeset
1165 @kindex DEL
Dave Love <fx@gnu.org>
parents:
diff changeset
1166 @kindex Backspace
Dave Love <fx@gnu.org>
parents:
diff changeset
1167 In a nutshell, when hungry-delete mode is enabled, hitting the
Dave Love <fx@gnu.org>
parents:
diff changeset
1168 @key{Backspace} key@footnote{I say ``hit the @key{Backspace} key'' but
Dave Love <fx@gnu.org>
parents:
diff changeset
1169 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
1170 event.'' The difference usually isn't significant to most users, but
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1171 advanced users will realize that under window systems such as X, any
Dave Love <fx@gnu.org>
parents:
diff changeset
1172 physical key (keycap) on the keyboard can be configured to generate any
Dave Love <fx@gnu.org>
parents:
diff changeset
1173 keysym, and thus any Emacs key event. Also, the use of Emacs on TTYs
Dave Love <fx@gnu.org>
parents:
diff changeset
1174 will affect which keycap generates which key event. From a pedantic
Dave Love <fx@gnu.org>
parents:
diff changeset
1175 point of view, here we are only concerned with the key event that
Dave Love <fx@gnu.org>
parents:
diff changeset
1176 Emacs receives.} will consume all preceding whitespace, including
Dave Love <fx@gnu.org>
parents:
diff changeset
1177 newlines and tabs. This can really cut down on the number of
Dave Love <fx@gnu.org>
parents:
diff changeset
1178 @key{Backspace}'s you have to type if, for example you made a mistake on
Dave Love <fx@gnu.org>
parents:
diff changeset
1179 the preceding line.
Dave Love <fx@gnu.org>
parents:
diff changeset
1180
Dave Love <fx@gnu.org>
parents:
diff changeset
1181 @findex c-electric-backspace
Dave Love <fx@gnu.org>
parents:
diff changeset
1182 @findex electric-backspace (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
1183 @vindex c-backspace-function
Dave Love <fx@gnu.org>
parents:
diff changeset
1184 @vindex backspace-function (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
1185
Dave Love <fx@gnu.org>
parents:
diff changeset
1186 @findex c-electric-delete
Dave Love <fx@gnu.org>
parents:
diff changeset
1187 @findex electric-delete (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
1188 @vindex c-delete-function
Dave Love <fx@gnu.org>
parents:
diff changeset
1189 @vindex delete-function (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
1190 @cindex literal
Dave Love <fx@gnu.org>
parents:
diff changeset
1191
Dave Love <fx@gnu.org>
parents:
diff changeset
1192 @findex backward-delete-char-untabify
Dave Love <fx@gnu.org>
parents:
diff changeset
1193
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1194 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
1195 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
1196 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
1197 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
1198 mode is disabled, the function contained in the
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1199 @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
1200 number of characters to delete). This variable is set to
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1201 @code{backward-delete-char-untabify} by default.
Dave Love <fx@gnu.org>
parents:
diff changeset
1202
Dave Love <fx@gnu.org>
parents:
diff changeset
1203 @vindex delete-key-deletes-forward
Dave Love <fx@gnu.org>
parents:
diff changeset
1204 @findex delete-char
Dave Love <fx@gnu.org>
parents:
diff changeset
1205
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1206 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
1207 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
1208 @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
1209 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
1210 @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
1211 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
1212 @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
1213 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
1214 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
1215 @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
1216 @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
1217 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
1218 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
1219 @code{delete-char} by default.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1220
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1221 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
1222 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
1223 explicitly binding @code{[delete]}@footnote{E.g. to
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1224 @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
1225 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
1226 @code{delete-key-deletes-forward}.}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1227
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1228 XEmacsen older than 20.3 behave similar to Emacs 19 and Emacs 20.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1229
Dave Love <fx@gnu.org>
parents:
diff changeset
1230
Dave Love <fx@gnu.org>
parents:
diff changeset
1231 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1232 @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
1233 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1234 @chapter Text Filling and Line Breaking
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1235 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
1236
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1237 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
1238 @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
1239 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
1240 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
1241 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
1242 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
1243 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
1244 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
1245 necessary.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1246
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1247 @vindex c-comment-prefix-regexp
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1248 @vindex comment-prefix-regexp (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1249 @cindex comment line prefix
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1250 @vindex comment-start
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1251 @vindex comment-end
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1252 @vindex comment-start-skip
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1253 @vindex paragraph-start
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1254 @vindex paragraph-separate
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1255 @vindex paragraph-ignore-fill-prefix
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1256 @vindex adaptive-fill-mode
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1257 @vindex adaptive-fill-regexp
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1258 @vindex adaptive-fill-first-line-regexp
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1259 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
1260 paragraphs, @ccmode{} makes several standard
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1261 variables@footnote{@code{comment-start}, @code{comment-end},
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1262 @code{comment-start-skip}, @code{paragraph-start},
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1263 @code{paragraph-separate}, @code{paragraph-ignore-fill-prefix},
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1264 @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
1265 @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
1266 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
1267 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
1268 @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
1269 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
1270 matches C++ style line comments like
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1271 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1272
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1273 // blah blah
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1274
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1275 @end example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1276
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1277 @noindent
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1278 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
1279 like
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1280 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1281 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1282
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1283 /*
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1284 * blah blah
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1285 */
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1286
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1287 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1288 @end example
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 @noindent
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1291 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
1292 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
1293 (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
1294 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
1295 @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
1296 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
1297 it inside a @ccmode{} buffer.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1298
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1299 @findex auto-fill-mode
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1300 @cindex auto fill mode
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1301 @cindex paragraph fill
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1302 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
1303 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
1304 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
1305 @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
1306 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
1307 @code{string} syntactic symbol). In comments, @ccmode{} uses
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1308 @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
1309 lines in the comment.
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 @vindex adaptive-fill-mode
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1312 @cindex adaptive fill mode
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1313 @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
1314 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
1315 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
1316 @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
1317 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
1318 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1319 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1320
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1321 /* 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
1322 * 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
1323 * Knuth,
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1324 *
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1325 * 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
1326 * proved it correct, not tried it.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1327 */
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1328
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1329 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1330 @end example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1331
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1332 @findex c-setup-filladapt
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1333 @findex setup-filladapt (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1334 @findex filladapt-mode
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1335 @vindex filladapt-mode
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1336 @cindex Filladapt mode
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1337 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
1338 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
1339 @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
1340 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
1341 @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
1342 by default). A patch for that is available from
30396
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
1343 @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
1344 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
1345 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
1346 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
1347 something like this in your @file{.emacs}:
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1348 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1349 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1350
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1351 (defun my-c-mode-common-hook ()
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1352 (c-setup-filladapt)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1353 (filladapt-mode 1))
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1354 (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
1355
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1356 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1357 @end example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1358
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1359 @vindex c-block-comment-prefix
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1360 @vindex block-comment-prefix (c-)
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1361 @vindex c-comment-continuation-stars
Dave Love <fx@gnu.org>
parents:
diff changeset
1362 @vindex comment-continuation-stars (c-)
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1363 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
1364 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
1365 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
1366 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
1367 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
1368 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
1369 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
1370 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
1371 makes a comment
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1372 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1373
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1374 /* 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
1375
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1376 @end example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1377
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1378 @noindent
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1379 break into
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1380 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1381 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1382
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1383 /* Got O(n^2) here,
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1384 * which is a Bad Thing. */
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1385
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1386 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1387 @end example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1388
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1389 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
1390 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
1391 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
1392 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
1393 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
1394 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
1395 Functions}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1396
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1397 @vindex c-ignore-auto-fill
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1398 @vindex ignore-auto-fill (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1399 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
1400 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
1401 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
1402 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
1403 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
1404 should occur:
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 @itemize @bullet
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1407 @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
1408 @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
1409 @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
1410 @item @code{cpp} --- Inside a preprocessor directive.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1411 @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
1412 @end itemize
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1413
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1414 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
1415 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
1416 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
1417 explicit control over newlines. In preprocessor directives, the
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1418 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
1419 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
1420 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
1421 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
1422 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
1423 implementation.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1424
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1425 The commands that does the actual work follows.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1426
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1427 @table @asis
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-q
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1430 @findex c-fill-paragraph
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1431 @findex fill-paragraph (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1432 @cindex Javadoc markup
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1433 @cindex Pike autodoc markup
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1434 @item @kbd{M-q} (@code{c-fill-paragraph})
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1435 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
1436 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
1437 line style comments. In Java buffers, the Javadoc markup words are
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1438 recognized as paragraph starters. The line oriented Pike autodoc markup
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1439 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
1440
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1441 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
1442 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
1443 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
1444 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
1445 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
1446 @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
1447 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
1448 obsolete.}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1449
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1450 @kindex M-j
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1451 @findex c-indent-new-comment-line
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1452 @findex indent-new-comment-line (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1453 @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
1454 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
1455 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
1456
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1457 @vindex comment-multi-line
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1458 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
1459 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
1460 @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
1461 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
1462
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1463 @findex c-context-line-break
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1464 @findex context-line-break (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1465 @item @kbd{M-x c-context-line-break}
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1466 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
1467 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
1468 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
1469 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
1470 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
1471 indentation engine.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1472
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1473 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
1474 @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
1475 @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
1476
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1477 @end table
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1478
Dave Love <fx@gnu.org>
parents:
diff changeset
1479
Dave Love <fx@gnu.org>
parents:
diff changeset
1480 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1481 @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
1482 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1483 @chapter Commands
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1484 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
1485
Dave Love <fx@gnu.org>
parents:
diff changeset
1486 @menu
Dave Love <fx@gnu.org>
parents:
diff changeset
1487 * Indentation Commands::
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1488 * Movement Commands::
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1489 * Other Commands::
Dave Love <fx@gnu.org>
parents:
diff changeset
1490 @end menu
Dave Love <fx@gnu.org>
parents:
diff changeset
1491
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1492 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
1493 that bit.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1494
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1495
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1496 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1497 @node Indentation Commands, Movement Commands, , Commands
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1498 @comment node-name, next, previous,up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1499 @section Indentation Commands
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1500 @cindex indentation commands
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1501 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
1502
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1503 The following list of commands re-indent C constructs. Note that when
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1504 you change your coding style, either interactively or through some other
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1505 means, your file does @emph{not} automatically get re-indented. You
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1506 will need to execute one of the following commands to see the effects of
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1507 your changes.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1508
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1509 @cindex GNU indent program
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1510 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
1511 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
1512 ``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
1513 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
1514 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
1515 among other things.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1516
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1517 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
1518 @ccmode{} reindents a region of code, it is essentially equivalent to
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1519 hitting @kbd{TAB} on every line of the region. Especially vulnerable is
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1520 code generator output@footnote{In particular, I have had people
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1521 complain about the speed with which @code{lex(1)} output is re-indented.
Dave Love <fx@gnu.org>
parents:
diff changeset
1522 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
1523 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
1524
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1525 These commands are useful when indenting code:
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1526
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1527 @table @asis
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1528
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1529 @kindex TAB
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1530 @findex c-indent-command
Dave Love <fx@gnu.org>
parents:
diff changeset
1531 @findex indent-command (c-)
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1532 @item @kbd{TAB} (@code{c-indent-command})
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1533 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
1534 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
1535 @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
1536 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
1537 the relative indentation among the lines.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1538
40705
421e0a91a1d1 Replace M-C- with C-M-
Eli Zaretskii <eliz@gnu.org>
parents: 39267
diff changeset
1539 @kindex C-M-q
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1540 @findex c-indent-exp
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1541 @findex indent-exp (c-)
40705
421e0a91a1d1 Replace M-C- with C-M-
Eli Zaretskii <eliz@gnu.org>
parents: 39267
diff changeset
1542 @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
1543 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
1544 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
1545 want to indent.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1546
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1547 @kindex C-c C-q
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1548 @findex c-indent-defun
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1549 @findex indent-defun (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1550 @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
1551 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
1552 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
1553 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
1554 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
1555 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
1556
40705
421e0a91a1d1 Replace M-C- with C-M-
Eli Zaretskii <eliz@gnu.org>
parents: 39267
diff changeset
1557 @kindex C-M-\
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1558 @findex indent-region
40705
421e0a91a1d1 Replace M-C- with C-M-
Eli Zaretskii <eliz@gnu.org>
parents: 39267
diff changeset
1559 @item @kbd{C-M-\} (@code{indent-region})
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1560 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
1561 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
1562 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
1563
40705
421e0a91a1d1 Replace M-C- with C-M-
Eli Zaretskii <eliz@gnu.org>
parents: 39267
diff changeset
1564 @kindex C-M-h
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1565 @findex c-mark-function
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1566 @findex mark-function (c-)
40705
421e0a91a1d1 Replace M-C- with C-M-
Eli Zaretskii <eliz@gnu.org>
parents: 39267
diff changeset
1567 @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
1568 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
1569 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
1570 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
1571 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
1572
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1573 @end table
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1574
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1575 These variables are also useful when indenting code:
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1576
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1577 @table @code
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1578
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1579 @vindex c-tab-always-indent
Dave Love <fx@gnu.org>
parents:
diff changeset
1580 @vindex tab-always-indent (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
1581 @kindex TAB
Dave Love <fx@gnu.org>
parents:
diff changeset
1582 @cindex literal
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1583 @item c-tab-always-indent
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1584 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
1585 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
1586 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
1587 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
1588 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
1589 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
1590 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
1591 directives, but the line is always reindented.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1592
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1593 @vindex c-insert-tab-function
Dave Love <fx@gnu.org>
parents:
diff changeset
1594 @vindex insert-tab-function (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
1595 @findex tab-to-tab-stop
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1596 @item c-insert-tab-function
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1597 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
1598 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
1599 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
1600 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
1601 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
1602 @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
1603
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1604 @vindex indent-tabs-mode
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1605 @item indent-tabs-mode
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1606 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
1607 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
1608 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
1609
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1610 @vindex c-progress-interval
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1611 @vindex progress-interval (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1612 @item c-progress-interval
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1613 When indenting large regions of code, this variable controls how often a
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1614 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
1615 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
1616 interval in seconds that progress messages are displayed.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1617
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1618 @end table
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1619
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1620
Dave Love <fx@gnu.org>
parents:
diff changeset
1621 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1622 @node Movement Commands, Other Commands, Indentation Commands, Commands
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1623 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1624 @section Movement Commands
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1625 @cindex movement commands
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1626 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
1627
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1628 @ccmode{} contains some useful command for moving around in C
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1629 code.
Dave Love <fx@gnu.org>
parents:
diff changeset
1630
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1631 @table @asis
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1632
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1633 @findex c-beginning-of-defun
Dave Love <fx@gnu.org>
parents:
diff changeset
1634 @findex beginning-of-defun (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
1635 @findex beginning-of-defun
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1636 @item @kbd{M-x c-beginning-of-defun}
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1637 Moves point back to the least-enclosing brace. This function is
Dave Love <fx@gnu.org>
parents:
diff changeset
1638 analogous to the Emacs built-in command @code{beginning-of-defun},
Dave Love <fx@gnu.org>
parents:
diff changeset
1639 except it eliminates the constraint that the top-level opening brace
Dave Love <fx@gnu.org>
parents:
diff changeset
1640 must be in column zero. See @code{beginning-of-defun} for more
Dave Love <fx@gnu.org>
parents:
diff changeset
1641 information.
Dave Love <fx@gnu.org>
parents:
diff changeset
1642
Dave Love <fx@gnu.org>
parents:
diff changeset
1643 Depending on the coding style being used, you might prefer
Dave Love <fx@gnu.org>
parents:
diff changeset
1644 @code{c-beginning-of-defun} to @code{beginning-of-defun}. If so,
Dave Love <fx@gnu.org>
parents:
diff changeset
1645 consider binding @kbd{C-M-a} to the former instead. For backwards
Dave Love <fx@gnu.org>
parents:
diff changeset
1646 compatibility reasons, the default binding remains in effect.
Dave Love <fx@gnu.org>
parents:
diff changeset
1647
Dave Love <fx@gnu.org>
parents:
diff changeset
1648 @findex c-end-of-defun
Dave Love <fx@gnu.org>
parents:
diff changeset
1649 @findex end-of-defun (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
1650 @findex end-of-defun
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1651 @item @kbd{M-x c-end-of-defun}
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1652 Moves point to the end of the current top-level definition. This
Dave Love <fx@gnu.org>
parents:
diff changeset
1653 function is analogous to the Emacs built-in command @code{end-of-defun},
Dave Love <fx@gnu.org>
parents:
diff changeset
1654 except it eliminates the constraint that the top-level opening brace of
Dave Love <fx@gnu.org>
parents:
diff changeset
1655 the defun must be in column zero. See @code{beginning-of-defun} for more
Dave Love <fx@gnu.org>
parents:
diff changeset
1656 information.
Dave Love <fx@gnu.org>
parents:
diff changeset
1657
Dave Love <fx@gnu.org>
parents:
diff changeset
1658 Depending on the coding style being used, you might prefer
Dave Love <fx@gnu.org>
parents:
diff changeset
1659 @code{c-end-of-defun} to @code{end-of-defun}. If so,
Dave Love <fx@gnu.org>
parents:
diff changeset
1660 consider binding @kbd{C-M-e} to the former instead. For backwards
Dave Love <fx@gnu.org>
parents:
diff changeset
1661 compatibility reasons, the default binding remains in effect.
Dave Love <fx@gnu.org>
parents:
diff changeset
1662
Dave Love <fx@gnu.org>
parents:
diff changeset
1663 @kindex C-c C-u
Dave Love <fx@gnu.org>
parents:
diff changeset
1664 @findex c-up-conditional
Dave Love <fx@gnu.org>
parents:
diff changeset
1665 @findex up-conditional (c-)
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1666 @item @kbd{C-c C-u} (@code{c-up-conditional})
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1667 Move point back to the containing preprocessor conditional, leaving the
Dave Love <fx@gnu.org>
parents:
diff changeset
1668 mark behind. A prefix argument acts as a repeat count. With a negative
Dave Love <fx@gnu.org>
parents:
diff changeset
1669 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
1670 preprocessor conditional.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1671
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1672 @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
1673 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
1674
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1675 @findex c-up-conditional-with-else
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1676 @findex up-conditional-with-else (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1677 @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
1678 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
1679 lines. Normally those lines are ignored.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1680
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1681 @findex c-down-conditional
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1682 @findex down-conditional (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1683 @item @kbd{M-x c-down-conditional}
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1684 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
1685 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
1686 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
1687 nested preprocessor conditional.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1688
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1689 @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
1690 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
1691
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1692 @findex c-down-conditional-with-else
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1693 @findex down-conditional-with-else (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1694 @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
1695 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
1696 lines. Normally those lines are ignored.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1697
Dave Love <fx@gnu.org>
parents:
diff changeset
1698 @kindex C-c C-p
Dave Love <fx@gnu.org>
parents:
diff changeset
1699 @findex c-backward-conditional
Dave Love <fx@gnu.org>
parents:
diff changeset
1700 @findex backward-conditional (c-)
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1701 @item @kbd{C-c C-p} (@code{c-backward-conditional})
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1702 Move point back over a preprocessor conditional, leaving the mark
Dave Love <fx@gnu.org>
parents:
diff changeset
1703 behind. A prefix argument acts as a repeat count. With a negative
Dave Love <fx@gnu.org>
parents:
diff changeset
1704 argument, move forward.
Dave Love <fx@gnu.org>
parents:
diff changeset
1705
Dave Love <fx@gnu.org>
parents:
diff changeset
1706 @kindex C-c C-n
Dave Love <fx@gnu.org>
parents:
diff changeset
1707 @findex c-forward-conditional
Dave Love <fx@gnu.org>
parents:
diff changeset
1708 @findex forward-conditional (c-)
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1709 @item @kbd{C-c C-n} (@code{c-forward-conditional})
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1710 Move point forward across a preprocessor conditional, leaving the mark
Dave Love <fx@gnu.org>
parents:
diff changeset
1711 behind. A prefix argument acts as a repeat count. With a negative
Dave Love <fx@gnu.org>
parents:
diff changeset
1712 argument, move backward.
Dave Love <fx@gnu.org>
parents:
diff changeset
1713
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1714 @kindex M-a
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1715 @findex c-beginning-of-statement
Dave Love <fx@gnu.org>
parents:
diff changeset
1716 @findex beginning-of-statement (c-)
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1717 @item @kbd{M-a} (@code{c-beginning-of-statement})
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1718 Move point to the beginning of the innermost C statement. If point is
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1719 already at the beginning of a statement, move to the beginning of the
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1720 closest preceding statement, even if that means moving into a block (you
40705
421e0a91a1d1 Replace M-C- with C-M-
Eli Zaretskii <eliz@gnu.org>
parents: 39267
diff changeset
1721 can use @kbd{C-M-b} to move over a balanced block). With prefix
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1722 argument @var{n}, move back @var{n} @minus{} 1 statements.
Dave Love <fx@gnu.org>
parents:
diff changeset
1723
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1724 If point is within or next to a comment or a string which spans more
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1725 than one line, this command moves by sentences instead of statements.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1726
Dave Love <fx@gnu.org>
parents:
diff changeset
1727 When called from a program, this function takes three optional
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1728 arguments: the repetition count, a buffer position limit which is the
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1729 farthest back to search for the syntactic context, and a flag saying
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1730 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
1731
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1732 @kindex M-e
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1733 @findex c-end-of-statement
Dave Love <fx@gnu.org>
parents:
diff changeset
1734 @findex end-of-statement (c-)
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1735 @item @kbd{M-e} (@code{c-end-of-statement})
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1736 Move point to the end of the innermost C statement. If point is at the
Dave Love <fx@gnu.org>
parents:
diff changeset
1737 end of a statement, move to the end of the next statement, even if it's
40705
421e0a91a1d1 Replace M-C- with C-M-
Eli Zaretskii <eliz@gnu.org>
parents: 39267
diff changeset
1738 inside a nested block (use @kbd{C-M-f} to move to the other side of the
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1739 block). With prefix argument @var{n}, move forward @var{n} @minus{} 1
Dave Love <fx@gnu.org>
parents:
diff changeset
1740 statements.
Dave Love <fx@gnu.org>
parents:
diff changeset
1741
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1742 If point is within or next to a comment or a string which spans more
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1743 than one line, this command moves by sentences instead of statements.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1744
Dave Love <fx@gnu.org>
parents:
diff changeset
1745 When called from a program, this function takes three optional
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1746 arguments: the repetition count, a buffer position limit which is the
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1747 farthest back to search for the syntactic context, and a flag saying
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1748 whether to do sentence motion in or near comments and multiline strings.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1749
Dave Love <fx@gnu.org>
parents:
diff changeset
1750 @findex c-forward-into-nomenclature
Dave Love <fx@gnu.org>
parents:
diff changeset
1751 @findex forward-into-nomenclature (c-)
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1752 @item @kbd{M-x c-forward-into-nomenclature}
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1753 A popular programming style, especially for object-oriented languages
Dave Love <fx@gnu.org>
parents:
diff changeset
1754 such as C++ is to write symbols in a mixed case format, where the first
Dave Love <fx@gnu.org>
parents:
diff changeset
1755 letter of each word is capitalized, and not separated by underscores.
Dave Love <fx@gnu.org>
parents:
diff changeset
1756 E.g. @samp{SymbolsWithMixedCaseAndNoUnderlines}.
Dave Love <fx@gnu.org>
parents:
diff changeset
1757
Dave Love <fx@gnu.org>
parents:
diff changeset
1758 This command moves point forward to next capitalized word. With prefix
Dave Love <fx@gnu.org>
parents:
diff changeset
1759 argument @var{n}, move @var{n} times.
Dave Love <fx@gnu.org>
parents:
diff changeset
1760
Dave Love <fx@gnu.org>
parents:
diff changeset
1761 @findex c-backward-into-nomenclature
Dave Love <fx@gnu.org>
parents:
diff changeset
1762 @findex backward-into-nomenclature (c-)
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1763 @item @kbd{M-x c-backward-into-nomenclature}
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1764 Move point backward to beginning of the next capitalized
Dave Love <fx@gnu.org>
parents:
diff changeset
1765 word. With prefix argument @var{n}, move @var{n} times. If
Dave Love <fx@gnu.org>
parents:
diff changeset
1766 @var{n} is negative, move forward.
Dave Love <fx@gnu.org>
parents:
diff changeset
1767
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1768 @end table
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1769
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1770
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1771 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1772 @node Other Commands, , Movement Commands, Commands
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1773 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1774 @section Other Commands
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1775 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1776
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1777 @ccmode{} contains a few other useful commands:
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1778
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1779 @table @asis
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1780
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1781 @kindex C-c :
Dave Love <fx@gnu.org>
parents:
diff changeset
1782 @findex c-scope-operator
Dave Love <fx@gnu.org>
parents:
diff changeset
1783 @findex scope-operator (c-)
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1784 @item @kbd{C-c :} (@code{c-scope-operator})
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1785 In C++, it is also sometimes desirable to insert the double-colon scope
Dave Love <fx@gnu.org>
parents:
diff changeset
1786 operator without performing the electric behavior of colon insertion.
Dave Love <fx@gnu.org>
parents:
diff changeset
1787 @kbd{C-c :} does just this.
Dave Love <fx@gnu.org>
parents:
diff changeset
1788
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1789 @kindex C-c C-\
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1790 @findex c-backslash-region
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1791 @findex backslash-region (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1792 @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
1793 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
1794 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
1795 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
1796
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1797 @vindex c-backslash-column
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1798 @vindex backslash-column (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1799 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
1800 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
1801 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
1802
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1803 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
1804 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
1805 (if any) at the end of the previous line.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1806
Dave Love <fx@gnu.org>
parents:
diff changeset
1807 @end table
Dave Love <fx@gnu.org>
parents:
diff changeset
1808
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1809
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1810 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1811 @node Customizing Indentation, Syntactic Symbols, Commands, Top
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1812 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1813 @chapter Customizing Indentation
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1814 @cindex customizing indentation
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1815 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
1816
Dave Love <fx@gnu.org>
parents:
diff changeset
1817 @vindex c-offsets-alist
Dave Love <fx@gnu.org>
parents:
diff changeset
1818 @vindex offsets-alist (c-)
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1819 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
1820 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
1821 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
1822 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
1823 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
1824 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
1825 styles.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1826
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1827 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
1828 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
1829 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
1830 @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
1831 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
1832 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
1833 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
1834 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
1835
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1836 @kindex C-c C-o
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1837 @findex c-set-offset
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1838 @findex set-offset (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1839 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
1840 to set offsets, both interactively and from your mode
39267
a8c0a02f6129 Spelling corrections.
Richard M. Stallman <rms@gnu.org>
parents: 36924
diff changeset
1841 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
1842 function call programmatically!}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1843
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1844 @vindex c-basic-offset
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1845 @vindex basic-offset (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1846 The offset associated with any particular syntactic symbol can be any of
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1847 an integer, a function or lambda expression, a variable name, a vector,
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1848 a list, or one of the following symbols: @code{+}, @code{-}, @code{++},
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1849 @code{--}, @code{*}, or @code{/}.
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1850
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1851 Those last special symbols describe an offset in multiples of the value
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1852 of the style variable @code{c-basic-offset}. By defining a style's
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1853 indentation in terms of this fundamental variable, you can change the
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1854 amount of whitespace given to an indentation level while maintaining the
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1855 same basic shape of your code. Here are the values that the special
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1856 symbols correspond to:
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1857
Dave Love <fx@gnu.org>
parents:
diff changeset
1858 @table @code
Dave Love <fx@gnu.org>
parents:
diff changeset
1859
Dave Love <fx@gnu.org>
parents:
diff changeset
1860 @item +
Dave Love <fx@gnu.org>
parents:
diff changeset
1861 @code{c-basic-offset} times 1
Dave Love <fx@gnu.org>
parents:
diff changeset
1862 @item -
Dave Love <fx@gnu.org>
parents:
diff changeset
1863 @code{c-basic-offset} times -1
Dave Love <fx@gnu.org>
parents:
diff changeset
1864 @item ++
Dave Love <fx@gnu.org>
parents:
diff changeset
1865 @code{c-basic-offset} times 2
Dave Love <fx@gnu.org>
parents:
diff changeset
1866 @item --
Dave Love <fx@gnu.org>
parents:
diff changeset
1867 @code{c-basic-offset} times -2
Dave Love <fx@gnu.org>
parents:
diff changeset
1868 @item *
Dave Love <fx@gnu.org>
parents:
diff changeset
1869 @code{c-basic-offset} times 0.5
Dave Love <fx@gnu.org>
parents:
diff changeset
1870 @item /
Dave Love <fx@gnu.org>
parents:
diff changeset
1871 @code{c-basic-offset} times -0.5
Dave Love <fx@gnu.org>
parents:
diff changeset
1872
Dave Love <fx@gnu.org>
parents:
diff changeset
1873 @end table
Dave Love <fx@gnu.org>
parents:
diff changeset
1874
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1875 @cindex indentation functions
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1876
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1877 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
1878 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
1879 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
1880 @xref{Indentation Functions}, and @ref{Custom Indentation Functions},
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1881 for details about them.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1882
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1883 If the offset is a vector, its first element sets the absolute
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1884 indentation column, which will override any relative indentation.
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
1885
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1886 @vindex c-strict-syntax-p
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1887 @vindex strict-syntax-p (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1888 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
1889 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
1890 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
1891 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
1892 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
1893 @code{c-strict-syntax-p} that, when set to non-@code{nil}, will cause an
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1894 error to be signalled in that case. It's now considered obsolete since
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1895 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
1896 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
1897 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
1898
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1899 So, for example, because most of the default offsets are defined in
Dave Love <fx@gnu.org>
parents:
diff changeset
1900 terms of @code{+}, @code{-}, and @code{0}, if you like the general
Dave Love <fx@gnu.org>
parents:
diff changeset
1901 indentation style, but you use 4 spaces instead of 2 spaces per level,
Dave Love <fx@gnu.org>
parents:
diff changeset
1902 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
1903 @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
1904 a C buffer by typing the text that appears in italics.}:
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1905 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
1906
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1907 @emph{M-x set-variable RET}
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1908 Set variable: @emph{c-basic-offset RET}
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1909 Set c-basic-offset to value: @emph{4 RET}
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1910
Dave Love <fx@gnu.org>
parents:
diff changeset
1911 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
1912
Dave Love <fx@gnu.org>
parents:
diff changeset
1913 @noindent
Dave Love <fx@gnu.org>
parents:
diff changeset
1914 This would change
Dave Love <fx@gnu.org>
parents:
diff changeset
1915 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
1916 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
1917
Dave Love <fx@gnu.org>
parents:
diff changeset
1918 int add( int val, int incr, int doit )
Dave Love <fx@gnu.org>
parents:
diff changeset
1919 @{
Dave Love <fx@gnu.org>
parents:
diff changeset
1920 if( doit )
Dave Love <fx@gnu.org>
parents:
diff changeset
1921 @{
Dave Love <fx@gnu.org>
parents:
diff changeset
1922 return( val + incr );
Dave Love <fx@gnu.org>
parents:
diff changeset
1923 @}
Dave Love <fx@gnu.org>
parents:
diff changeset
1924 return( val );
Dave Love <fx@gnu.org>
parents:
diff changeset
1925 @}
Dave Love <fx@gnu.org>
parents:
diff changeset
1926
Dave Love <fx@gnu.org>
parents:
diff changeset
1927 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
1928 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
1929 @noindent
Dave Love <fx@gnu.org>
parents:
diff changeset
1930 to
Dave Love <fx@gnu.org>
parents:
diff changeset
1931 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
1932 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
1933
Dave Love <fx@gnu.org>
parents:
diff changeset
1934 int add( int val, int incr, int doit )
Dave Love <fx@gnu.org>
parents:
diff changeset
1935 @{
Dave Love <fx@gnu.org>
parents:
diff changeset
1936 if( doit )
Dave Love <fx@gnu.org>
parents:
diff changeset
1937 @{
Dave Love <fx@gnu.org>
parents:
diff changeset
1938 return( val + incr );
Dave Love <fx@gnu.org>
parents:
diff changeset
1939 @}
Dave Love <fx@gnu.org>
parents:
diff changeset
1940 return( val );
Dave Love <fx@gnu.org>
parents:
diff changeset
1941 @}
Dave Love <fx@gnu.org>
parents:
diff changeset
1942
Dave Love <fx@gnu.org>
parents:
diff changeset
1943 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
1944 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
1945
Dave Love <fx@gnu.org>
parents:
diff changeset
1946 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
1947 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
1948 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
1949 your @file{.emacs} file so that your changes are more permanent.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1950
Dave Love <fx@gnu.org>
parents:
diff changeset
1951 @menu
Dave Love <fx@gnu.org>
parents:
diff changeset
1952 * Interactive Customization::
Dave Love <fx@gnu.org>
parents:
diff changeset
1953 * Permanent Customization::
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1954 * Hooks::
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1955 * Styles::
Dave Love <fx@gnu.org>
parents:
diff changeset
1956 * Advanced Customizations::
Dave Love <fx@gnu.org>
parents:
diff changeset
1957 @end menu
Dave Love <fx@gnu.org>
parents:
diff changeset
1958
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1959
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1960 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1961 @node Interactive Customization, Permanent Customization, , Customizing Indentation
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1962 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1963 @section Interactive Customization
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1964 @cindex interactive customization
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1965 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
1966
Dave Love <fx@gnu.org>
parents:
diff changeset
1967 As an example of how to customize indentation, let's change the
Dave Love <fx@gnu.org>
parents:
diff changeset
1968 style of this example@footnote{In this an subsequent examples, the
Dave Love <fx@gnu.org>
parents:
diff changeset
1969 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
1970 indicated. @xref{Styles}.}:
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1971 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
1972 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
1973
Dave Love <fx@gnu.org>
parents:
diff changeset
1974 1: int add( int val, int incr, int doit )
Dave Love <fx@gnu.org>
parents:
diff changeset
1975 2: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
1976 3: if( doit )
Dave Love <fx@gnu.org>
parents:
diff changeset
1977 4: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
1978 5: return( val + incr );
Dave Love <fx@gnu.org>
parents:
diff changeset
1979 6: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
1980 7: return( val );
Dave Love <fx@gnu.org>
parents:
diff changeset
1981 8: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
1982
Dave Love <fx@gnu.org>
parents:
diff changeset
1983 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
1984 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
1985 @noindent
Dave Love <fx@gnu.org>
parents:
diff changeset
1986 to:
Dave Love <fx@gnu.org>
parents:
diff changeset
1987 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
1988 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
1989
Dave Love <fx@gnu.org>
parents:
diff changeset
1990 1: int add( int val, int incr, int doit )
Dave Love <fx@gnu.org>
parents:
diff changeset
1991 2: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
1992 3: if( doit )
Dave Love <fx@gnu.org>
parents:
diff changeset
1993 4: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
1994 5: return( val + incr );
Dave Love <fx@gnu.org>
parents:
diff changeset
1995 6: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
1996 7: return( val );
Dave Love <fx@gnu.org>
parents:
diff changeset
1997 8: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
1998
Dave Love <fx@gnu.org>
parents:
diff changeset
1999 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
2000 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
2001
Dave Love <fx@gnu.org>
parents:
diff changeset
2002 In other words, we want to change the indentation of braces that open a
Dave Love <fx@gnu.org>
parents:
diff changeset
2003 block following a condition so that the braces line up under the
Dave Love <fx@gnu.org>
parents:
diff changeset
2004 conditional, instead of being indented. Notice that the construct we
Dave Love <fx@gnu.org>
parents:
diff changeset
2005 want to change starts on line 4. To change the indentation of a line,
Dave Love <fx@gnu.org>
parents:
diff changeset
2006 we need to see which syntactic components affect the offset calculations
Dave Love <fx@gnu.org>
parents:
diff changeset
2007 for that line. Hitting @kbd{C-c C-s} on line 4 yields:
Dave Love <fx@gnu.org>
parents:
diff changeset
2008 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
2009
Dave Love <fx@gnu.org>
parents:
diff changeset
2010 ((substatement-open . 44))
Dave Love <fx@gnu.org>
parents:
diff changeset
2011
Dave Love <fx@gnu.org>
parents:
diff changeset
2012 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
2013
Dave Love <fx@gnu.org>
parents:
diff changeset
2014 @noindent
Dave Love <fx@gnu.org>
parents:
diff changeset
2015 so we know that to change the offset of the open brace, we need to
Dave Love <fx@gnu.org>
parents:
diff changeset
2016 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
2017 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
2018 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
2019 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
2020 syntactic symbol we want to change!
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2021
Dave Love <fx@gnu.org>
parents:
diff changeset
2022 After you hit return, @ccmode{} will then prompt you for the new
Dave Love <fx@gnu.org>
parents:
diff changeset
2023 offset value, with the old value as the default. The default in this
Dave Love <fx@gnu.org>
parents:
diff changeset
2024 case is @samp{+}, but we want no extra indentation so enter
Dave Love <fx@gnu.org>
parents:
diff changeset
2025 @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
2026 syntactic symbol @code{substatement-open}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2027
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2028 To check your changes quickly, just hit @kbd{C-c C-q}
Dave Love <fx@gnu.org>
parents:
diff changeset
2029 (@code{c-indent-defun}) to reindent the entire function. The example
Dave Love <fx@gnu.org>
parents:
diff changeset
2030 should now look like:
Dave Love <fx@gnu.org>
parents:
diff changeset
2031 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
2032 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
2033
Dave Love <fx@gnu.org>
parents:
diff changeset
2034 1: int add( int val, int incr, int doit )
Dave Love <fx@gnu.org>
parents:
diff changeset
2035 2: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
2036 3: if( doit )
Dave Love <fx@gnu.org>
parents:
diff changeset
2037 4: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
2038 5: return( val + incr );
Dave Love <fx@gnu.org>
parents:
diff changeset
2039 6: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
2040 7: return( val );
Dave Love <fx@gnu.org>
parents:
diff changeset
2041 8: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
2042
Dave Love <fx@gnu.org>
parents:
diff changeset
2043 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
2044 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
2045
Dave Love <fx@gnu.org>
parents:
diff changeset
2046 Notice how just changing the open brace offset on line 4 is all we
Dave Love <fx@gnu.org>
parents:
diff changeset
2047 needed to do. Since the other affected lines are indented relative to
Dave Love <fx@gnu.org>
parents:
diff changeset
2048 line 4, they are automatically indented the way you'd expect. For more
Dave Love <fx@gnu.org>
parents:
diff changeset
2049 complicated examples, this may not always work. The general approach to
Dave Love <fx@gnu.org>
parents:
diff changeset
2050 take is to always start adjusting offsets for lines higher up in the
Dave Love <fx@gnu.org>
parents:
diff changeset
2051 file, then re-indent and see if any following lines need further
Dave Love <fx@gnu.org>
parents:
diff changeset
2052 adjustments.
Dave Love <fx@gnu.org>
parents:
diff changeset
2053
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2054
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2055 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2056 @node Permanent Customization, Hooks, Interactive Customization, Customizing Indentation
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2057 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2058 @section Permanent Customization
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2059 @cindex permanent customization
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2060 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2061
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2062 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
2063 @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
2064 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
2065 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
2066 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
2067
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2068 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
2069 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
2070 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
2071 to the @file{.emacs} file:
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2072 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2073 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2074
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2075 (require 'cc-mode)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2076 (c-set-offset 'substatement-open 0)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2077
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2078 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2079 @end example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2080
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2081 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
2082 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
2083 defined.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2084
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2085 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
2086 this manual does not cover how that works.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2087
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2088 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
2089 all @ccmode{} buffers, regardless of language. The indentation style
30396
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
2090 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
2091 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
2092 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
2093 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
2094 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
2095 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
2096 different languages.
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2097
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2098 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
2099 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
2100 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
2101 @ref{Styles}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2102
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2103 @vindex c-style-variables-are-local-p
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2104 @vindex style-variables-are-local-p (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2105 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
2106 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
2107 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
2108 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
2109 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
2110 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
2111 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
2112 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
2113 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
2114 without restarting Emacs.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2115
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2116
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2117 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2118 @node Hooks, Styles, Permanent Customization, Customizing Indentation
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2119 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2120 @section Hooks
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2121 @cindex hooks
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2122 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
2123
Dave Love <fx@gnu.org>
parents:
diff changeset
2124 @vindex c-mode-common-hook
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2125 @vindex mode-common-hook (c-)
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2126 @vindex c-mode-hook
Dave Love <fx@gnu.org>
parents:
diff changeset
2127 @vindex c++-mode-hook
Dave Love <fx@gnu.org>
parents:
diff changeset
2128 @vindex objc-mode-hook
Dave Love <fx@gnu.org>
parents:
diff changeset
2129 @vindex java-mode-hook
Dave Love <fx@gnu.org>
parents:
diff changeset
2130 @vindex idl-mode-hook
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2131 @vindex pike-mode-hook
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2132 @vindex c-initialization-hook
Dave Love <fx@gnu.org>
parents:
diff changeset
2133 @vindex initialization-hook (c-)
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2134 @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
2135 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
2136 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
2137 general hook and one package initialization hook:
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2138
Dave Love <fx@gnu.org>
parents:
diff changeset
2139 @itemize @bullet
Dave Love <fx@gnu.org>
parents:
diff changeset
2140
Dave Love <fx@gnu.org>
parents:
diff changeset
2141 @item
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2142 @code{c-mode-hook} --- For C buffers only.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2143 @item
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2144 @code{c++-mode-hook} --- For C++ buffers only.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2145 @item
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2146 @code{objc-mode-hook} --- For Objective-C buffers only.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2147 @item
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2148 @code{java-mode-hook} --- For Java buffers only.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2149 @item
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2150 @code{idl-mode-hook} --- For CORBA IDL buffers only.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2151 @item
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2152 @code{pike-mode-hook} --- For Pike buffers only.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2153 @item
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2154 @code{c-mode-common-hook} --- Common across all languages.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2155 @item
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2156 @code{c-initialization-hook} --- Hook run only once per Emacs session,
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2157 when @ccmode{} is initialized.
Dave Love <fx@gnu.org>
parents:
diff changeset
2158
Dave Love <fx@gnu.org>
parents:
diff changeset
2159 @end itemize
Dave Love <fx@gnu.org>
parents:
diff changeset
2160
Dave Love <fx@gnu.org>
parents:
diff changeset
2161 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
2162 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
2163 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
2164 customizations that are common across all languages. Most of the
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
2165 examples in this section will assume you are using the common hook.
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
2166
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
2167 Note that all the language-specific mode setup that CC Mode does is done
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
2168 prior to both @code{c-mode-common-hook} and the language specific hook.
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
2169 That includes installing the indentation style, which can be mode
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
2170 specific (and also is by default for Java mode). Thus, any style
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
2171 settings done in @code{c-mode-common-hook} will override whatever
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
2172 language-specific style is chosen by @code{c-default-style}.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2173
Dave Love <fx@gnu.org>
parents:
diff changeset
2174 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
2175 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
2176 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
2177 @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
2178 file.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2179 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
2180 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
2181
Dave Love <fx@gnu.org>
parents:
diff changeset
2182 (defun my-c-mode-common-hook ()
Dave Love <fx@gnu.org>
parents:
diff changeset
2183 ;; 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
2184 (no-case-fold-search)
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2185 )
Dave Love <fx@gnu.org>
parents:
diff changeset
2186 (add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
Dave Love <fx@gnu.org>
parents:
diff changeset
2187
Dave Love <fx@gnu.org>
parents:
diff changeset
2188 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
2189 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
2190
Dave Love <fx@gnu.org>
parents:
diff changeset
2191
Dave Love <fx@gnu.org>
parents:
diff changeset
2192 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2193 @node Styles, Advanced Customizations, Hooks, Customizing Indentation
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2194 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2195 @section Styles
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2196 @cindex styles
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2197 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
2198
Dave Love <fx@gnu.org>
parents:
diff changeset
2199 Most people only need to edit code formatted in just a few well-defined
Dave Love <fx@gnu.org>
parents:
diff changeset
2200 and consistent styles. For example, their organization might impose a
Dave Love <fx@gnu.org>
parents:
diff changeset
2201 ``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
2202 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
2203 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
2204 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
2205 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
2206 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
2207 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
2208 existing code using these styles.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2209
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2210 @cindex style variables
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2211 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
2212 variables}. They are handled specially in several ways:
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 @itemize @bullet
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2215 @item
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2216 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
2217 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
2218 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
2219 non-@code{nil} before @ccmode{} is initialized.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2220
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2221 @vindex c-old-style-variable-behavior
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2222 @vindex old-style-variable-behavior (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2223 @item
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2224 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
2225 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
2226 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
2227 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
2228 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
2229 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
2230 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
2231 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
2232 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
2233 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
2234
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2235 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
2236 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
2237 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
2238 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
2239 value.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2240
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2241 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
2242 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
2243 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
2244 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
2245 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
2246
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2247 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
2248 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
2249 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
2250 in version 5.26.}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2251
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2252 @item
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2253 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
2254 @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
2255 @xref{Built-in Styles}, for details.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2256
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2257 @end itemize
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2258
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2259 The style variables are:
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2260 @code{c-basic-offset},
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2261 @code{c-comment-only-line-offset},
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2262 @code{c-block-comment-prefix},
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2263 @code{c-comment-prefix-regexp},
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2264 @code{c-cleanup-list},
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2265 @code{c-hanging-braces-alist},
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2266 @code{c-hanging-colons-alist},
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2267 @code{c-hanging-semi&comma-criteria},
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2268 @code{c-backslash-column},
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2269 @code{c-special-indent-hook},
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2270 @code{c-label-minimum-indentation}, and
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2271 @code{c-offsets-alist}.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2272
Dave Love <fx@gnu.org>
parents:
diff changeset
2273 @menu
Dave Love <fx@gnu.org>
parents:
diff changeset
2274 * Built-in Styles::
Dave Love <fx@gnu.org>
parents:
diff changeset
2275 * Adding Styles::
Dave Love <fx@gnu.org>
parents:
diff changeset
2276 * File Styles::
Dave Love <fx@gnu.org>
parents:
diff changeset
2277 @end menu
Dave Love <fx@gnu.org>
parents:
diff changeset
2278
Dave Love <fx@gnu.org>
parents:
diff changeset
2279
Dave Love <fx@gnu.org>
parents:
diff changeset
2280 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2281 @node Built-in Styles, Adding Styles, , Styles
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2282 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2283 @subsection Built-in Styles
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2284 @cindex built-in styles
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2285 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
2286
Dave Love <fx@gnu.org>
parents:
diff changeset
2287 If you're lucky, one of @ccmode{}'s built-in styles might be just
Dave Love <fx@gnu.org>
parents:
diff changeset
2288 what you're looking for. These include:
Dave Love <fx@gnu.org>
parents:
diff changeset
2289
Dave Love <fx@gnu.org>
parents:
diff changeset
2290 @itemize @bullet
Dave Love <fx@gnu.org>
parents:
diff changeset
2291 @cindex GNU style
Dave Love <fx@gnu.org>
parents:
diff changeset
2292 @item
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2293 @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
2294 for C code in GNU programs.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2295
Dave Love <fx@gnu.org>
parents:
diff changeset
2296 @cindex K&R style
Dave Love <fx@gnu.org>
parents:
diff changeset
2297 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
2298 @code{k&r} --- The classic Kernighan and Ritchie style for C code.
Dave Love <fx@gnu.org>
parents:
diff changeset
2299
Dave Love <fx@gnu.org>
parents:
diff changeset
2300 @cindex BSD style
Dave Love <fx@gnu.org>
parents:
diff changeset
2301 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
2302 @code{bsd} --- Also known as ``Allman style'' after Eric Allman.
Dave Love <fx@gnu.org>
parents:
diff changeset
2303
Dave Love <fx@gnu.org>
parents:
diff changeset
2304 @cindex Whitesmith style
Dave Love <fx@gnu.org>
parents:
diff changeset
2305 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
2306 @code{whitesmith} --- Popularized by the examples that came with
Dave Love <fx@gnu.org>
parents:
diff changeset
2307 Whitesmiths C, an early commercial C compiler.
Dave Love <fx@gnu.org>
parents:
diff changeset
2308
Dave Love <fx@gnu.org>
parents:
diff changeset
2309 @cindex Stroustrup style
Dave Love <fx@gnu.org>
parents:
diff changeset
2310 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
2311 @code{stroustrup} --- The classic Stroustrup style for C++ code.
Dave Love <fx@gnu.org>
parents:
diff changeset
2312
Dave Love <fx@gnu.org>
parents:
diff changeset
2313 @cindex Ellemtel style
Dave Love <fx@gnu.org>
parents:
diff changeset
2314 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
2315 @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
2316 ``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
2317 Henricson, Ellemtel@footnote{This document is available at
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2318 @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
2319 places.}.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2320
Dave Love <fx@gnu.org>
parents:
diff changeset
2321 @cindex Linux style
Dave Love <fx@gnu.org>
parents:
diff changeset
2322 @item
36924
28d23bbdd2cf Version merged with the one from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36923
diff changeset
2323 @code{linux} --- C coding standard for Linux (the kernel).
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2324
Dave Love <fx@gnu.org>
parents:
diff changeset
2325 @cindex Python style
Dave Love <fx@gnu.org>
parents:
diff changeset
2326 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
2327 @code{python} --- C coding standard for Python extension
Dave Love <fx@gnu.org>
parents:
diff changeset
2328 modules@footnote{Python is a high level scripting language with a C/C++
Dave Love <fx@gnu.org>
parents:
diff changeset
2329 foreign function interface. For more information, see
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2330 @uref{http://www.python.org/}.}.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2331
Dave Love <fx@gnu.org>
parents:
diff changeset
2332 @cindex Java style
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2333 @findex java-mode
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2334 @item
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
2335 @code{java} --- The style for editing Java code. Note that the default
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
2336 value for @code{c-default-style} installs this style when you enter
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
2337 @code{java-mode}.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2338
Dave Love <fx@gnu.org>
parents:
diff changeset
2339 @cindex User style
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2340 @item
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2341 @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
2342 @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
2343 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
2344 @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
2345 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
2346 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
2347 (@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
2348 your new style and @code{user} style.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2349
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2350 @end itemize
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2351
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2352 @vindex c-default-style
Dave Love <fx@gnu.org>
parents:
diff changeset
2353 @vindex default-style (c-)
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2354 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
2355 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
2356 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
2357 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
2358 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
2359 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
2360 effect of these settings.
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 @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
2363 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
2364 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
2365 mode. Here are the rules:
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 @vindex c-style-alist
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2368 @vindex style-alist (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2369 @vindex c-mode-common-hook
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2370 @vindex mode-common-hook (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2371 @enumerate
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2372 @item
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2373 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
2374 name as found in @code{c-style-alist}. This style is then used for all
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
2375 modes.
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2376
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2377 @item
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2378 When @code{c-default-style} is an association list, the current major
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2379 mode is looked up to find a style name string. In this case, this style
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2380 is always used exactly as specified and an error will occur if the named
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2381 style does not exist.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2382
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2383 @item
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2384 If @code{c-default-style} is an association list, but the current major
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2385 mode isn't found, then the special symbol @samp{other} is looked up. If
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2386 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
2387
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2388 @item
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2389 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
2390
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2391 @item
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2392 In all cases, the style described in @code{c-default-style} is installed
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2393 @emph{before} the language hooks are run, so you can always override
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2394 this setting by including an explicit call to @code{c-set-style} in your
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2395 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
2396
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2397 @end enumerate
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2398
Dave Love <fx@gnu.org>
parents:
diff changeset
2399 @findex c-set-style
Dave Love <fx@gnu.org>
parents:
diff changeset
2400 @findex set-style (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
2401 @kindex C-c .
Dave Love <fx@gnu.org>
parents:
diff changeset
2402 If you'd like to experiment with these built-in styles you can simply
Dave Love <fx@gnu.org>
parents:
diff changeset
2403 type the following in a @ccmode{} buffer:
Dave Love <fx@gnu.org>
parents:
diff changeset
2404 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
2405 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
2406
Dave Love <fx@gnu.org>
parents:
diff changeset
2407 @kbd{C-c . @var{STYLE-NAME} RET}
Dave Love <fx@gnu.org>
parents:
diff changeset
2408
Dave Love <fx@gnu.org>
parents:
diff changeset
2409 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
2410 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
2411 @noindent
Dave Love <fx@gnu.org>
parents:
diff changeset
2412 @kbd{C-c .} runs the command @code{c-set-style}. Note that all style
Dave Love <fx@gnu.org>
parents:
diff changeset
2413 names are case insensitive, even the ones you define.
Dave Love <fx@gnu.org>
parents:
diff changeset
2414
Dave Love <fx@gnu.org>
parents:
diff changeset
2415 Setting a style in this way does @emph{not} automatically re-indent your
Dave Love <fx@gnu.org>
parents:
diff changeset
2416 file. For commands that you can use to view the effect of your changes,
Dave Love <fx@gnu.org>
parents:
diff changeset
2417 see @ref{Commands}.
Dave Love <fx@gnu.org>
parents:
diff changeset
2418
Dave Love <fx@gnu.org>
parents:
diff changeset
2419 @vindex c-indentation-style
Dave Love <fx@gnu.org>
parents:
diff changeset
2420 @vindex indentation-style (c-)
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2421 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
2422 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
2423 @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
2424 @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
2425 @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
2426 @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
2427 name, as a string.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2428
Dave Love <fx@gnu.org>
parents:
diff changeset
2429
Dave Love <fx@gnu.org>
parents:
diff changeset
2430 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2431 @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
2432 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2433 @subsection Adding Styles
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2434 @cindex adding styles
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2435 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
2436
Dave Love <fx@gnu.org>
parents:
diff changeset
2437 @vindex c-style-alist
Dave Love <fx@gnu.org>
parents:
diff changeset
2438 @vindex style-alist (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
2439 @findex c-add-style
Dave Love <fx@gnu.org>
parents:
diff changeset
2440 @findex add-style (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
2441 If none of the built-in styles is appropriate, you'll probably want to
Dave Love <fx@gnu.org>
parents:
diff changeset
2442 add a new @dfn{style definition}. Styles are kept in the
Dave Love <fx@gnu.org>
parents:
diff changeset
2443 @code{c-style-alist} variable, but you should never modify this variable
Dave Love <fx@gnu.org>
parents:
diff changeset
2444 directly. Instead, @ccmode{} provides the function
Dave Love <fx@gnu.org>
parents:
diff changeset
2445 @code{c-add-style} that you can use to easily add new styles or change
Dave Love <fx@gnu.org>
parents:
diff changeset
2446 existing styles. This function takes two arguments, a @var{stylename}
Dave Love <fx@gnu.org>
parents:
diff changeset
2447 string, and an association list @var{description} of style
Dave Love <fx@gnu.org>
parents:
diff changeset
2448 customizations. If @var{stylename} is not already in
Dave Love <fx@gnu.org>
parents:
diff changeset
2449 @code{c-style-alist}, the new style is added, otherwise the style is
Dave Love <fx@gnu.org>
parents:
diff changeset
2450 changed to the new @var{description}.
Dave Love <fx@gnu.org>
parents:
diff changeset
2451 This function also takes an optional third argument, which if
Dave Love <fx@gnu.org>
parents:
diff changeset
2452 non-@code{nil}, automatically applies the new style to the current
Dave Love <fx@gnu.org>
parents:
diff changeset
2453 buffer.
Dave Love <fx@gnu.org>
parents:
diff changeset
2454
Dave Love <fx@gnu.org>
parents:
diff changeset
2455 @comment TBD: The next paragraph is bogus. I really need to better
Dave Love <fx@gnu.org>
parents:
diff changeset
2456 @comment document adding styles, including setting up inherited styles.
Dave Love <fx@gnu.org>
parents:
diff changeset
2457
Dave Love <fx@gnu.org>
parents:
diff changeset
2458 The sample @file{.emacs} file provides a concrete example of how a new
Dave Love <fx@gnu.org>
parents:
diff changeset
2459 style can be added and automatically set. @xref{Sample .emacs File}.
Dave Love <fx@gnu.org>
parents:
diff changeset
2460
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2461
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2462 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2463 @node File Styles, , Adding Styles, Styles
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2464 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2465 @subsection File Styles
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2466 @cindex file styles
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2467 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
2468
Dave Love <fx@gnu.org>
parents:
diff changeset
2469 @cindex local variables
Dave Love <fx@gnu.org>
parents:
diff changeset
2470
Dave Love <fx@gnu.org>
parents:
diff changeset
2471 The Emacs manual describes how you can customize certain variables on a
Dave Love <fx@gnu.org>
parents:
diff changeset
2472 per-file basis by including a @dfn{Local Variable} block at the end of
Dave Love <fx@gnu.org>
parents:
diff changeset
2473 the file. So far, you've only seen a functional interface to @ccmode{}
Dave Love <fx@gnu.org>
parents:
diff changeset
2474 customization, which is highly inconvenient for use in a Local Variable
Dave Love <fx@gnu.org>
parents:
diff changeset
2475 block. @ccmode{} provides two variables that make it easier for you to
Dave Love <fx@gnu.org>
parents:
diff changeset
2476 customize your style on a per-file basis.
Dave Love <fx@gnu.org>
parents:
diff changeset
2477
Dave Love <fx@gnu.org>
parents:
diff changeset
2478 @vindex c-file-style
Dave Love <fx@gnu.org>
parents:
diff changeset
2479 @vindex file-style (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
2480 @vindex c-file-offsets
Dave Love <fx@gnu.org>
parents:
diff changeset
2481 @vindex file-offsets (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
2482
Dave Love <fx@gnu.org>
parents:
diff changeset
2483 The variable @code{c-file-style} can be set to a style name string.
Dave Love <fx@gnu.org>
parents:
diff changeset
2484 When the file is visited, @ccmode{} will automatically set the
Dave Love <fx@gnu.org>
parents:
diff changeset
2485 file's style to this style using @code{c-set-style}.
Dave Love <fx@gnu.org>
parents:
diff changeset
2486
Dave Love <fx@gnu.org>
parents:
diff changeset
2487 Another variable, @code{c-file-offsets}, takes an association list
Dave Love <fx@gnu.org>
parents:
diff changeset
2488 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
2489 visited, @ccmode{} will automatically institute these offsets using
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2490 @code{c-set-offset}.
Dave Love <fx@gnu.org>
parents:
diff changeset
2491
Dave Love <fx@gnu.org>
parents:
diff changeset
2492 Note that file style settings (i.e. @code{c-file-style}) are applied
Dave Love <fx@gnu.org>
parents:
diff changeset
2493 before file offset settings (i.e. @code{c-file-offsets}). Also, if
Dave Love <fx@gnu.org>
parents:
diff changeset
2494 either of these are set in a file's local variable section, all the
Dave Love <fx@gnu.org>
parents:
diff changeset
2495 style variable values are made local to that buffer.
Dave Love <fx@gnu.org>
parents:
diff changeset
2496
Dave Love <fx@gnu.org>
parents:
diff changeset
2497
Dave Love <fx@gnu.org>
parents:
diff changeset
2498 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2499 @node Advanced Customizations, , Styles, Customizing Indentation
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2500 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2501 @section Advanced Customizations
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2502 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
2503
Dave Love <fx@gnu.org>
parents:
diff changeset
2504 @vindex c-style-alist
Dave Love <fx@gnu.org>
parents:
diff changeset
2505 @vindex style-alist (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
2506 For most users, @ccmode{} will support their coding styles with
Dave Love <fx@gnu.org>
parents:
diff changeset
2507 very little need for more advanced customizations. Usually, one of the
Dave Love <fx@gnu.org>
parents:
diff changeset
2508 standard styles defined in @code{c-style-alist} will do the trick. At
Dave Love <fx@gnu.org>
parents:
diff changeset
2509 most, perhaps one of the syntactic symbol offsets will need to be
Dave Love <fx@gnu.org>
parents:
diff changeset
2510 tweaked slightly, or maybe @code{c-basic-offset} will need to be
Dave Love <fx@gnu.org>
parents:
diff changeset
2511 changed. However, some styles require a more flexible framework for
Dave Love <fx@gnu.org>
parents:
diff changeset
2512 customization, and one of the real strengths of @ccmode{} is that
Dave Love <fx@gnu.org>
parents:
diff changeset
2513 the syntactic analysis model provides just such a framework. This allows
Dave Love <fx@gnu.org>
parents:
diff changeset
2514 you to implement custom indentation calculations for situations not
Dave Love <fx@gnu.org>
parents:
diff changeset
2515 handled by the mode directly.
Dave Love <fx@gnu.org>
parents:
diff changeset
2516
Dave Love <fx@gnu.org>
parents:
diff changeset
2517 @menu
Dave Love <fx@gnu.org>
parents:
diff changeset
2518 * Custom Indentation Functions::
Dave Love <fx@gnu.org>
parents:
diff changeset
2519 * Custom Brace and Colon Hanging::
Dave Love <fx@gnu.org>
parents:
diff changeset
2520 * Customizing Semi-colons and Commas::
Dave Love <fx@gnu.org>
parents:
diff changeset
2521 * Other Special Indentations::
Dave Love <fx@gnu.org>
parents:
diff changeset
2522 @end menu
Dave Love <fx@gnu.org>
parents:
diff changeset
2523
Dave Love <fx@gnu.org>
parents:
diff changeset
2524 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2525 @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
2526 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2527 @subsection Custom Indentation Functions
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2528 @cindex custom indentation functions
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2529 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
2530
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2531 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
2532 indentation functions, and associating them with specific syntactic
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2533 symbols (@pxref{Syntactic Symbols}). @ccmode{} itself uses indentation
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2534 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
2535 lining up C++ stream operator blocks:
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2536 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
2537 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
2538
Dave Love <fx@gnu.org>
parents:
diff changeset
2539 1: void main(int argc, char**)
Dave Love <fx@gnu.org>
parents:
diff changeset
2540 2: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
2541 3: cout << "There were "
Dave Love <fx@gnu.org>
parents:
diff changeset
2542 4: << argc
Dave Love <fx@gnu.org>
parents:
diff changeset
2543 5: << "arguments passed to the program"
Dave Love <fx@gnu.org>
parents:
diff changeset
2544 6: << endl;
Dave Love <fx@gnu.org>
parents:
diff changeset
2545 7: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
2546
Dave Love <fx@gnu.org>
parents:
diff changeset
2547 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
2548 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
2549
Dave Love <fx@gnu.org>
parents:
diff changeset
2550 In this example, lines 4 through 6 are assigned the @code{stream-op}
Dave Love <fx@gnu.org>
parents:
diff changeset
2551 syntactic symbol. Here, @code{stream-op} has an offset of @code{+}, and
Dave Love <fx@gnu.org>
parents:
diff changeset
2552 with a @code{c-basic-offset} of 2, you can see that lines 4 through 6
Dave Love <fx@gnu.org>
parents:
diff changeset
2553 are simply indented two spaces to the right of line 3. But perhaps we'd
Dave Love <fx@gnu.org>
parents:
diff changeset
2554 like @ccmode{} to be a little more intelligent so that it aligns
Dave Love <fx@gnu.org>
parents:
diff changeset
2555 all the @samp{<<} symbols in lines 3 through 6. To do this, we have
Dave Love <fx@gnu.org>
parents:
diff changeset
2556 to write a custom indentation function which finds the column of first
Dave Love <fx@gnu.org>
parents:
diff changeset
2557 stream operator on the first line of the statement. Here is sample
Dave Love <fx@gnu.org>
parents:
diff changeset
2558 lisp code implementing this:
Dave Love <fx@gnu.org>
parents:
diff changeset
2559 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
2560 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
2561
Dave Love <fx@gnu.org>
parents:
diff changeset
2562 (defun c-lineup-streamop (langelem)
Dave Love <fx@gnu.org>
parents:
diff changeset
2563 ;; lineup stream operators
Dave Love <fx@gnu.org>
parents:
diff changeset
2564 (save-excursion
Dave Love <fx@gnu.org>
parents:
diff changeset
2565 (let* ((relpos (cdr langelem))
Dave Love <fx@gnu.org>
parents:
diff changeset
2566 (curcol (progn (goto-char relpos)
Dave Love <fx@gnu.org>
parents:
diff changeset
2567 (current-column))))
Dave Love <fx@gnu.org>
parents:
diff changeset
2568 (re-search-forward "<<\\|>>" (c-point 'eol) 'move)
Dave Love <fx@gnu.org>
parents:
diff changeset
2569 (goto-char (match-beginning 0))
Dave Love <fx@gnu.org>
parents:
diff changeset
2570 (- (current-column) curcol))))
Dave Love <fx@gnu.org>
parents:
diff changeset
2571
Dave Love <fx@gnu.org>
parents:
diff changeset
2572 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
2573 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
2574 @noindent
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2575 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
2576 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
2577 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
2578 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
2579 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
2580 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
2581 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
2582 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
2583 added in twice.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2584
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2585 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
2586 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
2587 expression (@pxref{Customizing Indentation}), that will cause @ccmode{}
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2588 to go on and check the next entry in the list.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2589
Dave Love <fx@gnu.org>
parents:
diff changeset
2590 @cindex stream-op syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
2591 @findex c-lineup-streamop
Dave Love <fx@gnu.org>
parents:
diff changeset
2592 @findex lineup-streamop (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
2593 Now, to associate the function @code{c-lineup-streamop} with the
Dave Love <fx@gnu.org>
parents:
diff changeset
2594 @code{stream-op} syntactic symbol, we can add something like the
Dave Love <fx@gnu.org>
parents:
diff changeset
2595 following to our @code{c++-mode-hook}@footnote{It probably makes more
Dave Love <fx@gnu.org>
parents:
diff changeset
2596 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
2597 since stream operators are only relevant for C++.}:
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2598 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
2599
Dave Love <fx@gnu.org>
parents:
diff changeset
2600 (c-set-offset 'stream-op 'c-lineup-streamop)
Dave Love <fx@gnu.org>
parents:
diff changeset
2601
Dave Love <fx@gnu.org>
parents:
diff changeset
2602 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
2603
Dave Love <fx@gnu.org>
parents:
diff changeset
2604 Now the function looks like this after re-indenting (using @kbd{C-c
Dave Love <fx@gnu.org>
parents:
diff changeset
2605 C-q}):
Dave Love <fx@gnu.org>
parents:
diff changeset
2606 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
2607 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
2608
Dave Love <fx@gnu.org>
parents:
diff changeset
2609 1: void main(int argc, char**)
Dave Love <fx@gnu.org>
parents:
diff changeset
2610 2: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
2611 3: cout << "There were "
Dave Love <fx@gnu.org>
parents:
diff changeset
2612 4: << argc
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2613 5: << " arguments passed to the program"
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2614 6: << endl;
Dave Love <fx@gnu.org>
parents:
diff changeset
2615 7: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
2616
Dave Love <fx@gnu.org>
parents:
diff changeset
2617 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
2618 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
2619
Dave Love <fx@gnu.org>
parents:
diff changeset
2620 Custom indentation functions can be as simple or as complex as you like,
Dave Love <fx@gnu.org>
parents:
diff changeset
2621 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
2622 a custom indentation function associated with it.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2623
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2624 @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
2625 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
2626 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
2627 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
2628 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
2629 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
2630
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2631
Dave Love <fx@gnu.org>
parents:
diff changeset
2632 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2633 @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
2634 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2635 @subsection Custom Brace and Colon Hanging
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2636 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
2637
Dave Love <fx@gnu.org>
parents:
diff changeset
2638 @vindex c-hanging-braces-alist
Dave Love <fx@gnu.org>
parents:
diff changeset
2639 @vindex hanging-braces-alist (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
2640 Syntactic symbols aren't the only place where you can customize
Dave Love <fx@gnu.org>
parents:
diff changeset
2641 @ccmode{} with the lisp equivalent of callback functions. Brace
Dave Love <fx@gnu.org>
parents:
diff changeset
2642 ``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
2643 syntactic symbols on the @code{c-hanging-braces-alist} style variable.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2644 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
2645 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
2646 (@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
2647 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
2648 is entered.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2649
Dave Love <fx@gnu.org>
parents:
diff changeset
2650 @cindex customizing brace hanging
Dave Love <fx@gnu.org>
parents:
diff changeset
2651 These @var{ACTION} functions are called with two arguments: the
Dave Love <fx@gnu.org>
parents:
diff changeset
2652 syntactic symbol for the brace, and the buffer position at which the
Dave Love <fx@gnu.org>
parents:
diff changeset
2653 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
2654 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
2655 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
2656 normal brace hanging semantics.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2657
Dave Love <fx@gnu.org>
parents:
diff changeset
2658 As an example, @ccmode{} itself uses this feature to dynamically
Dave Love <fx@gnu.org>
parents:
diff changeset
2659 determine the hanginess of braces which close ``do-while''
Dave Love <fx@gnu.org>
parents:
diff changeset
2660 constructs:
Dave Love <fx@gnu.org>
parents:
diff changeset
2661 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
2662 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
2663
Dave Love <fx@gnu.org>
parents:
diff changeset
2664 void do_list( int count, char** atleast_one_string )
Dave Love <fx@gnu.org>
parents:
diff changeset
2665 @{
Dave Love <fx@gnu.org>
parents:
diff changeset
2666 int i=0;
Dave Love <fx@gnu.org>
parents:
diff changeset
2667 do @{
Dave Love <fx@gnu.org>
parents:
diff changeset
2668 handle_string( atleast_one_string[i] );
Dave Love <fx@gnu.org>
parents:
diff changeset
2669 i++;
Dave Love <fx@gnu.org>
parents:
diff changeset
2670 @} while( i < count );
Dave Love <fx@gnu.org>
parents:
diff changeset
2671 @}
Dave Love <fx@gnu.org>
parents:
diff changeset
2672
Dave Love <fx@gnu.org>
parents:
diff changeset
2673 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
2674 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
2675
Dave Love <fx@gnu.org>
parents:
diff changeset
2676 @findex c-snug-do-while
Dave Love <fx@gnu.org>
parents:
diff changeset
2677 @findex snug-do-while (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
2678 @ccmode{} assigns the @code{block-close} syntactic symbol to the
Dave Love <fx@gnu.org>
parents:
diff changeset
2679 brace that closes the @code{do} construct, and normally we'd like the
Dave Love <fx@gnu.org>
parents:
diff changeset
2680 line that follows a @code{block-close} brace to begin on a separate
Dave Love <fx@gnu.org>
parents:
diff changeset
2681 line. However, with ``do-while'' constructs, we want the
Dave Love <fx@gnu.org>
parents:
diff changeset
2682 @code{while} clause to follow the closing brace. To do this, we
Dave Love <fx@gnu.org>
parents:
diff changeset
2683 associate the @code{block-close} symbol with the @var{ACTION} function
Dave Love <fx@gnu.org>
parents:
diff changeset
2684 @code{c-snug-do-while}:
Dave Love <fx@gnu.org>
parents:
diff changeset
2685 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
2686
Dave Love <fx@gnu.org>
parents:
diff changeset
2687 (defun c-snug-do-while (syntax pos)
Dave Love <fx@gnu.org>
parents:
diff changeset
2688 "Dynamically calculate brace hanginess for do-while statements.
Dave Love <fx@gnu.org>
parents:
diff changeset
2689 Using this function, `while' clauses that end a `do-while' block will
Dave Love <fx@gnu.org>
parents:
diff changeset
2690 remain on the same line as the brace that closes that block.
Dave Love <fx@gnu.org>
parents:
diff changeset
2691
Dave Love <fx@gnu.org>
parents:
diff changeset
2692 See `c-hanging-braces-alist' for how to utilize this function as an
Dave Love <fx@gnu.org>
parents:
diff changeset
2693 ACTION associated with `block-close' syntax."
Dave Love <fx@gnu.org>
parents:
diff changeset
2694 (save-excursion
Dave Love <fx@gnu.org>
parents:
diff changeset
2695 (let (langelem)
Dave Love <fx@gnu.org>
parents:
diff changeset
2696 (if (and (eq syntax 'block-close)
Dave Love <fx@gnu.org>
parents:
diff changeset
2697 (setq langelem (assq 'block-close c-syntactic-context))
Dave Love <fx@gnu.org>
parents:
diff changeset
2698 (progn (goto-char (cdr langelem))
Dave Love <fx@gnu.org>
parents:
diff changeset
2699 (if (= (following-char) ?@{)
Dave Love <fx@gnu.org>
parents:
diff changeset
2700 (forward-sexp -1))
Dave Love <fx@gnu.org>
parents:
diff changeset
2701 (looking-at "\\<do\\>[^_]")))
Dave Love <fx@gnu.org>
parents:
diff changeset
2702 '(before)
Dave Love <fx@gnu.org>
parents:
diff changeset
2703 '(before after)))))
Dave Love <fx@gnu.org>
parents:
diff changeset
2704
Dave Love <fx@gnu.org>
parents:
diff changeset
2705 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
2706
Dave Love <fx@gnu.org>
parents:
diff changeset
2707 This function simply looks to see if the brace closes a ``do-while''
Dave Love <fx@gnu.org>
parents:
diff changeset
2708 clause and if so, returns the list @samp{(before)} indicating
Dave Love <fx@gnu.org>
parents:
diff changeset
2709 that a newline should be inserted before the brace, but not after it.
Dave Love <fx@gnu.org>
parents:
diff changeset
2710 In all other cases, it returns the list @samp{(before after)} so
Dave Love <fx@gnu.org>
parents:
diff changeset
2711 that the brace appears on a line by itself.
Dave Love <fx@gnu.org>
parents:
diff changeset
2712
Dave Love <fx@gnu.org>
parents:
diff changeset
2713 @vindex c-syntactic-context
Dave Love <fx@gnu.org>
parents:
diff changeset
2714 @vindex syntactic-context (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
2715 During the call to the brace hanging @var{ACTION} function, the variable
Dave Love <fx@gnu.org>
parents:
diff changeset
2716 @code{c-syntactic-context} is bound to the full syntactic analysis list.
Dave Love <fx@gnu.org>
parents:
diff changeset
2717
Dave Love <fx@gnu.org>
parents:
diff changeset
2718 @cindex customizing colon hanging
Dave Love <fx@gnu.org>
parents:
diff changeset
2719 @vindex c-hanging-colon-alist
Dave Love <fx@gnu.org>
parents:
diff changeset
2720 @vindex hanging-colon-alist (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
2721 Note that for symmetry, colon hanginess should be customizable by
Dave Love <fx@gnu.org>
parents:
diff changeset
2722 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
2723 @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
2724 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
2725
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2726
Dave Love <fx@gnu.org>
parents:
diff changeset
2727 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2728 @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
2729 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2730 @subsection Customizing Semi-colons and Commas
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2731 @cindex customizing semi-colons and commas
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2732 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
2733
Dave Love <fx@gnu.org>
parents:
diff changeset
2734 @vindex c-hanging-semi&comma-criteria
Dave Love <fx@gnu.org>
parents:
diff changeset
2735 @vindex hanging-semi&comma-criteria (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
2736 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
2737 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
2738 Modes}). This is controlled by the style variable
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2739 @code{c-hanging-semi&comma-criteria}, which contains a list of functions
Dave Love <fx@gnu.org>
parents:
diff changeset
2740 that are called in the order they appear. Each function is called with
Dave Love <fx@gnu.org>
parents:
diff changeset
2741 zero arguments, and is expected to return one of the following values:
Dave Love <fx@gnu.org>
parents:
diff changeset
2742
Dave Love <fx@gnu.org>
parents:
diff changeset
2743 @itemize @bullet
Dave Love <fx@gnu.org>
parents:
diff changeset
2744 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
2745 non-@code{nil} --- A newline is inserted, and no more functions from the
Dave Love <fx@gnu.org>
parents:
diff changeset
2746 list are called.
Dave Love <fx@gnu.org>
parents:
diff changeset
2747
Dave Love <fx@gnu.org>
parents:
diff changeset
2748 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
2749 @code{stop} --- No more functions from the list are called, but no
Dave Love <fx@gnu.org>
parents:
diff changeset
2750 newline is inserted.
Dave Love <fx@gnu.org>
parents:
diff changeset
2751
Dave Love <fx@gnu.org>
parents:
diff changeset
2752 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
2753 @code{nil} --- No determination is made, and the next function in the
Dave Love <fx@gnu.org>
parents:
diff changeset
2754 list is called.
Dave Love <fx@gnu.org>
parents:
diff changeset
2755
Dave Love <fx@gnu.org>
parents:
diff changeset
2756 @end itemize
Dave Love <fx@gnu.org>
parents:
diff changeset
2757
Dave Love <fx@gnu.org>
parents:
diff changeset
2758 If every function in the list is called without a determination being
Dave Love <fx@gnu.org>
parents:
diff changeset
2759 made, then no newline is added. The default value for this variable is a
Dave Love <fx@gnu.org>
parents:
diff changeset
2760 list containing a single function which inserts newlines only after
Dave Love <fx@gnu.org>
parents:
diff changeset
2761 semi-colons which do not appear inside parenthesis lists (i.e. those
Dave Love <fx@gnu.org>
parents:
diff changeset
2762 that separate @code{for}-clause statements).
Dave Love <fx@gnu.org>
parents:
diff changeset
2763
Dave Love <fx@gnu.org>
parents:
diff changeset
2764 @findex c-semi&comma-no-newlines-before-nonblanks
Dave Love <fx@gnu.org>
parents:
diff changeset
2765 @findex semi&comma-no-newlines-before-nonblanks (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
2766 Here's an example of a criteria function, provided by @ccmode{}, that
Dave Love <fx@gnu.org>
parents:
diff changeset
2767 will prevent newlines from being inserted after semicolons when there is
Dave Love <fx@gnu.org>
parents:
diff changeset
2768 a non-blank following line. Otherwise, it makes no determination. To
Dave Love <fx@gnu.org>
parents:
diff changeset
2769 use, add this to the front of the @code{c-hanging-semi&comma-criteria}
Dave Love <fx@gnu.org>
parents:
diff changeset
2770 list.
Dave Love <fx@gnu.org>
parents:
diff changeset
2771
Dave Love <fx@gnu.org>
parents:
diff changeset
2772 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
2773 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
2774
Dave Love <fx@gnu.org>
parents:
diff changeset
2775 (defun c-semi&comma-no-newlines-before-nonblanks ()
Dave Love <fx@gnu.org>
parents:
diff changeset
2776 (save-excursion
Dave Love <fx@gnu.org>
parents:
diff changeset
2777 (if (and (eq last-command-char ?\;)
Dave Love <fx@gnu.org>
parents:
diff changeset
2778 (zerop (forward-line 1))
Dave Love <fx@gnu.org>
parents:
diff changeset
2779 (not (looking-at "^[ \t]*$")))
Dave Love <fx@gnu.org>
parents:
diff changeset
2780 'stop
Dave Love <fx@gnu.org>
parents:
diff changeset
2781 nil)))
Dave Love <fx@gnu.org>
parents:
diff changeset
2782
Dave Love <fx@gnu.org>
parents:
diff changeset
2783 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
2784 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
2785
Dave Love <fx@gnu.org>
parents:
diff changeset
2786 @findex c-semi&comma-inside-parenlist
Dave Love <fx@gnu.org>
parents:
diff changeset
2787 @findex c-semi&comma-no-newlines-for-oneline-inliners
Dave Love <fx@gnu.org>
parents:
diff changeset
2788 @findex semi&comma-inside-parenlist (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
2789 @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
2790 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
2791 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
2792 statements. In addition to
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2793 @code{c-semi&comma-no-newlines-before-nonblanks} described above,
Dave Love <fx@gnu.org>
parents:
diff changeset
2794 @ccmode{} also comes with the criteria function
Dave Love <fx@gnu.org>
parents:
diff changeset
2795 @code{c-semi&comma-no-newlines-for-oneline-inliners}, which suppresses
Dave Love <fx@gnu.org>
parents:
diff changeset
2796 newlines after semicolons inside one-line inline method definitions
Dave Love <fx@gnu.org>
parents:
diff changeset
2797 (i.e. in C++ or Java).
Dave Love <fx@gnu.org>
parents:
diff changeset
2798
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2799
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2800 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2801 @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
2802 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2803 @subsection Other Special Indentations
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2804 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
2805
Dave Love <fx@gnu.org>
parents:
diff changeset
2806 @vindex c-label-minimum-indentation
Dave Love <fx@gnu.org>
parents:
diff changeset
2807 @vindex label-minimum-indentation (c-)
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2808 In @samp{gnu} style (@pxref{Built-in Styles}), a minimum indentation
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2809 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
2810 indentation is controlled by the style variable
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2811 @code{c-label-minimum-indentation}. The default value for this variable
Dave Love <fx@gnu.org>
parents:
diff changeset
2812 is 1.
Dave Love <fx@gnu.org>
parents:
diff changeset
2813
Dave Love <fx@gnu.org>
parents:
diff changeset
2814 @vindex c-special-indent-hook
Dave Love <fx@gnu.org>
parents:
diff changeset
2815 @vindex special-indent-hook (c-)
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2816 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
2817 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
2818 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
2819 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
2820 dictates, such as adding extra indentation to constructors or destructor
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2821 declarations in a class definition, etc. Note however, that you should
Dave Love <fx@gnu.org>
parents:
diff changeset
2822 not change point or mark inside your @code{c-special-indent-hook}
Dave Love <fx@gnu.org>
parents:
diff changeset
2823 functions (i.e. you'll probably want to wrap your function in a
Dave Love <fx@gnu.org>
parents:
diff changeset
2824 @code{save-excursion}).
Dave Love <fx@gnu.org>
parents:
diff changeset
2825
Dave Love <fx@gnu.org>
parents:
diff changeset
2826 Setting @code{c-special-indent-hook} in your style definition is handled
Dave Love <fx@gnu.org>
parents:
diff changeset
2827 slightly differently than other variables. In your style definition,
Dave Love <fx@gnu.org>
parents:
diff changeset
2828 you should set the value for
Dave Love <fx@gnu.org>
parents:
diff changeset
2829 @code{c-special-indent-hook} to a function or list of functions, which
Dave Love <fx@gnu.org>
parents:
diff changeset
2830 will be appended to @code{c-special-indent-hook} using @code{add-hook}.
Dave Love <fx@gnu.org>
parents:
diff changeset
2831 That way, the current setting for the buffer local value of
Dave Love <fx@gnu.org>
parents:
diff changeset
2832 @code{c-special-indent-hook} won't be overridden.
Dave Love <fx@gnu.org>
parents:
diff changeset
2833
Dave Love <fx@gnu.org>
parents:
diff changeset
2834 @kindex M-;
Dave Love <fx@gnu.org>
parents:
diff changeset
2835 @findex indent-for-comment
Dave Love <fx@gnu.org>
parents:
diff changeset
2836 @vindex c-indent-comments-syntactically-p
Dave Love <fx@gnu.org>
parents:
diff changeset
2837 @vindex indent-comments-syntactically-p (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
2838 @vindex comment-column
Dave Love <fx@gnu.org>
parents:
diff changeset
2839 Normally, the standard Emacs command @kbd{M-;}
Dave Love <fx@gnu.org>
parents:
diff changeset
2840 (@code{indent-for-comment}) will indent comment only lines to
Dave Love <fx@gnu.org>
parents:
diff changeset
2841 @code{comment-column}. Some users however, prefer that @kbd{M-;} act
Dave Love <fx@gnu.org>
parents:
diff changeset
2842 just like @kbd{TAB} for purposes of indenting comment-only lines;
Dave Love <fx@gnu.org>
parents:
diff changeset
2843 i.e. they want the comments to always indent as they would for normal
Dave Love <fx@gnu.org>
parents:
diff changeset
2844 code, regardless of whether @kbd{TAB} or @kbd{M-;} were used. This
Dave Love <fx@gnu.org>
parents:
diff changeset
2845 behavior is controlled by the variable
Dave Love <fx@gnu.org>
parents:
diff changeset
2846 @code{c-indent-comments-syntactically-p}. When @code{nil} (the
Dave Love <fx@gnu.org>
parents:
diff changeset
2847 default), @kbd{M-;} indents comment-only lines to @code{comment-column},
Dave Love <fx@gnu.org>
parents:
diff changeset
2848 otherwise, they are indented just as they would be if @kbd{TAB} were
Dave Love <fx@gnu.org>
parents:
diff changeset
2849 typed.
Dave Love <fx@gnu.org>
parents:
diff changeset
2850
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2851 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
2852 @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
2853 start at @code{comment-column}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2854
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2855
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2856 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2857 @node Syntactic Symbols, Indentation Functions, Customizing Indentation, Top
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2858 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2859 @chapter Syntactic Symbols
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2860 @cindex syntactic symbols
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2861 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
2862
Dave Love <fx@gnu.org>
parents:
diff changeset
2863 @vindex c-offsets-alist
Dave Love <fx@gnu.org>
parents:
diff changeset
2864 @vindex offsets-alist (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
2865 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
2866 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
2867 description. More detailed descriptions follow.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2868
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2869 @table @code
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2870 @item string
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2871 Inside a multi-line string.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2872 @item c
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2873 Inside a multi-line C style block comment.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2874 @item defun-open
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2875 Brace that opens a top-level function definition.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2876 @item defun-close
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2877 Brace that closes a top-level function definition.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2878 @item defun-block-intro
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2879 The first line in a top-level defun.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2880 @item class-open
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2881 Brace that opens a class definition.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2882 @item class-close
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2883 Brace that closes a class definition.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2884 @item inline-open
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2885 Brace that opens an in-class inline method.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2886 @item inline-close
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2887 Brace that closes an in-class inline method.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2888 @item func-decl-cont
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2889 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
2890 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
2891 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
2892 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
2893 here.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2894 @item knr-argdecl-intro
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2895 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
2896 @item knr-argdecl
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2897 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
2898 @item topmost-intro
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2899 The first line in a ``topmost'' definition.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2900 @item topmost-intro-cont
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2901 Topmost definition continuation lines.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2902 @item member-init-intro
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2903 First line in a member initialization list.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2904 @item member-init-cont
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2905 Subsequent member initialization list lines.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2906 @item inher-intro
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2907 First line of a multiple inheritance list.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2908 @item inher-cont
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2909 Subsequent multiple inheritance lines.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2910 @item block-open
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2911 Statement block open brace.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2912 @item block-close
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2913 Statement block close brace.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2914 @item brace-list-open
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2915 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
2916 @item brace-list-close
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2917 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
2918 @item brace-list-intro
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2919 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
2920 @item brace-list-entry
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2921 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
2922 @item brace-entry-open
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2923 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
2924 with an open brace.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2925 @item statement
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2926 A statement.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2927 @item statement-cont
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2928 A continuation of a statement.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2929 @item statement-block-intro
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2930 The first line in a new statement block.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2931 @item statement-case-intro
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2932 The first line in a case block.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2933 @item statement-case-open
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2934 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
2935 @item substatement
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2936 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
2937 @item substatement-open
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2938 The brace that opens a substatement block.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2939 @item case-label
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2940 A @code{case} or @code{default} label.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2941 @item access-label
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2942 C++ access control label.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2943 @item label
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2944 Any non-special C label.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2945 @item do-while-closure
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2946 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
2947 @item else-clause
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2948 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
2949 @item catch-clause
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2950 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
2951 @code{try}-@code{catch} construct.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2952 @item comment-intro
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2953 A line containing only a comment introduction.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2954 @item arglist-intro
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2955 The first line in an argument list.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2956 @item arglist-cont
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2957 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
2958 as the arglist opening paren.
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2959 @item arglist-cont-nonempty
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2960 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
2961 same line as the arglist opening paren.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2962 @item arglist-close
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2963 The solo close paren of an argument list.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2964 @item stream-op
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2965 Lines continuing a stream operator (C++ only).
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2966 @item inclass
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2967 The line is nested inside a class definition.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2968 @item cpp-macro
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2969 The start of a C preprocessor macro definition.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2970 @item cpp-macro-cont
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2971 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
2972 @item friend
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2973 A C++ friend declaration.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2974 @item objc-method-intro
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2975 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
2976 @item objc-method-args-cont
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2977 Lines continuing an Objective-C method. definition
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2978 @item objc-method-call-cont
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2979 Lines continuing an Objective-C method call.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2980 @item extern-lang-open
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2981 Brace that opens an external language block.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2982 @item extern-lang-close
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2983 Brace that closes an external language block.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2984 @item inextern-lang
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2985 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
2986 language blocks (e.g. @code{extern "C" @{}).
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2987 @item namespace-open
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2988 Brace that opens a C++ namespace block.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2989 @item namespace-close
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2990 Brace that closes a C++ namespace block.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2991 @item innamespace
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2992 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
2993 namespace blocks.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2994 @item template-args-cont
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2995 C++ template argument list continuations.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2996 @item inlambda
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2997 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
2998 (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
2999 @item lambda-intro-cont
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3000 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
3001 @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
3002 @item inexpr-statement
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3003 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
3004 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
3005 statement block as an argument in Pike.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3006 @item inexpr-class
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3007 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
3008 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
3009 Java.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3010 @end table
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
3011
Dave Love <fx@gnu.org>
parents:
diff changeset
3012 @cindex -open syntactic symbols
Dave Love <fx@gnu.org>
parents:
diff changeset
3013 @cindex -close syntactic symbols
Dave Love <fx@gnu.org>
parents:
diff changeset
3014 Most syntactic symbol names follow a general naming convention. When a
Dave Love <fx@gnu.org>
parents:
diff changeset
3015 line begins with an open or close brace, the syntactic symbol will
Dave Love <fx@gnu.org>
parents:
diff changeset
3016 contain the suffix @code{-open} or @code{-close} respectively.
Dave Love <fx@gnu.org>
parents:
diff changeset
3017
Dave Love <fx@gnu.org>
parents:
diff changeset
3018 @cindex -intro syntactic symbols
Dave Love <fx@gnu.org>
parents:
diff changeset
3019 @cindex -cont syntactic symbols
Dave Love <fx@gnu.org>
parents:
diff changeset
3020 @cindex -block-intro syntactic symbols
Dave Love <fx@gnu.org>
parents:
diff changeset
3021 Usually, a distinction is made between the first line that introduces a
Dave Love <fx@gnu.org>
parents:
diff changeset
3022 construct and lines that continue a construct, and the syntactic symbols
Dave Love <fx@gnu.org>
parents:
diff changeset
3023 that represent these lines will contain the suffix @code{-intro} or
Dave Love <fx@gnu.org>
parents:
diff changeset
3024 @code{-cont} respectively. As a sub-classification of this scheme, a
Dave Love <fx@gnu.org>
parents:
diff changeset
3025 line which is the first of a particular brace block construct will
Dave Love <fx@gnu.org>
parents:
diff changeset
3026 contain the suffix @code{-block-intro}.
Dave Love <fx@gnu.org>
parents:
diff changeset
3027
Dave Love <fx@gnu.org>
parents:
diff changeset
3028 Let's look at some examples to understand how this works. Remember that
Dave Love <fx@gnu.org>
parents:
diff changeset
3029 you can check the syntax of any line by using @kbd{C-c C-s}.
Dave Love <fx@gnu.org>
parents:
diff changeset
3030 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
3031 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
3032
Dave Love <fx@gnu.org>
parents:
diff changeset
3033 1: void
Dave Love <fx@gnu.org>
parents:
diff changeset
3034 2: swap( int& a, int& b )
Dave Love <fx@gnu.org>
parents:
diff changeset
3035 3: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
3036 4: int tmp = a;
Dave Love <fx@gnu.org>
parents:
diff changeset
3037 5: a = b;
Dave Love <fx@gnu.org>
parents:
diff changeset
3038 6: b = tmp;
Dave Love <fx@gnu.org>
parents:
diff changeset
3039 7: int ignored =
Dave Love <fx@gnu.org>
parents:
diff changeset
3040 8: a + b;
Dave Love <fx@gnu.org>
parents:
diff changeset
3041 9: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
3042
Dave Love <fx@gnu.org>
parents:
diff changeset
3043 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
3044 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
3045
Dave Love <fx@gnu.org>
parents:
diff changeset
3046 @cindex topmost-intro syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3047 @cindex topmost-intro-cont syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3048 @cindex defun-open syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3049 @cindex defun-close syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3050 @cindex defun-block-intro syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3051 Line 1 shows a @code{topmost-intro} since it is the first line that
Dave Love <fx@gnu.org>
parents:
diff changeset
3052 introduces a top-level construct. Line 2 is a continuation of the
Dave Love <fx@gnu.org>
parents:
diff changeset
3053 top-level construct introduction so it has the syntax
Dave Love <fx@gnu.org>
parents:
diff changeset
3054 @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
3055 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
3056 corresponding
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
3057 @code{defun-close} since it contains the brace that closes the top-level
Dave Love <fx@gnu.org>
parents:
diff changeset
3058 function definition. Line 4 is a @code{defun-block-intro}, i.e. it is
Dave Love <fx@gnu.org>
parents:
diff changeset
3059 the first line of a brace-block, enclosed in a
Dave Love <fx@gnu.org>
parents:
diff changeset
3060 top-level function definition.
Dave Love <fx@gnu.org>
parents:
diff changeset
3061
Dave Love <fx@gnu.org>
parents:
diff changeset
3062 @cindex statement syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3063 @cindex statement-cont syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3064 Lines 5, 6, and 7 are all given @code{statement} syntax since there
Dave Love <fx@gnu.org>
parents:
diff changeset
3065 isn't much special about them. Note however that line 8 is given
Dave Love <fx@gnu.org>
parents:
diff changeset
3066 @code{statement-cont} syntax since it continues the statement begun
Dave Love <fx@gnu.org>
parents:
diff changeset
3067 on the previous line.
Dave Love <fx@gnu.org>
parents:
diff changeset
3068
Dave Love <fx@gnu.org>
parents:
diff changeset
3069 Here's another example, which illustrates some C++ class syntactic
Dave Love <fx@gnu.org>
parents:
diff changeset
3070 symbols:
Dave Love <fx@gnu.org>
parents:
diff changeset
3071 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
3072 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
3073
Dave Love <fx@gnu.org>
parents:
diff changeset
3074 1: class Bass
Dave Love <fx@gnu.org>
parents:
diff changeset
3075 2: : public Guitar,
Dave Love <fx@gnu.org>
parents:
diff changeset
3076 3: public Amplifiable
Dave Love <fx@gnu.org>
parents:
diff changeset
3077 4: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
3078 5: public:
Dave Love <fx@gnu.org>
parents:
diff changeset
3079 6: Bass()
Dave Love <fx@gnu.org>
parents:
diff changeset
3080 7: : eString( new BassString( 0.105 )),
Dave Love <fx@gnu.org>
parents:
diff changeset
3081 8: aString( new BassString( 0.085 )),
Dave Love <fx@gnu.org>
parents:
diff changeset
3082 9: dString( new BassString( 0.065 )),
Dave Love <fx@gnu.org>
parents:
diff changeset
3083 10: gString( new BassString( 0.045 ))
Dave Love <fx@gnu.org>
parents:
diff changeset
3084 11: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
3085 12: eString.tune( 'E' );
Dave Love <fx@gnu.org>
parents:
diff changeset
3086 13: aString.tune( 'A' );
Dave Love <fx@gnu.org>
parents:
diff changeset
3087 14: dString.tune( 'D' );
Dave Love <fx@gnu.org>
parents:
diff changeset
3088 15: gString.tune( 'G' );
Dave Love <fx@gnu.org>
parents:
diff changeset
3089 16: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
3090 17: friend class Luthier;
Dave Love <fx@gnu.org>
parents:
diff changeset
3091 18: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
3092
Dave Love <fx@gnu.org>
parents:
diff changeset
3093 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
3094 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
3095
Dave Love <fx@gnu.org>
parents:
diff changeset
3096 @cindex class-open syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3097 @cindex class-close syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3098 As in the previous example, line 1 has the @code{topmost-intro} syntax.
Dave Love <fx@gnu.org>
parents:
diff changeset
3099 Here however, the brace that opens a C++ class definition on line 4 is
Dave Love <fx@gnu.org>
parents:
diff changeset
3100 assigned the @code{class-open} syntax. Note that in C++, classes,
Dave Love <fx@gnu.org>
parents:
diff changeset
3101 structs, and unions are essentially equivalent syntactically (and are
Dave Love <fx@gnu.org>
parents:
diff changeset
3102 very similar semantically), so replacing the @code{class} keyword in the
Dave Love <fx@gnu.org>
parents:
diff changeset
3103 example above with @code{struct} or @code{union} would still result in a
Dave Love <fx@gnu.org>
parents:
diff changeset
3104 syntax of @code{class-open} for line 4 @footnote{This is the case even
Dave Love <fx@gnu.org>
parents:
diff changeset
3105 for C and Objective-C. For consistency, structs in all supported
Dave Love <fx@gnu.org>
parents:
diff changeset
3106 languages are syntactically equivalent to classes. Note however that
Dave Love <fx@gnu.org>
parents:
diff changeset
3107 the keyword @code{class} is meaningless in C and Objective-C.}.
Dave Love <fx@gnu.org>
parents:
diff changeset
3108 Similarly, line 18 is assigned @code{class-close} syntax.
Dave Love <fx@gnu.org>
parents:
diff changeset
3109
Dave Love <fx@gnu.org>
parents:
diff changeset
3110 @cindex inher-intro syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3111 @cindex inher-cont syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3112 Line 2 introduces the inheritance list for the class so it is assigned
Dave Love <fx@gnu.org>
parents:
diff changeset
3113 the @code{inher-intro} syntax, and line 3, which continues the
Dave Love <fx@gnu.org>
parents:
diff changeset
3114 inheritance list is given @code{inher-cont} syntax.
Dave Love <fx@gnu.org>
parents:
diff changeset
3115
Dave Love <fx@gnu.org>
parents:
diff changeset
3116 @cindex access-label syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3117 @cindex inclass syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3118 Hitting @kbd{C-c C-s} on line 5 shows the following analysis:
Dave Love <fx@gnu.org>
parents:
diff changeset
3119
Dave Love <fx@gnu.org>
parents:
diff changeset
3120 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
3121 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
3122
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3123 @code{((inclass . 58) (access-label . 67))}
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
3124
Dave Love <fx@gnu.org>
parents:
diff changeset
3125 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
3126 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
3127
Dave Love <fx@gnu.org>
parents:
diff changeset
3128 @noindent
Dave Love <fx@gnu.org>
parents:
diff changeset
3129 The primary syntactic symbol for this line is @code{access-label} as
Dave Love <fx@gnu.org>
parents:
diff changeset
3130 this a label keyword that specifies access protection in C++. However,
Dave Love <fx@gnu.org>
parents:
diff changeset
3131 because this line is also a top-level construct inside a class
Dave Love <fx@gnu.org>
parents:
diff changeset
3132 definition, the analysis actually shows two syntactic symbols. The
Dave Love <fx@gnu.org>
parents:
diff changeset
3133 other syntactic symbol assigned to this line is @code{inclass}.
Dave Love <fx@gnu.org>
parents:
diff changeset
3134 Similarly, line 6 is given both @code{inclass} and @code{topmost-intro}
Dave Love <fx@gnu.org>
parents:
diff changeset
3135 syntax:
Dave Love <fx@gnu.org>
parents:
diff changeset
3136
Dave Love <fx@gnu.org>
parents:
diff changeset
3137 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
3138 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
3139
Dave Love <fx@gnu.org>
parents:
diff changeset
3140 @code{((inclass . 58) (topmost-intro . 60))}
Dave Love <fx@gnu.org>
parents:
diff changeset
3141
Dave Love <fx@gnu.org>
parents:
diff changeset
3142 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
3143 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
3144
Dave Love <fx@gnu.org>
parents:
diff changeset
3145 @cindex member-init-intro syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3146 @cindex member-init-cont syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3147 Line 7 introduces a C++ member initialization list and as such is given
Dave Love <fx@gnu.org>
parents:
diff changeset
3148 @code{member-init-intro} syntax. Note that in this case it is
Dave Love <fx@gnu.org>
parents:
diff changeset
3149 @emph{not} assigned @code{inclass} since this is not considered a
Dave Love <fx@gnu.org>
parents:
diff changeset
3150 top-level construct. Lines 8 through 10 are all assigned
Dave Love <fx@gnu.org>
parents:
diff changeset
3151 @code{member-init-cont} since they continue the member initialization
Dave Love <fx@gnu.org>
parents:
diff changeset
3152 list started on line 7.
Dave Love <fx@gnu.org>
parents:
diff changeset
3153
Dave Love <fx@gnu.org>
parents:
diff changeset
3154 @cindex in-class inline methods
Dave Love <fx@gnu.org>
parents:
diff changeset
3155 @cindex inline-open syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3156 @cindex inline-close syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3157 Line 11's analysis is a bit more complicated:
Dave Love <fx@gnu.org>
parents:
diff changeset
3158
Dave Love <fx@gnu.org>
parents:
diff changeset
3159 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
3160 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
3161
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3162 @code{((inclass . 58) (inline-open))}
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
3163
Dave Love <fx@gnu.org>
parents:
diff changeset
3164 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
3165 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
3166
Dave Love <fx@gnu.org>
parents:
diff changeset
3167 This line is assigned a syntax of both @code{inline-open} and
Dave Love <fx@gnu.org>
parents:
diff changeset
3168 @code{inclass} because it opens an @dfn{in-class} C++ inline method
Dave Love <fx@gnu.org>
parents:
diff changeset
3169 definition. This is distinct from, but related to, the C++ notion of an
Dave Love <fx@gnu.org>
parents:
diff changeset
3170 inline function in that its definition occurs inside an enclosing class
Dave Love <fx@gnu.org>
parents:
diff changeset
3171 definition, which in C++ implies that the function should be inlined.
Dave Love <fx@gnu.org>
parents:
diff changeset
3172 If though, the definition of the @code{Bass} constructor appeared
Dave Love <fx@gnu.org>
parents:
diff changeset
3173 outside the class definition, the construct would be given the
Dave Love <fx@gnu.org>
parents:
diff changeset
3174 @code{defun-open} syntax, even if the keyword @code{inline} appeared
Dave Love <fx@gnu.org>
parents:
diff changeset
3175 before the method name, as in:
Dave Love <fx@gnu.org>
parents:
diff changeset
3176 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
3177 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
3178
Dave Love <fx@gnu.org>
parents:
diff changeset
3179 class Bass
Dave Love <fx@gnu.org>
parents:
diff changeset
3180 : public Guitar,
Dave Love <fx@gnu.org>
parents:
diff changeset
3181 public Amplifiable
Dave Love <fx@gnu.org>
parents:
diff changeset
3182 @{
Dave Love <fx@gnu.org>
parents:
diff changeset
3183 public:
Dave Love <fx@gnu.org>
parents:
diff changeset
3184 Bass();
Dave Love <fx@gnu.org>
parents:
diff changeset
3185 @}
Dave Love <fx@gnu.org>
parents:
diff changeset
3186
Dave Love <fx@gnu.org>
parents:
diff changeset
3187 inline
Dave Love <fx@gnu.org>
parents:
diff changeset
3188 Bass::Bass()
Dave Love <fx@gnu.org>
parents:
diff changeset
3189 : eString( new BassString( 0.105 )),
Dave Love <fx@gnu.org>
parents:
diff changeset
3190 aString( new BassString( 0.085 )),
Dave Love <fx@gnu.org>
parents:
diff changeset
3191 dString( new BassString( 0.065 )),
Dave Love <fx@gnu.org>
parents:
diff changeset
3192 gString( new BassString( 0.045 ))
Dave Love <fx@gnu.org>
parents:
diff changeset
3193 @{
Dave Love <fx@gnu.org>
parents:
diff changeset
3194 eString.tune( 'E' );
Dave Love <fx@gnu.org>
parents:
diff changeset
3195 aString.tune( 'A' );
Dave Love <fx@gnu.org>
parents:
diff changeset
3196 dString.tune( 'D' );
Dave Love <fx@gnu.org>
parents:
diff changeset
3197 gString.tune( 'G' );
Dave Love <fx@gnu.org>
parents:
diff changeset
3198 @}
Dave Love <fx@gnu.org>
parents:
diff changeset
3199
Dave Love <fx@gnu.org>
parents:
diff changeset
3200 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
3201 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
3202
Dave Love <fx@gnu.org>
parents:
diff changeset
3203 @cindex friend syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3204 Returning to the previous example, line 16 is given @code{inline-close}
Dave Love <fx@gnu.org>
parents:
diff changeset
3205 syntax, while line 12 is given @code{defun-block-open} syntax, and lines
Dave Love <fx@gnu.org>
parents:
diff changeset
3206 13 through 15 are all given @code{statement} syntax. Line 17 is
Dave Love <fx@gnu.org>
parents:
diff changeset
3207 interesting in that its syntactic analysis list contains three
Dave Love <fx@gnu.org>
parents:
diff changeset
3208 elements:
Dave Love <fx@gnu.org>
parents:
diff changeset
3209
Dave Love <fx@gnu.org>
parents:
diff changeset
3210 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
3211
Dave Love <fx@gnu.org>
parents:
diff changeset
3212 @code{((friend) (inclass . 58) (topmost-intro . 380))}
Dave Love <fx@gnu.org>
parents:
diff changeset
3213
Dave Love <fx@gnu.org>
parents:
diff changeset
3214 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
3215
Dave Love <fx@gnu.org>
parents:
diff changeset
3216 The @code{friend} syntactic symbol is a modifier that typically does not
Dave Love <fx@gnu.org>
parents:
diff changeset
3217 have a relative buffer position.
Dave Love <fx@gnu.org>
parents:
diff changeset
3218
Dave Love <fx@gnu.org>
parents:
diff changeset
3219 Template definitions introduce yet another syntactic symbol:
Dave Love <fx@gnu.org>
parents:
diff changeset
3220
Dave Love <fx@gnu.org>
parents:
diff changeset
3221 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
3222 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
3223
Dave Love <fx@gnu.org>
parents:
diff changeset
3224 1: ThingManager <int,
Dave Love <fx@gnu.org>
parents:
diff changeset
3225 2: Framework::Callback *,
Dave Love <fx@gnu.org>
parents:
diff changeset
3226 3: Mutex> framework_callbacks;
Dave Love <fx@gnu.org>
parents:
diff changeset
3227
Dave Love <fx@gnu.org>
parents:
diff changeset
3228 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
3229 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
3230
Dave Love <fx@gnu.org>
parents:
diff changeset
3231 Here, line 1 is analyzed as a @code{topmost-intro}, but lines 2 and 3
Dave Love <fx@gnu.org>
parents:
diff changeset
3232 are both analyzed as @code{template-args-cont} lines.
Dave Love <fx@gnu.org>
parents:
diff changeset
3233
Dave Love <fx@gnu.org>
parents:
diff changeset
3234 Here is another (totally contrived) example which illustrates how syntax
Dave Love <fx@gnu.org>
parents:
diff changeset
3235 is assigned to various conditional constructs:
Dave Love <fx@gnu.org>
parents:
diff changeset
3236 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
3237 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
3238
Dave Love <fx@gnu.org>
parents:
diff changeset
3239 1: void spam( int index )
Dave Love <fx@gnu.org>
parents:
diff changeset
3240 2: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
3241 3: for( int i=0; i<index; i++ )
Dave Love <fx@gnu.org>
parents:
diff changeset
3242 4: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
3243 5: if( i == 10 )
Dave Love <fx@gnu.org>
parents:
diff changeset
3244 6: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
3245 7: do_something_special();
Dave Love <fx@gnu.org>
parents:
diff changeset
3246 8: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
3247 9: else
Dave Love <fx@gnu.org>
parents:
diff changeset
3248 10: do_something( i );
Dave Love <fx@gnu.org>
parents:
diff changeset
3249 11: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
3250 12: do @{
Dave Love <fx@gnu.org>
parents:
diff changeset
3251 13: another_thing( i-- );
Dave Love <fx@gnu.org>
parents:
diff changeset
3252 14: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
3253 15: while( i > 0 );
Dave Love <fx@gnu.org>
parents:
diff changeset
3254 16: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
3255
Dave Love <fx@gnu.org>
parents:
diff changeset
3256
Dave Love <fx@gnu.org>
parents:
diff changeset
3257 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
3258 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
3259
Dave Love <fx@gnu.org>
parents:
diff changeset
3260 @noindent
Dave Love <fx@gnu.org>
parents:
diff changeset
3261 Only the lines that illustrate new syntactic symbols will be discussed.
Dave Love <fx@gnu.org>
parents:
diff changeset
3262
Dave Love <fx@gnu.org>
parents:
diff changeset
3263 @cindex substatement-open syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3264 @cindex substatement-block-intro syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3265 @cindex block-close syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3266 Line 4 has a brace which opens a conditional's substatement block. It
Dave Love <fx@gnu.org>
parents:
diff changeset
3267 is thus assigned @code{substatement-open} syntax, and since line 5 is
Dave Love <fx@gnu.org>
parents:
diff changeset
3268 the first line in the substatement block, it is assigned
Dave Love <fx@gnu.org>
parents:
diff changeset
3269 @code{substatement-block-intro} syntax. Lines 6 and 7 are assigned
Dave Love <fx@gnu.org>
parents:
diff changeset
3270 similar syntax. Line 8 contains the brace that closes the inner
Dave Love <fx@gnu.org>
parents:
diff changeset
3271 substatement block. It is given the syntax @code{block-close},
Dave Love <fx@gnu.org>
parents:
diff changeset
3272 as are lines 11 and 14.
Dave Love <fx@gnu.org>
parents:
diff changeset
3273
Dave Love <fx@gnu.org>
parents:
diff changeset
3274 @cindex else-clause syntactic symbol
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3275 @cindex catch-clause syntactic symbol
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
3276 Line 9 is a little different --- since it contains the keyword
Dave Love <fx@gnu.org>
parents:
diff changeset
3277 @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
3278 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
3279 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
3280 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
3281 marked with @code{catch-clause}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3282
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3283 @cindex substatement syntactic symbol
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3284 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
3285 conditional introducing keyword @footnote{The list of conditional
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3286 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
3287 @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
3288 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
3289 @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
3290 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
3291 line 10 is assigned the @code{substatement} syntax.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
3292
Dave Love <fx@gnu.org>
parents:
diff changeset
3293 @cindex do-while-closure syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3294 One other difference is seen on line 15. The @code{while} construct
Dave Love <fx@gnu.org>
parents:
diff changeset
3295 that closes a @code{do} conditional is given the special syntax
Dave Love <fx@gnu.org>
parents:
diff changeset
3296 @code{do-while-closure} if it appears on a line by itself. Note that if
Dave Love <fx@gnu.org>
parents:
diff changeset
3297 the @code{while} appeared on the same line as the preceding close brace,
Dave Love <fx@gnu.org>
parents:
diff changeset
3298 that line would have been assigned @code{block-close} syntax instead.
Dave Love <fx@gnu.org>
parents:
diff changeset
3299
Dave Love <fx@gnu.org>
parents:
diff changeset
3300 Switch statements have their own set of syntactic symbols. Here's an
Dave Love <fx@gnu.org>
parents:
diff changeset
3301 example:
Dave Love <fx@gnu.org>
parents:
diff changeset
3302 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
3303 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
3304
Dave Love <fx@gnu.org>
parents:
diff changeset
3305 1: void spam( enum Ingredient i )
Dave Love <fx@gnu.org>
parents:
diff changeset
3306 2: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
3307 3: switch( i ) @{
Dave Love <fx@gnu.org>
parents:
diff changeset
3308 4: case Ham:
Dave Love <fx@gnu.org>
parents:
diff changeset
3309 5: be_a_pig();
Dave Love <fx@gnu.org>
parents:
diff changeset
3310 6: break;
Dave Love <fx@gnu.org>
parents:
diff changeset
3311 7: case Salt:
Dave Love <fx@gnu.org>
parents:
diff changeset
3312 8: drink_some_water();
Dave Love <fx@gnu.org>
parents:
diff changeset
3313 9: break;
Dave Love <fx@gnu.org>
parents:
diff changeset
3314 10: default:
Dave Love <fx@gnu.org>
parents:
diff changeset
3315 11: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
3316 12: what_is_it();
Dave Love <fx@gnu.org>
parents:
diff changeset
3317 13: break;
Dave Love <fx@gnu.org>
parents:
diff changeset
3318 14: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
3319 15: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
3320 14: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
3321
Dave Love <fx@gnu.org>
parents:
diff changeset
3322 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
3323 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
3324
Dave Love <fx@gnu.org>
parents:
diff changeset
3325 @cindex case-label syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3326 @cindex statement-case-intro syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3327 @cindex statement-case-open syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3328 Here, lines 4, 7, and 10 are all assigned @code{case-label} syntax,
Dave Love <fx@gnu.org>
parents:
diff changeset
3329 while lines 5 and 8 are assigned @code{statement-case-intro}. Line 11
Dave Love <fx@gnu.org>
parents:
diff changeset
3330 is treated slightly differently since it contains a brace that opens a
Dave Love <fx@gnu.org>
parents:
diff changeset
3331 block --- it is given @code{statement-case-open} syntax.
Dave Love <fx@gnu.org>
parents:
diff changeset
3332
Dave Love <fx@gnu.org>
parents:
diff changeset
3333 @cindex brace lists
Dave Love <fx@gnu.org>
parents:
diff changeset
3334 There are a set of syntactic symbols that are used to recognize
Dave Love <fx@gnu.org>
parents:
diff changeset
3335 constructs inside of brace lists. A brace list is defined as an
Dave Love <fx@gnu.org>
parents:
diff changeset
3336 @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
3337 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
3338 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
3339 brace lists too. An example:
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
3340 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
3341 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
3342
Dave Love <fx@gnu.org>
parents:
diff changeset
3343 1: static char* ingredients[] =
Dave Love <fx@gnu.org>
parents:
diff changeset
3344 2: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
3345 3: "Ham",
Dave Love <fx@gnu.org>
parents:
diff changeset
3346 4: "Salt",
Dave Love <fx@gnu.org>
parents:
diff changeset
3347 5: NULL
Dave Love <fx@gnu.org>
parents:
diff changeset
3348 6: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
3349
Dave Love <fx@gnu.org>
parents:
diff changeset
3350 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
3351 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
3352
Dave Love <fx@gnu.org>
parents:
diff changeset
3353 @cindex brace-list-open syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3354 @cindex brace-list-intro syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3355 @cindex brace-list-close syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3356 @cindex brace-list-entry syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3357 Following convention, line 2 in this example is assigned
Dave Love <fx@gnu.org>
parents:
diff changeset
3358 @code{brace-list-open} syntax, and line 3 is assigned
Dave Love <fx@gnu.org>
parents:
diff changeset
3359 @code{brace-list-intro} syntax. Likewise, line 6 is assigned
Dave Love <fx@gnu.org>
parents:
diff changeset
3360 @code{brace-list-close} syntax. Lines 4 and 5 however, are assigned
Dave Love <fx@gnu.org>
parents:
diff changeset
3361 @code{brace-list-entry} syntax, as would all subsequent lines in this
Dave Love <fx@gnu.org>
parents:
diff changeset
3362 initializer list.
Dave Love <fx@gnu.org>
parents:
diff changeset
3363
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3364 @cindex brace-entry-open syntactic symbol
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3365 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
3366 example:
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3367 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3368 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3369
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3370 1: struct intpairs[] =
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3371 2: @{
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3372 3: @{ 1, 2 @},
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3373 4: @{
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3374 5: 3,
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3375 6: 4
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3376 7: @}
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3377 8: @{ 1,
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3378 9: 2 @},
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3379 10: @{ 3, 4 @}
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3380 11: @}
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3381
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3382 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3383 @end example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3384
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3385 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
3386 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
3387 @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
3388 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
3389 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
3390 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
3391 line 10.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3392
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
3393 External language definition blocks also have their own syntactic
Dave Love <fx@gnu.org>
parents:
diff changeset
3394 symbols. In this example:
Dave Love <fx@gnu.org>
parents:
diff changeset
3395 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
3396 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
3397
Dave Love <fx@gnu.org>
parents:
diff changeset
3398 1: extern "C"
Dave Love <fx@gnu.org>
parents:
diff changeset
3399 2: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
3400 3: int thing_one( int );
Dave Love <fx@gnu.org>
parents:
diff changeset
3401 4: int thing_two( double );
Dave Love <fx@gnu.org>
parents:
diff changeset
3402 5: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
3403
Dave Love <fx@gnu.org>
parents:
diff changeset
3404 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
3405 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
3406
Dave Love <fx@gnu.org>
parents:
diff changeset
3407 @cindex extern-lang-open syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3408 @cindex extern-lang-close syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3409 @cindex inextern-lang syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3410 @cindex inclass syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3411 @noindent
Dave Love <fx@gnu.org>
parents:
diff changeset
3412 line 2 is given the @code{extern-lang-open} syntax, while line 5 is given
Dave Love <fx@gnu.org>
parents:
diff changeset
3413 the @code{extern-lang-close} syntax. The analysis for line 3 yields:
Dave Love <fx@gnu.org>
parents:
diff changeset
3414 @code{((inextern-lang) (topmost-intro . 14))}, where
Dave Love <fx@gnu.org>
parents:
diff changeset
3415 @code{inextern-lang} is a modifier similar in purpose to @code{inclass}.
Dave Love <fx@gnu.org>
parents:
diff changeset
3416
Dave Love <fx@gnu.org>
parents:
diff changeset
3417 Similarly, C++ namespace constructs have their own associated syntactic
Dave Love <fx@gnu.org>
parents:
diff changeset
3418 symbols. In this example:
Dave Love <fx@gnu.org>
parents:
diff changeset
3419 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
3420 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
3421
Dave Love <fx@gnu.org>
parents:
diff changeset
3422 1: namespace foo
Dave Love <fx@gnu.org>
parents:
diff changeset
3423 2: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
3424 3: void xxx() @{@}
Dave Love <fx@gnu.org>
parents:
diff changeset
3425 4: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
3426
Dave Love <fx@gnu.org>
parents:
diff changeset
3427 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
3428 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
3429
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3430 @cindex namespace-open syntactic symbol
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3431 @cindex namespace-close syntactic symbol
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3432 @cindex innamespace syntactic symbol
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
3433 @noindent
Dave Love <fx@gnu.org>
parents:
diff changeset
3434 line 2 is given the @code{namespace-open} syntax, while line 4 is given
Dave Love <fx@gnu.org>
parents:
diff changeset
3435 the @code{namespace-close} syntax. The analysis for line 3 yields:
Dave Love <fx@gnu.org>
parents:
diff changeset
3436 @code{((innamespace) (topmost-intro . 17))}, where @code{innamespace} is
Dave Love <fx@gnu.org>
parents:
diff changeset
3437 a modifier similar in purpose to @code{inextern-lang} and @code{inclass}.
Dave Love <fx@gnu.org>
parents:
diff changeset
3438
Dave Love <fx@gnu.org>
parents:
diff changeset
3439 A number of syntactic symbols are associated with parenthesis lists,
Dave Love <fx@gnu.org>
parents:
diff changeset
3440 a.k.a argument lists, as found in function declarations and function
Dave Love <fx@gnu.org>
parents:
diff changeset
3441 calls. This example illustrates these:
Dave Love <fx@gnu.org>
parents:
diff changeset
3442 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
3443 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
3444
Dave Love <fx@gnu.org>
parents:
diff changeset
3445 1: void a_function( int line1,
Dave Love <fx@gnu.org>
parents:
diff changeset
3446 2: int line2 );
Dave Love <fx@gnu.org>
parents:
diff changeset
3447 3:
Dave Love <fx@gnu.org>
parents:
diff changeset
3448 4: void a_longer_function(
Dave Love <fx@gnu.org>
parents:
diff changeset
3449 5: int line1,
Dave Love <fx@gnu.org>
parents:
diff changeset
3450 6: int line2
Dave Love <fx@gnu.org>
parents:
diff changeset
3451 7: );
Dave Love <fx@gnu.org>
parents:
diff changeset
3452 8:
Dave Love <fx@gnu.org>
parents:
diff changeset
3453 9: void call_them( int line1, int line2 )
Dave Love <fx@gnu.org>
parents:
diff changeset
3454 10: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
3455 11: a_function(
Dave Love <fx@gnu.org>
parents:
diff changeset
3456 12: line1,
Dave Love <fx@gnu.org>
parents:
diff changeset
3457 13: line2
Dave Love <fx@gnu.org>
parents:
diff changeset
3458 14: );
Dave Love <fx@gnu.org>
parents:
diff changeset
3459 15:
Dave Love <fx@gnu.org>
parents:
diff changeset
3460 16: a_longer_function( line1,
Dave Love <fx@gnu.org>
parents:
diff changeset
3461 17: line2 );
Dave Love <fx@gnu.org>
parents:
diff changeset
3462 18: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
3463
Dave Love <fx@gnu.org>
parents:
diff changeset
3464 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
3465 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
3466
Dave Love <fx@gnu.org>
parents:
diff changeset
3467 @cindex arglist-intro syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3468 @cindex arglist-close syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3469 Lines 5 and 12 are assigned @code{arglist-intro} syntax since they are
Dave Love <fx@gnu.org>
parents:
diff changeset
3470 the first line following the open parenthesis, and lines 7 and 14 are
Dave Love <fx@gnu.org>
parents:
diff changeset
3471 assigned @code{arglist-close} syntax since they contain the parenthesis
Dave Love <fx@gnu.org>
parents:
diff changeset
3472 that closes the argument list.
Dave Love <fx@gnu.org>
parents:
diff changeset
3473
Dave Love <fx@gnu.org>
parents:
diff changeset
3474 @cindex arglist-cont-nonempty syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3475 @cindex arglist-cont syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3476 Lines that continue argument lists can be assigned one of two syntactic
Dave Love <fx@gnu.org>
parents:
diff changeset
3477 symbols. For example, Lines 2 and 17
Dave Love <fx@gnu.org>
parents:
diff changeset
3478 are assigned @code{arglist-cont-nonempty} syntax. What this means
Dave Love <fx@gnu.org>
parents:
diff changeset
3479 is that they continue an argument list, but that the line containing the
Dave Love <fx@gnu.org>
parents:
diff changeset
3480 parenthesis that opens the list is @emph{not empty} following the open
Dave Love <fx@gnu.org>
parents:
diff changeset
3481 parenthesis. Contrast this against lines 6 and 13 which are assigned
Dave Love <fx@gnu.org>
parents:
diff changeset
3482 @code{arglist-cont} syntax. This is because the parenthesis that opens
Dave Love <fx@gnu.org>
parents:
diff changeset
3483 their argument lists is the last character on that line.
Dave Love <fx@gnu.org>
parents:
diff changeset
3484
Dave Love <fx@gnu.org>
parents:
diff changeset
3485 Note that there is no @code{arglist-open} syntax. This is because any
Dave Love <fx@gnu.org>
parents:
diff changeset
3486 parenthesis that opens an argument list, appearing on a separate line,
Dave Love <fx@gnu.org>
parents:
diff changeset
3487 is assigned the @code{statement-cont} syntax instead.
Dave Love <fx@gnu.org>
parents:
diff changeset
3488
Dave Love <fx@gnu.org>
parents:
diff changeset
3489 A few miscellaneous syntactic symbols that haven't been previously
Dave Love <fx@gnu.org>
parents:
diff changeset
3490 covered are illustrated by this C++ example:
Dave Love <fx@gnu.org>
parents:
diff changeset
3491 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
3492 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
3493
Dave Love <fx@gnu.org>
parents:
diff changeset
3494 1: void Bass::play( int volume )
Dave Love <fx@gnu.org>
parents:
diff changeset
3495 2: const
Dave Love <fx@gnu.org>
parents:
diff changeset
3496 3: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
3497 4: /* this line starts a multi-line
Dave Love <fx@gnu.org>
parents:
diff changeset
3498 5: * comment. This line should get `c' syntax */
Dave Love <fx@gnu.org>
parents:
diff changeset
3499 6:
Dave Love <fx@gnu.org>
parents:
diff changeset
3500 7: char* a_multiline_string = "This line starts a multi-line \
Dave Love <fx@gnu.org>
parents:
diff changeset
3501 8: string. This line should get `string' syntax.";
Dave Love <fx@gnu.org>
parents:
diff changeset
3502 9:
Dave Love <fx@gnu.org>
parents:
diff changeset
3503 10: note:
Dave Love <fx@gnu.org>
parents:
diff changeset
3504 11: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
3505 12: #ifdef LOCK
Dave Love <fx@gnu.org>
parents:
diff changeset
3506 13: Lock acquire();
Dave Love <fx@gnu.org>
parents:
diff changeset
3507 14: #endif // LOCK
Dave Love <fx@gnu.org>
parents:
diff changeset
3508 15: slap_pop();
Dave Love <fx@gnu.org>
parents:
diff changeset
3509 16: cout << "I played "
Dave Love <fx@gnu.org>
parents:
diff changeset
3510 17: << "a note\n";
Dave Love <fx@gnu.org>
parents:
diff changeset
3511 18: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
3512 19: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
3513
Dave Love <fx@gnu.org>
parents:
diff changeset
3514 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
3515 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
3516
Dave Love <fx@gnu.org>
parents:
diff changeset
3517 The lines to note in this example include:
Dave Love <fx@gnu.org>
parents:
diff changeset
3518
Dave Love <fx@gnu.org>
parents:
diff changeset
3519 @itemize @bullet
Dave Love <fx@gnu.org>
parents:
diff changeset
3520
Dave Love <fx@gnu.org>
parents:
diff changeset
3521 @cindex func-decl-cont syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3522 @item
30396
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
3523 Line 2 is assigned the @code{func-decl-cont} syntax.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
3524
Dave Love <fx@gnu.org>
parents:
diff changeset
3525 @cindex comment-intro syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3526 @item
30396
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
3527 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
3528 @code{comment-intro} syntax.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
3529
Dave Love <fx@gnu.org>
parents:
diff changeset
3530 @cindex c syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3531 @item
30396
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
3532 Line 5 is assigned @code{c} syntax.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
3533
Dave Love <fx@gnu.org>
parents:
diff changeset
3534 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
3535 @cindex syntactic whitespace
30396
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
3536 Line 6 which, even though it contains nothing but whitespace, is
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
3537 assigned @code{defun-block-intro}. Note that the appearance of the
Dave Love <fx@gnu.org>
parents:
diff changeset
3538 comment on lines 4 and 5 do not cause line 6 to be assigned
Dave Love <fx@gnu.org>
parents:
diff changeset
3539 @code{statement} syntax because comments are considered to be
Dave Love <fx@gnu.org>
parents:
diff changeset
3540 @dfn{syntactic whitespace}, which are ignored when analyzing
30396
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
3541 code.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
3542
Dave Love <fx@gnu.org>
parents:
diff changeset
3543 @cindex string syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3544 @item
30396
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
3545 Line 8 is assigned @code{string} syntax.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
3546
Dave Love <fx@gnu.org>
parents:
diff changeset
3547 @cindex label syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3548 @item
30396
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
3549 Line 10 is assigned @code{label} syntax.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
3550
Dave Love <fx@gnu.org>
parents:
diff changeset
3551 @cindex block-open syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3552 @item
30396
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
3553 Line 11 is assigned @code{block-open} syntax.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
3554
Dave Love <fx@gnu.org>
parents:
diff changeset
3555 @cindex cpp-macro syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3556 @cindex cpp-macro-cont syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3557 @item
30396
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
3558 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
3559 normal syntactic symbols (@code{statement-block-intro} and
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
3560 @code{statement}, respectively). Normally @code{cpp-macro} is
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
3561 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
3562 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
3563 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
3564 of the code.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
3565
Dave Love <fx@gnu.org>
parents:
diff changeset
3566 @cindex stream-op syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3567 @item
30396
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
3568 Line 17 is assigned @code{stream-op} syntax.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
3569
Dave Love <fx@gnu.org>
parents:
diff changeset
3570 @end itemize
Dave Love <fx@gnu.org>
parents:
diff changeset
3571
Dave Love <fx@gnu.org>
parents:
diff changeset
3572 @cindex multi-line macros
Dave Love <fx@gnu.org>
parents:
diff changeset
3573 @cindex syntactic whitespace
Dave Love <fx@gnu.org>
parents:
diff changeset
3574 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
3575 @ccmode{} now recognizes the fact that it is inside a multi-line macro,
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
3576 and it properly skips such macros as syntactic whitespace. In this
Dave Love <fx@gnu.org>
parents:
diff changeset
3577 example:
Dave Love <fx@gnu.org>
parents:
diff changeset
3578 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
3579 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
3580
Dave Love <fx@gnu.org>
parents:
diff changeset
3581 1: #define LIST_LOOP(cons, listp) \
Dave Love <fx@gnu.org>
parents:
diff changeset
3582 2: for (cons = listp; !NILP (cons); cons = XCDR (cons)) \
Dave Love <fx@gnu.org>
parents:
diff changeset
3583 3: if (!CONSP (cons)) \
Dave Love <fx@gnu.org>
parents:
diff changeset
3584 4: signal_error ("Invalid list format", listp); \
Dave Love <fx@gnu.org>
parents:
diff changeset
3585 5: else
Dave Love <fx@gnu.org>
parents:
diff changeset
3586
Dave Love <fx@gnu.org>
parents:
diff changeset
3587 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
3588 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
3589 @noindent
Dave Love <fx@gnu.org>
parents:
diff changeset
3590 line 1 is given the syntactic symbol @code{cpp-macro}. This first line
Dave Love <fx@gnu.org>
parents:
diff changeset
3591 of a macro is always given this symbol. The second and subsequent lines
Dave Love <fx@gnu.org>
parents:
diff changeset
3592 (e.g. lines 2 through 5) are given the @code{cpp-macro-cont} syntactic
Dave Love <fx@gnu.org>
parents:
diff changeset
3593 symbol, with a relative buffer position pointing to the @code{#} which
Dave Love <fx@gnu.org>
parents:
diff changeset
3594 starts the macro definition.
Dave Love <fx@gnu.org>
parents:
diff changeset
3595
Dave Love <fx@gnu.org>
parents:
diff changeset
3596 In Objective-C buffers, there are three additional syntactic symbols
Dave Love <fx@gnu.org>
parents:
diff changeset
3597 assigned to various message calling constructs. Here's an example
Dave Love <fx@gnu.org>
parents:
diff changeset
3598 illustrating these:
Dave Love <fx@gnu.org>
parents:
diff changeset
3599 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
3600 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
3601
Dave Love <fx@gnu.org>
parents:
diff changeset
3602 1: - (void)setDelegate:anObject
Dave Love <fx@gnu.org>
parents:
diff changeset
3603 2: withStuff:stuff
Dave Love <fx@gnu.org>
parents:
diff changeset
3604 3: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
3605 4: [delegate masterWillRebind:self
Dave Love <fx@gnu.org>
parents:
diff changeset
3606 5: toDelegate:anObject
Dave Love <fx@gnu.org>
parents:
diff changeset
3607 6: withExtraStuff:stuff];
Dave Love <fx@gnu.org>
parents:
diff changeset
3608 7: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
3609
Dave Love <fx@gnu.org>
parents:
diff changeset
3610 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
3611 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
3612
Dave Love <fx@gnu.org>
parents:
diff changeset
3613 @cindex objc-method-intro syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3614 @cindex objc-method-args-cont syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3615 @cindex objc-method-call-cont syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3616 Here, line 1 is assigned @code{objc-method-intro} syntax, and line 2 is
Dave Love <fx@gnu.org>
parents:
diff changeset
3617 assigned @code{objc-method-args-cont} syntax. Lines 5 and 6 are both
Dave Love <fx@gnu.org>
parents:
diff changeset
3618 assigned @code{objc-method-call-cont} syntax.
Dave Love <fx@gnu.org>
parents:
diff changeset
3619
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3620 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
3621 this:
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3622 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3623 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3624
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3625 1: public void watch(Observable o) @{
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3626 2: o.addObserver(new Observer() @{
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3627 3: public void update(Observable o, Object arg) @{
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3628 4: history.addElement(arg);
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3629 5: @}
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3630 6: @});
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3631 7: @}
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-class syntactic symbol
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3637 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
3638 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
3639 @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
3640 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
3641 @code{inexpr-class}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3642
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3643 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
3644 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
3645 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3646 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3647
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3648 1: int res = (@{
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3649 2: int y = foo (); int z;
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3650 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
3651 4: z;
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3652 5: @});
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3653
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3654 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3655 @end example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3656
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3657 @cindex inexpr-statement syntactic symbol
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3658 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
3659 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
3660 @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
3661 indentation.
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 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
3664 statements, as illustrated here:
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3665 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3666 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3667
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3668 1: array itgob()
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3669 2: @{
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3670 3: string s = map (backtrace()[-2][3..],
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3671 4: lambda
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3672 5: (mixed arg)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3673 6: @{
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3674 7: return sprintf ("%t", arg);
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3675 8: @}) * ", " + "\n";
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3676 9: return catch @{
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3677 10: write (s + "\n");
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3678 11: @};
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3679 12: @}
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3680
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3681 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3682 @end example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3683
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3684 @cindex inlambda syntactic symbol
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3685 @cindex lambda-intro-cont syntactic symbol
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3686 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
3687 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
3688 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
3689 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
3690 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
3691 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
3692 @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
3693 @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
3694 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
3695 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
3696 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
3697
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3698 @cindex inexpr-statement syntactic symbol
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3699 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
3700 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
3701 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
3702 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
3703 handled like this too.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3704
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
3705 @cindex knr-argdecl-intro syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3706 @cindex knr-argdecl syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3707 Two other syntactic symbols can appear in old style, non-prototyped C
Dave Love <fx@gnu.org>
parents:
diff changeset
3708 code @footnote{a.k.a. K&R C, or Kernighan & Ritchie C}:
Dave Love <fx@gnu.org>
parents:
diff changeset
3709 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
3710 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
3711
Dave Love <fx@gnu.org>
parents:
diff changeset
3712 1: int add_three_integers(a, b, c)
Dave Love <fx@gnu.org>
parents:
diff changeset
3713 2: int a;
Dave Love <fx@gnu.org>
parents:
diff changeset
3714 3: int b;
Dave Love <fx@gnu.org>
parents:
diff changeset
3715 4: int c;
Dave Love <fx@gnu.org>
parents:
diff changeset
3716 5: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
3717 6: return a + b + c;
Dave Love <fx@gnu.org>
parents:
diff changeset
3718 7: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
3719
Dave Love <fx@gnu.org>
parents:
diff changeset
3720 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
3721 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
3722
Dave Love <fx@gnu.org>
parents:
diff changeset
3723 Here, line 2 is the first line in an argument declaration list and so is
Dave Love <fx@gnu.org>
parents:
diff changeset
3724 given the @code{knr-argdecl-intro} syntactic symbol. Subsequent lines
Dave Love <fx@gnu.org>
parents:
diff changeset
3725 (i.e. lines 3 and 4 in this example), are given @code{knr-argdecl}
Dave Love <fx@gnu.org>
parents:
diff changeset
3726 syntax.
Dave Love <fx@gnu.org>
parents:
diff changeset
3727
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3728
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
3729 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3730 @node Indentation Functions, Performance Issues, Syntactic Symbols, Top
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3731 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3732 @chapter Indentation Functions
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3733 @cindex indentation functions
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3734 @cindex line-up functions
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3735 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3736
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3737 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
3738 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
3739 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
3740 for a syntactic symbol.
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 @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
3743 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
3744 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
3745 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
3746 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
3747
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3748 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
3749 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
3750
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3751 @macro workswith
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
3752 @emph{Works with:@ }
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3753 @end macro
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3754 @ifinfo
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3755 @unmacro workswith
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3756 @macro workswith
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3757 Works with:
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3758 @end macro
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3759 @end ifinfo
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3760
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3761 @table @code
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3762
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3763 @findex c-lineup-arglist
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3764 @findex lineup-arglist (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3765 @item c-lineup-arglist
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3766 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
3767
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3768 @workswith @code{arglist-cont-nonempty}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3769
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3770 @findex c-lineup-arglist-intro-after-paren
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3771 @findex lineup-arglist-intro-after-paren (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3772 @item c-lineup-arglist-intro-after-paren
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3773 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
3774 brace block.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3775
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3776 @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
3777 @code{statement-block-intro}, @code{statement-case-intro},
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3778 @code{arglist-intro}.
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 @findex c-lineup-arglist-close-under-paren
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3781 @findex lineup-arglist-close-under-paren (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3782 @item c-lineup-arglist-close-under-paren
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3783 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
3784 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
3785 under the parenthesis that opened the argument list.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3786
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3787 @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
3788 @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
3789 @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
3790 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
3791
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3792 @findex c-lineup-close-paren
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3793 @findex lineup-close-paren (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3794 @item c-lineup-close-paren
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3795 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
3796 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
3797 indentation is added. E.g:
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3798 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3799 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3800
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3801 main (int,
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3802 char **
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3803 ) // c-lineup-close-paren
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3804
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3805 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3806 @end example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3807 @noindent
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3808 and
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3809 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3810 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3811
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3812 main (
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3813 int, char **
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3814 ) // c-lineup-close-paren
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3815
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3816 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3817 @end example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3818
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3819 @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
3820 @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
3821 @code{extern-lang-close}, @code{namespace-close}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3822
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3823 @findex c-lineup-streamop
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3824 @findex lineup-streamop (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3825 @item c-lineup-streamop
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3826 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
3827
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3828 @workswith @code{stream-op}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3829
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3830 @findex c-lineup-multi-inher
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3831 @findex lineup-multi-inher (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3832 @item c-lineup-multi-inher
30396
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
3833 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
3834 initializers under each other. E.g:
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
3835 @example
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
3836 @group
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
3837
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
3838 Foo::Foo (int a, int b):
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
3839 Cyphr (a),
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
3840 Bar (b) // c-lineup-multi-inher
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
3841
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
3842 @end group
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
3843 @end example
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
3844 @noindent
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
3845 and
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
3846 @example
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
3847 @group
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
3848
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
3849 class Foo
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
3850 : public Cyphr,
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
3851 public Bar // c-lineup-multi-inher
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
3852
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
3853 @end group
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
3854 @end example
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
3855 @noindent
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
3856 and
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
3857 @example
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
3858 @group
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
3859
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
3860 Foo::Foo (int a, int b)
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
3861 : Cyphr (a)
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
3862 , Bar (b) // c-lineup-multi-inher
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
3863
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
3864 @end group
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
3865 @end example
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
3866
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
3867 @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
3868
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3869 @findex c-lineup-java-inher
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3870 @findex lineup-java-inher (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3871 @item c-lineup-java-inher
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3872 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
3873 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
3874 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
3875 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
3876 E.g:
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3877 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3878 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3879
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3880 class Foo
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3881 extends
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3882 Bar // c-lineup-java-inher
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3883
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3884 <--> c-basic-offset
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3885
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3886 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3887 @end example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3888 @noindent
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3889 and
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 class Foo
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3894 extends Cyphr,
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3895 Bar // c-lineup-java-inher
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 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3898 @end example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3899
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3900 @workswith @code{inher-cont}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3901
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3902 @findex c-lineup-java-throws
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3903 @findex lineup-java-throws (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3904 @item c-lineup-java-throws
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3905 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
3906 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
3907 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
3908 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
3909 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
3910 start if it doesn't hang. E.g:
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3911 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3912 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3913
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3914 int foo()
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3915 throws // c-lineup-java-throws
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3916 Bar // c-lineup-java-throws
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3917
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3918 <--><--> c-basic-offset
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3919
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3920 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3921 @end example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3922 @noindent
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3923 and
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3924 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3925 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3926
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3927 int foo() throws Cyphr,
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3928 Bar, // c-lineup-java-throws
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3929 Vlod // c-lineup-java-throws
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3930
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3931 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3932 @end example
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 @workswith @code{func-decl-cont}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3935
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3936 @findex c-indent-one-line-block
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3937 @findex indent-one-line-block (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3938 @item c-indent-one-line-block
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3939 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
3940 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3941 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3942
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3943 if (n > 0)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3944 @{m+=n; n=0;@} // c-indent-one-line-block
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3945
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3946 <--> c-basic-offset
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3947
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3948 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3949 @end example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3950 @noindent
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3951 and
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3952 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3953 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3954
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3955 if (n > 0)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3956 @{ // c-indent-one-line-block
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3957 m+=n; n=0;
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3958 @}
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3959
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
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3963 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
3964 @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
3965 which makes the function usable in list expressions.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3966
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3967 @workswith 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
3968 @code{-open} symbols.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3969
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3970 @findex c-indent-multi-line-block
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3971 @findex indent-multi-line-block (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3972 @item c-indent-multi-line-block
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3973 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
3974 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3975 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3976
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3977 int *foo[] = @{
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3978 NULL,
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3979 @{17@}, // c-indent-multi-line-block
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3980
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3981 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3982 @end example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3983 @noindent
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3984 and
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3985 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3986 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3987
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3988 int *foo[] = @{
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3989 NULL,
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3990 @{ // c-indent-multi-line-block
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3991 17
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3992 @},
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3993
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3994 <--> c-basic-offset
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 @end example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3998
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3999 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
4000 @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
4001 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
4002
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4003 @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
4004 @code{-open} symbols.
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 @findex c-lineup-C-comments
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4007 @findex lineup-C-comments (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4008 @item c-lineup-C-comments
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4009 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
4010 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
4011 @example
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 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4014 /* /** /*
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4015 * text * text text
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4016 */ */ */
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4017 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4018
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4019 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4020 /* text /* /**
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4021 text ** text ** text
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4022 */ */ */
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4023 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4024
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4025 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4026 /**************************************************
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4027 * text
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4028 *************************************************/
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4029 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4030
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4031 @vindex comment-start-skip
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4032 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4033 /**************************************************
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4034 Free form text comments:
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4035 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
4036 start, the indentation is kept unchanged for lines
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4037 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
4038 delimiter line is whatever matches the
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4039 @code{comment-start-skip} regexp.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4040 **************************************************/
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4041 @end group
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 @end example
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 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
4046 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
4047 line inside a comment.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4048
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4049 @workswith The @code{c} syntactic symbol.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4050
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4051 @findex c-lineup-comment
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4052 @findex lineup-comment (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4053 @item c-lineup-comment
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4054 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
4055 @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
4056 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
4057
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4058 @vindex c-comment-only-line-offset
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4059 @vindex comment-only-line-offset (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4060 @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
4061 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
4062 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4063
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4064 (@r{<non-anchored-offset>} . @r{<anchored-offset>})
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4065
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4066 @end example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4067
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4068 @noindent
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4069 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
4070 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
4071 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
4072 is equivalent to @code{(@r{<value>} . -1000)}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4073
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4074 @workswith @code{comment-intro}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4075
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4076 @findex c-lineup-runin-statements
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4077 @findex lineup-runin-statements (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4078 @item c-lineup-runin-statements
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4079 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
4080 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
4081 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
4082 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
4083 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4084 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4085
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4086 int main()
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4087 @{ puts (\"Hello world!\");
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4088 return 0; // c-lineup-runin-statements
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4089 @}
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4090
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4091 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4092 @end example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4093
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4094 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
4095 @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
4096 expressions.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4097
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4098 @workswith The @code{statement} syntactic symbol.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4099
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4100 @findex c-lineup-math
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4101 @findex lineup-math (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4102 @item c-lineup-math
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4103 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
4104 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
4105 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
4106 first one.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4107
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4108 @workswith @code{statement-cont}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4109
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4110 @findex c-lineup-template-args
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4111 @findex lineup-template-args (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4112 @item c-lineup-template-args
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4113 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
4114 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
4115 opening @samp{<}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4116
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4117 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
4118 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
4119
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4120 @workswith @code{template-args-cont}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4121
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4122 @findex c-lineup-ObjC-method-call
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4123 @findex lineup-ObjC-method-call (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4124 @item c-lineup-ObjC-method-call
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4125 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
4126 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
4127 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
4128 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
4129 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
4130 lineup the current line with it.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4131
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4132 @workswith @code{objc-method-call-cont}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4133
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4134 @findex c-lineup-ObjC-method-args
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4135 @findex lineup-ObjC-method-args (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4136 @item c-lineup-ObjC-method-args
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4137 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
4138 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
4139
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4140 @workswith @code{objc-method-args-cont}.
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-ObjC-method-args-2
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4143 @findex lineup-ObjC-method-args-2 (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4144 @item c-lineup-ObjC-method-args-2
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4145 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
4146 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
4147
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4148 @workswith @code{objc-method-args-cont}.
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 @findex c-lineup-inexpr-block
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4151 @findex lineup-inexpr-block (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4152 @item c-lineup-inexpr-block
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4153 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
4154 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
4155 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
4156 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
4157 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
4158 construct.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4159
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4160 @workswith @code{inlambda}, @code{inexpr-statement},
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4161 @code{inexpr-class}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4162
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4163 @findex c-lineup-whitesmith-in-block
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4164 @findex lineup-whitesmith-in-block (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4165 @item c-lineup-whitesmith-in-block
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4166 Line up lines inside a block in Whitesmith style. It's done in a way
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4167 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
4168 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4169 @group
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 something
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4172 @{
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4173 foo; // c-lineup-whitesmith-in-block
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4174 @}
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4175
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4176 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4177 @end example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4178 @noindent
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4179 and
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4180 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4181 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4182
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4183 something @{
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4184 foo; // c-lineup-whitesmith-in-block
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
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4187 <--> c-basic-offset
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4188
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4189 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4190 @end example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4191
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4192 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
4193 @code{c-basic-offset} is added.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4194
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4195 @workswith @code{defun-close}, @code{defun-block-intro},
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4196 @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
4197 @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
4198 @code{innamespace}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4199
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4200 @findex c-lineup-dont-change
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4201 @findex lineup-dont-change (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4202 @item c-lineup-dont-change
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4203 This lineup function makes the line stay at whatever indentation it
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4204 already has; think of it as an identity function for lineups. It is
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4205 used for @code{cpp-macro-cont} lines.
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4206
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4207 @workswith Any syntactic symbol.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4208
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4209 @end table
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4210
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4211
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4212 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4213 @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
4214 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4215 @chapter Performance Issues
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4216 @cindex performance issues
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4217 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
4218
Dave Love <fx@gnu.org>
parents:
diff changeset
4219 C and its derivative languages are highly complex creatures. Often,
Dave Love <fx@gnu.org>
parents:
diff changeset
4220 ambiguous code situations arise that require @ccmode{} to scan
Dave Love <fx@gnu.org>
parents:
diff changeset
4221 large portions of the buffer to determine syntactic context. Such
Dave Love <fx@gnu.org>
parents:
diff changeset
4222 pathological code@footnote{such as the output of @code{lex(1)}!}
Dave Love <fx@gnu.org>
parents:
diff changeset
4223 can cause @ccmode{} to perform fairly badly.
Dave Love <fx@gnu.org>
parents:
diff changeset
4224 This section identifies some of the coding styles to watch out for, and
Dave Love <fx@gnu.org>
parents:
diff changeset
4225 suggests some workarounds that you can use to improve performance.
Dave Love <fx@gnu.org>
parents:
diff changeset
4226
Dave Love <fx@gnu.org>
parents:
diff changeset
4227 Because @ccmode{} has to scan the buffer backwards from the current
Dave Love <fx@gnu.org>
parents:
diff changeset
4228 insertion point, and because C's syntax is fairly difficult to parse in
Dave Love <fx@gnu.org>
parents:
diff changeset
4229 the backwards direction, @ccmode{} often tries to find the nearest
Dave Love <fx@gnu.org>
parents:
diff changeset
4230 position higher up in the buffer from which to begin a forward scan.
Dave Love <fx@gnu.org>
parents:
diff changeset
4231 The farther this position is from the current insertion point, the
Dave Love <fx@gnu.org>
parents:
diff changeset
4232 slower the mode gets. Some coding styles can even force @ccmode{}
Dave Love <fx@gnu.org>
parents:
diff changeset
4233 to scan from the beginning of the buffer for every line of code!
Dave Love <fx@gnu.org>
parents:
diff changeset
4234
Dave Love <fx@gnu.org>
parents:
diff changeset
4235 @findex beginning-of-defun
Dave Love <fx@gnu.org>
parents:
diff changeset
4236 @findex defun-prompt-regexp
Dave Love <fx@gnu.org>
parents:
diff changeset
4237 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
4238 any brace that opens a top-level construct@footnote{E.g. a function in
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4239 C, or outermost class definition in C++ or Java.} always appears in the
Dave Love <fx@gnu.org>
parents:
diff changeset
4240 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
4241 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
4242 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
4243 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
4244 to something reasonable, however that ``something reasonable'' is
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4245 difficult to define, so @ccmode{} doesn't do it for you.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4246
Dave Love <fx@gnu.org>
parents:
diff changeset
4247 @vindex c-Java-defun-prompt-regexp
Dave Love <fx@gnu.org>
parents:
diff changeset
4248 @vindex Java-defun-prompt-regexp (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
4249 A special note about @code{defun-prompt-regexp} in Java mode: while much
Dave Love <fx@gnu.org>
parents:
diff changeset
4250 of the early sample Java code seems to encourage a style where the brace
Dave Love <fx@gnu.org>
parents:
diff changeset
4251 that opens a class is hung on the right side of the line, this is not a
Dave Love <fx@gnu.org>
parents:
diff changeset
4252 good style to pursue in Emacs. @ccmode{} comes with a variable
Dave Love <fx@gnu.org>
parents:
diff changeset
4253 @code{c-Java-defun-prompt-regexp} which tries to define a regular
Dave Love <fx@gnu.org>
parents:
diff changeset
4254 expression usable for this style, but there are problems with it. In
Dave Love <fx@gnu.org>
parents:
diff changeset
4255 some cases it can cause @code{beginning-of-defun} to hang@footnote{This
Dave Love <fx@gnu.org>
parents:
diff changeset
4256 has been observed in Emacs 19.34 and XEmacs 19.15.}. For this reason,
Dave Love <fx@gnu.org>
parents:
diff changeset
4257 it is not used by default, but if you feel adventurous, you can set
Dave Love <fx@gnu.org>
parents:
diff changeset
4258 @code{defun-prompt-regexp} to it in your mode hook. In any event,
Dave Love <fx@gnu.org>
parents:
diff changeset
4259 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
4260 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
4261 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
4262
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4263 @vindex c-enable-xemacs-performance-kludge-p
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4264 @vindex enable-xemacs-performance-kludge-p (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4265 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
4266 @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
4267 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
4268 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
4269 @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
4270 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
4271 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
4272 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
4273 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
4274 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
4275 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
4276 should be more common (and
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4277 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
4278 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
4279 this writing 27-Apr-1998).
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4280
Dave Love <fx@gnu.org>
parents:
diff changeset
4281 You will probably notice pathological behavior from @ccmode{} when
Dave Love <fx@gnu.org>
parents:
diff changeset
4282 working in files containing large amounts of C preprocessor macros.
Dave Love <fx@gnu.org>
parents:
diff changeset
4283 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
4284 as it can comments.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4285
Dave Love <fx@gnu.org>
parents:
diff changeset
4286 @vindex c-recognize-knr-p
Dave Love <fx@gnu.org>
parents:
diff changeset
4287 @vindex recognize-knr-p (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
4288 Previous versions of @ccmode{} had potential performance problems
Dave Love <fx@gnu.org>
parents:
diff changeset
4289 when recognizing K&R style function argument declarations. This was
Dave Love <fx@gnu.org>
parents:
diff changeset
4290 because there are ambiguities in the C syntax when K&R style argument
Dave Love <fx@gnu.org>
parents:
diff changeset
4291 lists are used@footnote{It is hard to distinguish them from top-level
Dave Love <fx@gnu.org>
parents:
diff changeset
4292 declarations.}. @ccmode{} has adopted BOCM's convention for
Dave Love <fx@gnu.org>
parents:
diff changeset
4293 limiting the search: it assumes that argdecls are indented at least one
Dave Love <fx@gnu.org>
parents:
diff changeset
4294 space, and that the function headers are not indented at all. With
Dave Love <fx@gnu.org>
parents:
diff changeset
4295 current versions of @ccmode{}, user customization of
Dave Love <fx@gnu.org>
parents:
diff changeset
4296 @code{c-recognize-knr-p} is deprecated. Just don't put argdecls in
Dave Love <fx@gnu.org>
parents:
diff changeset
4297 column zero!
Dave Love <fx@gnu.org>
parents:
diff changeset
4298
Dave Love <fx@gnu.org>
parents:
diff changeset
4299 @cindex @file{cc-lobotomy.el} file
Dave Love <fx@gnu.org>
parents:
diff changeset
4300 @vindex cc-lobotomy-pith-list
Dave Love <fx@gnu.org>
parents:
diff changeset
4301 You might want to investigate the speed-ups contained in the
Dave Love <fx@gnu.org>
parents:
diff changeset
4302 file @file{cc-lobotomy.el}, which comes as part of the @ccmode{}
Dave Love <fx@gnu.org>
parents:
diff changeset
4303 distribution, but is completely unsupported.
Dave Love <fx@gnu.org>
parents:
diff changeset
4304 As mentioned previous, @ccmode{} always trades speed for accuracy,
Dave Love <fx@gnu.org>
parents:
diff changeset
4305 however it is recognized that sometimes you need speed and can sacrifice
Dave Love <fx@gnu.org>
parents:
diff changeset
4306 some accuracy in indentation. The file @file{cc-lobotomy.el} contains
Dave Love <fx@gnu.org>
parents:
diff changeset
4307 hacks that will ``dumb down'' @ccmode{} in some specific ways, making
Dave Love <fx@gnu.org>
parents:
diff changeset
4308 that trade-off of accurancy for speed. I won't go into details of its
Dave Love <fx@gnu.org>
parents:
diff changeset
4309 use here; you should read the comments at the top of the file, and look
Dave Love <fx@gnu.org>
parents:
diff changeset
4310 at the variable @code{cc-lobotomy-pith-list} for details.
Dave Love <fx@gnu.org>
parents:
diff changeset
4311
Dave Love <fx@gnu.org>
parents:
diff changeset
4312
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4313 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4314 @node Limitations and Known Bugs, Frequently Asked Questions, Performance Issues, Top
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4315 @comment node-name, next, previous, up
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4316 @chapter Limitations and Known Bugs
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4317 @cindex limitations
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4318 @cindex bugs
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4319 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4320
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4321 @itemize @bullet
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4322 @item
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4323 Re-indenting large regions or expressions can be slow.
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4324
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4325 @findex c-indent-exp
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4326 @findex indent-exp (c-)
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4327 @item
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4328 @code{c-indent-exp} has not been fully optimized. It essentially
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4329 equivalent to hitting @kbd{TAB} (@code{c-indent-command}) on every
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4330 line. Some information is cached from line to line, but such caching
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4331 invariable causes inaccuracies in analysis in some bizarre situations.
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4332
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4333 @vindex signal-error-on-buffer-boundary
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4334 @item
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4335 XEmacs versions from 19.15 until (as of this writing 12-Mar-1998) 20.4
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4336 contain a variable called @code{signal-error-on-buffer-boundary}. This
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4337 was intended as a solution to user interface problems associated with
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4338 buffer movement and the @code{zmacs-region} deactivation on errors.
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4339 However, setting this variable to a non-default value had the
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4340 deleterious side effect of breaking many built-in primitive functions.
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4341 Most users will not be affected since they never change the value of
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4342 this variable. @strong{Do not set this variable to @code{nil}}; you
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4343 will cause serious problems in @ccmode{} and probably other XEmacs
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4344 packages! As of at least XEmacs 20.4, the effects this variable tried
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4345 to correct have been fixed in other, better ways.
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4346
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4347 @end itemize
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4348
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4349
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4350 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4351 @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
4352 @comment node-name, next, previous, up
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4353 @appendix Frequently Asked Questions
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4354 @cindex frequently asked questions
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4355 @cindex FAQ
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4356 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
4357
Dave Love <fx@gnu.org>
parents:
diff changeset
4358 @kindex C-x h
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4359 @kindex C-M-\
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4360 @kindex C-M-x
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4361 @kindex C-M-q
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4362 @kindex C-M-u
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4363 @kindex RET
Dave Love <fx@gnu.org>
parents:
diff changeset
4364 @kindex C-j
Dave Love <fx@gnu.org>
parents:
diff changeset
4365 @quotation
Dave Love <fx@gnu.org>
parents:
diff changeset
4366
Dave Love <fx@gnu.org>
parents:
diff changeset
4367 @strong{Q.} @emph{How do I re-indent the whole file?}
Dave Love <fx@gnu.org>
parents:
diff changeset
4368
Dave Love <fx@gnu.org>
parents:
diff changeset
4369 @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
4370 buffer. Then hit @kbd{C-M-\}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4371
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4372 @sp 1
Dave Love <fx@gnu.org>
parents:
diff changeset
4373 @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
4374 @kbd{C-M-x} doesn't work.}
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4375
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4376 @strong{A.} @kbd{C-M-x} is reserved for future Emacs use.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4377 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
4378
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4379 @sp 1
Dave Love <fx@gnu.org>
parents:
diff changeset
4380 @strong{Q.} @emph{How do I re-indent the current block?}
Dave Love <fx@gnu.org>
parents:
diff changeset
4381
Dave Love <fx@gnu.org>
parents:
diff changeset
4382 @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
4383 @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
4384 @kbd{C-M-q}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4385
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4386 @sp 1
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4387 @strong{Q.} @emph{Why doesn't the @kbd{RET} key indent the new line?}
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4388
Dave Love <fx@gnu.org>
parents:
diff changeset
4389 @strong{A.} Emacs' convention is that @kbd{RET} just adds a newline,
Dave Love <fx@gnu.org>
parents:
diff changeset
4390 and that @kbd{C-j} adds a newline and indents it. You can make
Dave Love <fx@gnu.org>
parents:
diff changeset
4391 @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
4392 @code{c-mode-common-hook}:
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4393 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
4394
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4395 (define-key c-mode-base-map "\C-m" 'c-context-line-break)
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4396
Dave Love <fx@gnu.org>
parents:
diff changeset
4397 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
4398
Dave Love <fx@gnu.org>
parents:
diff changeset
4399 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
4400 behavior, don't lobby me, lobby RMS! @t{:-)}
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4401
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4402 @sp 1
Dave Love <fx@gnu.org>
parents:
diff changeset
4403 @strong{Q.} @emph{I put @code{(c-set-offset 'substatement-open 0)}
Dave Love <fx@gnu.org>
parents:
diff changeset
4404 in my @file{.emacs} file but I get an error saying that
Dave Love <fx@gnu.org>
parents:
diff changeset
4405 @code{c-set-offset}'s function definition is void.}
Dave Love <fx@gnu.org>
parents:
diff changeset
4406
Dave Love <fx@gnu.org>
parents:
diff changeset
4407 @strong{A.} This means that @ccmode{} wasn't loaded into your
Dave Love <fx@gnu.org>
parents:
diff changeset
4408 Emacs session by the time the @code{c-set-offset} call was reached,
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4409 most likely because @ccmode{} is being autoloaded. Instead
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4410 of putting the @code{c-set-offset} line in your top-level
Dave Love <fx@gnu.org>
parents:
diff changeset
4411 @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
4412 simply modify @code{c-offsets-alist} directly:
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4413 @example
30396
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
4414
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
4415 (setq c-offsets-alist '((substatement-open . 0)))
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
4416
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4417 @end example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4418
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4419 @sp 1
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4420 @strong{Q.} @emph{How do I make strings, comments, keywords, and other
Dave Love <fx@gnu.org>
parents:
diff changeset
4421 constructs appear in different colors, or in bold face, etc.?}
Dave Love <fx@gnu.org>
parents:
diff changeset
4422
Dave Love <fx@gnu.org>
parents:
diff changeset
4423 @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
4424 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
4425 font-lock definitions for any of its supported languages.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4426
Dave Love <fx@gnu.org>
parents:
diff changeset
4427 @sp 1
Dave Love <fx@gnu.org>
parents:
diff changeset
4428 @strong{Q.} @emph{@kbd{M-a} and @kbd{M-e} used to move over entire
Dave Love <fx@gnu.org>
parents:
diff changeset
4429 balanced brace lists, but now they move into blocks. How do I get the
Dave Love <fx@gnu.org>
parents:
diff changeset
4430 old behavior back?}
Dave Love <fx@gnu.org>
parents:
diff changeset
4431
Dave Love <fx@gnu.org>
parents:
diff changeset
4432 @strong{A.} Use @kbd{C-M-f} and @kbd{C-M-b} to move over balanced brace
Dave Love <fx@gnu.org>
parents:
diff changeset
4433 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
4434 also move into blocks.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4435
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4436 @sp 1
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4437 @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
4438 ``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
4439 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
4440 gives?}
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 @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
4443 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
4444 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
4445 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
4446 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
4447 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
4448 @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
4449 in the @file{README} file.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4450
Dave Love <fx@gnu.org>
parents:
diff changeset
4451 @end quotation
Dave Love <fx@gnu.org>
parents:
diff changeset
4452
Dave Love <fx@gnu.org>
parents:
diff changeset
4453
Dave Love <fx@gnu.org>
parents:
diff changeset
4454 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4455 @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
4456 @comment node-name, next, previous, up
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4457 @appendix Getting the Latest CC Mode Release
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4458 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
4459
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4460 @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
4461 XEmacs since 19.16.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4462
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4463 Due to release schedule skew, it is likely that all of these Emacsen
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4464 have old versions of @ccmode{} and so should be upgraded. Access to the
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4465 @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
4466 compatibility, etc. are all available via the Web at:
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4467
Dave Love <fx@gnu.org>
parents:
diff changeset
4468 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
4469 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
4470
30396
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
4471 @uref{http://cc-mode.sourceforge.net/}
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4472
Dave Love <fx@gnu.org>
parents:
diff changeset
4473 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
4474 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
4475
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4476 @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
4477
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4478 There are many files under these directories; you can pick up the entire
Dave Love <fx@gnu.org>
parents:
diff changeset
4479 distribution (named @code{cc-mode.tar.gz}; a gzip'd tar file), or any of
Dave Love <fx@gnu.org>
parents:
diff changeset
4480 the individual files, including PostScript documentation.
Dave Love <fx@gnu.org>
parents:
diff changeset
4481
Dave Love <fx@gnu.org>
parents:
diff changeset
4482
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4483 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4484 @node Mailing Lists and Submitting Bug Reports, Sample .emacs File, Getting the Latest CC Mode Release, Top
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4485 @comment node-name, next, previous, up
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4486 @appendix Mailing Lists and Submitting Bug Reports
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4487 @cindex mailing lists
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4488 @cindex reporting bugs
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4489 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4490
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4491 @kindex C-c C-b
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4492 @findex c-submit-bug-report
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4493 @findex submit-bug-report (c-)
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4494 To report bugs, use the @kbd{C-c C-b} (@code{c-submit-bug-report})
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4495 command. This provides vital information we need to reproduce your
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4496 problem. Make sure you include a concise, but complete code example.
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4497 Please try to boil your example down to just the essential code needed
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4498 to reproduce the problem, and include an exact recipe of steps needed to
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4499 expose the bug. Be especially sure to include any code that appears
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4500 @emph{before} your bug example, if you think it might affect our ability
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4501 to reproduce it.
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4502
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4503 Please try to produce the problem in an Emacs instance without any
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4504 customizations loaded (i.e. start it with the @code{-q -no-site-file}
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4505 arguments). If it works correctly there, the problem might be caused by
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4506 faulty customizations in either your own or your site configuration. In
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4507 that case, we'd appreciate if you isolate the Emacs Lisp code that trigs
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4508 the bug and include it in your report.
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4509
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4510 @cindex bug report mailing list
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4511 Bug reports are now sent to the following email addresses:
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4512 @email{bug-cc-mode@@gnu.org} and @email{bug-gnu-emacs@@gnu.org}; the
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4513 latter is mirrored on the Usenet newsgroup @code{gnu.emacs.bug}. You
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4514 can send other questions and suggestions (kudos? @t{;-)} to
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4515 @email{bug-cc-mode@@gnu.org}.
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4516
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4517 @cindex announcement mailing list
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4518 If you want to get announcements of new @ccmode{} releases, send the
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4519 word @emph{subscribe} in the body of a message to
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4520 @email{cc-mode-announce-request@@lists.sourceforge.net}. Announcements
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4521 will also be posted to the Usenet newsgroups @code{gnu.emacs.sources},
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4522 @code{comp.emacs} and @code{comp.emacs.xemacs}.
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4523
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4524
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4525 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4526 @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
4527 @comment node-name, next, previous, up
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4528 @appendix Sample .emacs file
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4529 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
4530
Dave Love <fx@gnu.org>
parents:
diff changeset
4531 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
4532 ;; Here's a sample .emacs file that might help you along the way. Just
Dave Love <fx@gnu.org>
parents:
diff changeset
4533 ;; copy this region and paste it into your .emacs file. You may want to
Dave Love <fx@gnu.org>
parents:
diff changeset
4534 ;; change some of the actual values.
Dave Love <fx@gnu.org>
parents:
diff changeset
4535
Dave Love <fx@gnu.org>
parents:
diff changeset
4536 (defconst my-c-style
Dave Love <fx@gnu.org>
parents:
diff changeset
4537 '((c-tab-always-indent . t)
Dave Love <fx@gnu.org>
parents:
diff changeset
4538 (c-comment-only-line-offset . 4)
Dave Love <fx@gnu.org>
parents:
diff changeset
4539 (c-hanging-braces-alist . ((substatement-open after)
Dave Love <fx@gnu.org>
parents:
diff changeset
4540 (brace-list-open)))
Dave Love <fx@gnu.org>
parents:
diff changeset
4541 (c-hanging-colons-alist . ((member-init-intro before)
Dave Love <fx@gnu.org>
parents:
diff changeset
4542 (inher-intro)
Dave Love <fx@gnu.org>
parents:
diff changeset
4543 (case-label after)
Dave Love <fx@gnu.org>
parents:
diff changeset
4544 (label after)
Dave Love <fx@gnu.org>
parents:
diff changeset
4545 (access-label after)))
Dave Love <fx@gnu.org>
parents:
diff changeset
4546 (c-cleanup-list . (scope-operator
Dave Love <fx@gnu.org>
parents:
diff changeset
4547 empty-defun-braces
Dave Love <fx@gnu.org>
parents:
diff changeset
4548 defun-close-semi))
Dave Love <fx@gnu.org>
parents:
diff changeset
4549 (c-offsets-alist . ((arglist-close . c-lineup-arglist)
Dave Love <fx@gnu.org>
parents:
diff changeset
4550 (substatement-open . 0)
Dave Love <fx@gnu.org>
parents:
diff changeset
4551 (case-label . 4)
Dave Love <fx@gnu.org>
parents:
diff changeset
4552 (block-open . 0)
Dave Love <fx@gnu.org>
parents:
diff changeset
4553 (knr-argdecl-intro . -)))
Dave Love <fx@gnu.org>
parents:
diff changeset
4554 (c-echo-syntactic-information-p . t)
Dave Love <fx@gnu.org>
parents:
diff changeset
4555 )
Dave Love <fx@gnu.org>
parents:
diff changeset
4556 "My C Programming Style")
Dave Love <fx@gnu.org>
parents:
diff changeset
4557
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4558 ;; offset customizations not in my-c-style
30396
460a86ced57c @setfilename to ../info/ccmode.
Gerd Moellmann <gerd@gnu.org>
parents: 30044
diff changeset
4559 (setq c-offsets-alist '((member-init-intro . ++)))
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4560
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4561 ;; Customizations for all modes in CC Mode.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4562 (defun my-c-mode-common-hook ()
Dave Love <fx@gnu.org>
parents:
diff changeset
4563 ;; add my personal style and set it for the current buffer
Dave Love <fx@gnu.org>
parents:
diff changeset
4564 (c-add-style "PERSONAL" my-c-style t)
Dave Love <fx@gnu.org>
parents:
diff changeset
4565 ;; other customizations
Dave Love <fx@gnu.org>
parents:
diff changeset
4566 (setq tab-width 8
Dave Love <fx@gnu.org>
parents:
diff changeset
4567 ;; this will make sure spaces are used instead of tabs
Dave Love <fx@gnu.org>
parents:
diff changeset
4568 indent-tabs-mode nil)
Dave Love <fx@gnu.org>
parents:
diff changeset
4569 ;; we like auto-newline and hungry-delete
Dave Love <fx@gnu.org>
parents:
diff changeset
4570 (c-toggle-auto-hungry-state 1)
39267
a8c0a02f6129 Spelling corrections.
Richard M. Stallman <rms@gnu.org>
parents: 36924
diff changeset
4571 ;; key bindings for all supported languages. We can put these in
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4572 ;; 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
4573 ;; 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
4574 (define-key c-mode-base-map "\C-m" 'c-context-line-break)
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4575 )
Dave Love <fx@gnu.org>
parents:
diff changeset
4576
Dave Love <fx@gnu.org>
parents:
diff changeset
4577 (add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
Dave Love <fx@gnu.org>
parents:
diff changeset
4578 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
4579
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4580
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4581 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4582 @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
4583 @comment node-name, next, previous, up
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4584 @unnumbered Concept Index
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4585 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4586
Dave Love <fx@gnu.org>
parents:
diff changeset
4587 @printindex cp
Dave Love <fx@gnu.org>
parents:
diff changeset
4588
Dave Love <fx@gnu.org>
parents:
diff changeset
4589
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4590 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4591 @node Command Index, Key Index, Concept Index, Top
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4592 @comment node-name, next, previous, up
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4593 @unnumbered Command Index
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4594 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4595
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4596 Since most @ccmode{} commands are prepended with the string
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4597 @samp{c-}, each appears under its @code{c-@var{<thing>}} name and its
Dave Love <fx@gnu.org>
parents:
diff changeset
4598 @code{@var{<thing>} (c-)} name.
Dave Love <fx@gnu.org>
parents:
diff changeset
4599 @iftex
Dave Love <fx@gnu.org>
parents:
diff changeset
4600 @sp 2
Dave Love <fx@gnu.org>
parents:
diff changeset
4601 @end iftex
Dave Love <fx@gnu.org>
parents:
diff changeset
4602 @printindex fn
Dave Love <fx@gnu.org>
parents:
diff changeset
4603
Dave Love <fx@gnu.org>
parents:
diff changeset
4604
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4605 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4606 @node Key Index, Variable Index, Command Index, Top
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4607 @comment node-name, next, previous, up
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4608 @unnumbered Key Index
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4609 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4610
Dave Love <fx@gnu.org>
parents:
diff changeset
4611 @printindex ky
Dave Love <fx@gnu.org>
parents:
diff changeset
4612
Dave Love <fx@gnu.org>
parents:
diff changeset
4613
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4614 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4615 @node Variable Index, , Key Index, Top
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4616 @comment node-name, next, previous, up
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4617 @unnumbered Variable Index
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4618 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4619
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4620 Since most @ccmode{} variables are prepended with the string
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4621 @samp{c-}, each appears under its @code{c-@var{<thing>}} name and its
Dave Love <fx@gnu.org>
parents:
diff changeset
4622 @code{@var{<thing>} (c-)} name.
Dave Love <fx@gnu.org>
parents:
diff changeset
4623 @iftex
Dave Love <fx@gnu.org>
parents:
diff changeset
4624 @sp 2
Dave Love <fx@gnu.org>
parents:
diff changeset
4625 @end iftex
Dave Love <fx@gnu.org>
parents:
diff changeset
4626 @printindex vr
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4627
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4628 @iftex
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4629 @page
Dave Love <fx@gnu.org>
parents:
diff changeset
4630 @summarycontents
Dave Love <fx@gnu.org>
parents:
diff changeset
4631 @contents
36923
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4632 @end iftex
5be175601511 Version from CC mode 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 36341
diff changeset
4633
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4634 @bye