annotate man/cc-mode.texi @ 30044:f28b2213c12b

Remove duplicate @direntry.
author Gerd Moellmann <gerd@gnu.org>
date Wed, 05 Jul 2000 11:41:57 +0000
parents 95bdbefcdac6
children 460a86ced57c
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
26903
02eb743f6ab3 Set file name to ../info/ccmode, to avoid problems
Gerd Moellmann <gerd@gnu.org>
parents: 26819
diff changeset
10 @setfilename ../info/ccmode
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
11 @settitle CC Mode Version 5 Documentation
30009
95bdbefcdac6 Use dircategory `Emacs'.
Gerd Moellmann <gerd@gnu.org>
parents: 28823
diff changeset
12 @dircategory Emacs
95bdbefcdac6 Use dircategory `Emacs'.
Gerd Moellmann <gerd@gnu.org>
parents: 28823
diff changeset
13 @direntry
95bdbefcdac6 Use dircategory `Emacs'.
Gerd Moellmann <gerd@gnu.org>
parents: 28823
diff changeset
14 * CC Mode: (cc-mode). Emacs mode for editing C, C++, Objective-C,
95bdbefcdac6 Use dircategory `Emacs'.
Gerd Moellmann <gerd@gnu.org>
parents: 28823
diff changeset
15 Java, Pike, and IDL code.
28823
72c6f8275e0b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents: 28127
diff changeset
16 @end direntry
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
17 @footnotestyle end
Dave Love <fx@gnu.org>
parents:
diff changeset
18
Dave Love <fx@gnu.org>
parents:
diff changeset
19 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
20 @comment @setchapternewpage odd !! we don't want blank pages !!
Dave Love <fx@gnu.org>
parents:
diff changeset
21 @comment %**end of header (This is for running Texinfo on a region)
Dave Love <fx@gnu.org>
parents:
diff changeset
22 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
23
Dave Love <fx@gnu.org>
parents:
diff changeset
24
Dave Love <fx@gnu.org>
parents:
diff changeset
25 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
26 @comment
Dave Love <fx@gnu.org>
parents:
diff changeset
27 @comment Texinfo manual for CC Mode
Dave Love <fx@gnu.org>
parents:
diff changeset
28 @comment Generated from the original README file by Krishna Padmasola
Dave Love <fx@gnu.org>
parents:
diff changeset
29 @comment <krishna@earth-gw.njit.edu>
Dave Love <fx@gnu.org>
parents:
diff changeset
30 @comment
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
31 @comment Maintained by Barry A. Warsaw and Martin Stjernholm
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
32 @comment <bug-cc-mode@gnu.org> (or <cc-mode-help@python.org>)
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
33 @comment
Dave Love <fx@gnu.org>
parents:
diff changeset
34 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
35
Dave Love <fx@gnu.org>
parents:
diff changeset
36
Dave Love <fx@gnu.org>
parents:
diff changeset
37 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
38 @comment The following line inserts the copyright notice
Dave Love <fx@gnu.org>
parents:
diff changeset
39 @comment into the Info file.
Dave Love <fx@gnu.org>
parents:
diff changeset
40 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
41
Dave Love <fx@gnu.org>
parents:
diff changeset
42 @ifinfo
28127
ce57565effde Fix copyright lines.
Dave Love <fx@gnu.org>
parents: 26903
diff changeset
43 Copyright @copyright{} 1995,1996,1997,1998,1999 Free Software Foundation, Inc.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
44 @end ifinfo
Dave Love <fx@gnu.org>
parents:
diff changeset
45
Dave Love <fx@gnu.org>
parents:
diff changeset
46 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
47 @comment !!!The titlepage section does not appear in the Info file.!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
48 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
49
Dave Love <fx@gnu.org>
parents:
diff changeset
50 @titlepage
Dave Love <fx@gnu.org>
parents:
diff changeset
51 @sp 10
Dave Love <fx@gnu.org>
parents:
diff changeset
52
Dave Love <fx@gnu.org>
parents:
diff changeset
53
Dave Love <fx@gnu.org>
parents:
diff changeset
54 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
55 @comment The title is printed in a large font.
Dave Love <fx@gnu.org>
parents:
diff changeset
56 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
57
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
58 @center @titlefont{CC Mode 5.26}
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
59 @sp 2
Dave Love <fx@gnu.org>
parents:
diff changeset
60 @center @subtitlefont{A GNU Emacs mode for editing C and C-like languages}
Dave Love <fx@gnu.org>
parents:
diff changeset
61 @sp 2
Dave Love <fx@gnu.org>
parents:
diff changeset
62 @center Barry A. Warsaw
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
63 @center Martin Stjernholm
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
64
Dave Love <fx@gnu.org>
parents:
diff changeset
65
Dave Love <fx@gnu.org>
parents:
diff changeset
66 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
67 @comment The following two commands start the copyright page
Dave Love <fx@gnu.org>
parents:
diff changeset
68 @comment for the printed manual. This will not appear in the Info file.
Dave Love <fx@gnu.org>
parents:
diff changeset
69 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
70
Dave Love <fx@gnu.org>
parents:
diff changeset
71 @page
Dave Love <fx@gnu.org>
parents:
diff changeset
72 @vskip 0pt plus 1filll
28127
ce57565effde Fix copyright lines.
Dave Love <fx@gnu.org>
parents: 26903
diff changeset
73 Copyright @copyright{} 1995,1996,1997,1998,1999 Free Software Foundation, Inc.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
74 @end titlepage
Dave Love <fx@gnu.org>
parents:
diff changeset
75
Dave Love <fx@gnu.org>
parents:
diff changeset
76
Dave Love <fx@gnu.org>
parents:
diff changeset
77 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
78 @comment The Top node contains the master menu for the Info file.
Dave Love <fx@gnu.org>
parents:
diff changeset
79 @comment This appears only in the Info file, not the printed manual.
Dave Love <fx@gnu.org>
parents:
diff changeset
80 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
81
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
82 @node Top, Introduction, (dir), (dir)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
83 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
84
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
85 @macro ccmode
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
86 CC Mode
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
87 @end macro
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
88
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
89 @ifinfo
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
90 @top @ccmode{}
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
91
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
92 @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
93 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
94 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
95 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
96 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
97 @end ifinfo
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
98
Dave Love <fx@gnu.org>
parents:
diff changeset
99 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
100 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
101
Dave Love <fx@gnu.org>
parents:
diff changeset
102 @menu
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
103 * Introduction::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
104 * Getting Connected::
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
105 * New Indentation Engine::
Dave Love <fx@gnu.org>
parents:
diff changeset
106 * Minor Modes::
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
107 * Text Filling and Line Breaking::
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
108 * Commands::
Dave Love <fx@gnu.org>
parents:
diff changeset
109 * Customizing Indentation::
Dave Love <fx@gnu.org>
parents:
diff changeset
110 * Syntactic Symbols::
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
111 * Indentation Functions::
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
112 * Performance Issues::
Dave Love <fx@gnu.org>
parents:
diff changeset
113 * Frequently Asked Questions::
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
114 * Getting the Latest CC Mode Release::
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
115 * Sample .emacs File::
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
116 * Limitations and Known Bugs::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
117 * Mailing Lists and Submitting Bug Reports::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
118
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
119 --- Indices ---
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 * Concept Index::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
122 * Command Index::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
123 * Key Index::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
124 * Variable Index::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
125
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
126 --- The Detailed Node Listing ---
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
127
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
128 New Indentation Engine
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
129
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
130 * Syntactic Analysis::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
131 * Indentation Calculation::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
132
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
133 Minor Modes
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
134
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
135 * Auto-newline Insertion::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
136 * Hungry-deletion of Whitespace::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
137
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
138 Auto-newline Insertion
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
139
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
140 * Hanging Braces::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
141 * Hanging Colons::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
142 * Hanging Semi-colons and Commas::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
143 * Other Electric Commands::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
144 * Clean-ups::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
145
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
146 Commands
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
147
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
148 * Indentation Commands::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
149 * Movement Commands::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
150 * Other Commands::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
151
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
152 Customizing Indentation
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
153
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
154 * Interactive Customization::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
155 * Permanent Customization::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
156 * Hooks::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
157 * Styles::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
158 * Advanced Customizations::
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 Styles
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 * Built-in Styles::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
163 * Adding Styles::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
164 * File Styles::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
165
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
166 Advanced Customizations
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
167
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
168 * Custom Indentation Functions::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
169 * Custom Brace and Colon Hanging::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
170 * Customizing Semi-colons and Commas::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
171 * Other Special Indentations::
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
172 @end menu
Dave Love <fx@gnu.org>
parents:
diff changeset
173
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
174
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
175 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
176 @node Introduction, Getting Connected, Top, Top
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
177 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
178 @chapter Introduction
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
179 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
180
Dave Love <fx@gnu.org>
parents:
diff changeset
181 @cindex BOCM
Dave Love <fx@gnu.org>
parents:
diff changeset
182
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
183 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
184 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
185 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
186 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
187 been maintaining since 1992. @ccmode{} represents a significant
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
188 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
189 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
190 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
191 joined the @ccmode{} Maintainers Team, and implemented the Pike support.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
192
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
193 This manual describes @ccmode{}
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
194 @comment The following line must appear on its own, so that the automated
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
195 version 5.26.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
196 @comment Release.py script can update the version number automatically
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
197
Dave Love <fx@gnu.org>
parents:
diff changeset
198 @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
199 @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
200 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
201 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
202 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
203 @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
204 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
205 @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
206 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
207 modes. Font-locking is handled by other Emacs packages.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
208
Dave Love <fx@gnu.org>
parents:
diff changeset
209 This manual will describe the following:
Dave Love <fx@gnu.org>
parents:
diff changeset
210
Dave Love <fx@gnu.org>
parents:
diff changeset
211 @itemize @bullet
Dave Love <fx@gnu.org>
parents:
diff changeset
212 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
213 How to get started using @ccmode{}.
Dave Love <fx@gnu.org>
parents:
diff changeset
214
Dave Love <fx@gnu.org>
parents:
diff changeset
215 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
216 How the new indentation engine works.
Dave Love <fx@gnu.org>
parents:
diff changeset
217
Dave Love <fx@gnu.org>
parents:
diff changeset
218 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
219 How to customize the new indentation engine.
Dave Love <fx@gnu.org>
parents:
diff changeset
220
Dave Love <fx@gnu.org>
parents:
diff changeset
221 @end itemize
Dave Love <fx@gnu.org>
parents:
diff changeset
222
Dave Love <fx@gnu.org>
parents:
diff changeset
223 @findex c-mode
Dave Love <fx@gnu.org>
parents:
diff changeset
224 @findex c++-mode
Dave Love <fx@gnu.org>
parents:
diff changeset
225 @findex objc-mode
Dave Love <fx@gnu.org>
parents:
diff changeset
226 @findex java-mode
Dave Love <fx@gnu.org>
parents:
diff changeset
227 @findex idl-mode
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
228 @findex pike-mode
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
229 Note that the name of this package is ``@ccmode{}'', but there is no top
Dave Love <fx@gnu.org>
parents:
diff changeset
230 level @code{cc-mode} entry point. All of the variables, commands, and
Dave Love <fx@gnu.org>
parents:
diff changeset
231 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
232 @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
233 @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
234 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
235 @file{c++-mode.el}.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
236
Dave Love <fx@gnu.org>
parents:
diff changeset
237 @cindex @file{cc-compat.el} file
Dave Love <fx@gnu.org>
parents:
diff changeset
238 This distribution also contains a file
Dave Love <fx@gnu.org>
parents:
diff changeset
239 called @file{cc-compat.el} which should ease your transition from BOCM
Dave Love <fx@gnu.org>
parents:
diff changeset
240 to @ccmode{}. If you have a BOCM configuration you are really happy
Dave Love <fx@gnu.org>
parents:
diff changeset
241 with, and want to postpone learning how to configure @ccmode{}, take a
Dave Love <fx@gnu.org>
parents:
diff changeset
242 look at that file. It maps BOCM configuration variables to @ccmode{}'s
Dave Love <fx@gnu.org>
parents:
diff changeset
243 new indentation model. It is not actively supported so for the long
Dave Love <fx@gnu.org>
parents:
diff changeset
244 run, you should learn how to customize @ccmode{} to support your coding
Dave Love <fx@gnu.org>
parents:
diff changeset
245 style.
Dave Love <fx@gnu.org>
parents:
diff changeset
246
Dave Love <fx@gnu.org>
parents:
diff changeset
247 A special word of thanks goes to Krishna Padmasola for his work in
Dave Love <fx@gnu.org>
parents:
diff changeset
248 converting the original @file{README} file to Texinfo format. I'd also
Dave Love <fx@gnu.org>
parents:
diff changeset
249 like to thank all the @ccmode{} victims who help enormously during the
Dave Love <fx@gnu.org>
parents:
diff changeset
250 early beta stages of @ccmode{}'s development.
Dave Love <fx@gnu.org>
parents:
diff changeset
251
Dave Love <fx@gnu.org>
parents:
diff changeset
252
Dave Love <fx@gnu.org>
parents:
diff changeset
253 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
254 @node Getting Connected, New Indentation Engine, Introduction, Top
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
255 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
256 @chapter Getting Connected
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
257 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
258
Dave Love <fx@gnu.org>
parents:
diff changeset
259 If you got this version of @ccmode{} with Emacs or XEmacs, it should
Dave Love <fx@gnu.org>
parents:
diff changeset
260 work just fine right out of the box. Note however that you may not have
Dave Love <fx@gnu.org>
parents:
diff changeset
261 the latest @ccmode{} release and may want to upgrade your copy.
Dave Love <fx@gnu.org>
parents:
diff changeset
262
Dave Love <fx@gnu.org>
parents:
diff changeset
263 If you are upgrading an existing @ccmode{} installation, please see the
Dave Love <fx@gnu.org>
parents:
diff changeset
264 @file{README} file for installation details. @ccmode{} may not work
Dave Love <fx@gnu.org>
parents:
diff changeset
265 with older versions of Emacs or XEmacs. See the @ccmode{} release notes
Dave Love <fx@gnu.org>
parents:
diff changeset
266 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
267 compatibility (@pxref{Getting the Latest CC Mode Release}).
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
268
Dave Love <fx@gnu.org>
parents:
diff changeset
269 @cindex @file{cc-mode-18.el} file
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
270 @emph{Note that @ccmode{} no longer
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
271 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
272 you are out of luck.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
273
Dave Love <fx@gnu.org>
parents:
diff changeset
274 @findex c-version
Dave Love <fx@gnu.org>
parents:
diff changeset
275 @findex version (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
276 You can find out what version of @ccmode{} you are using by visiting a C
Dave Love <fx@gnu.org>
parents:
diff changeset
277 file and entering @kbd{M-x c-version RET}. You should see this message in
Dave Love <fx@gnu.org>
parents:
diff changeset
278 the echo area:
Dave Love <fx@gnu.org>
parents:
diff changeset
279 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
280
Dave Love <fx@gnu.org>
parents:
diff changeset
281 Using CC Mode version 5.XX
Dave Love <fx@gnu.org>
parents:
diff changeset
282
Dave Love <fx@gnu.org>
parents:
diff changeset
283 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
284
Dave Love <fx@gnu.org>
parents:
diff changeset
285 @noindent
Dave Love <fx@gnu.org>
parents:
diff changeset
286 where @samp{XX} is the minor release number.
Dave Love <fx@gnu.org>
parents:
diff changeset
287
Dave Love <fx@gnu.org>
parents:
diff changeset
288
Dave Love <fx@gnu.org>
parents:
diff changeset
289 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
290 @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
291 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
292 @chapter New Indentation Engine
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
293 @cindex indentation engine
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
294 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
295
Dave Love <fx@gnu.org>
parents:
diff changeset
296 @ccmode{} has a new indentation engine, providing a simplified, yet
Dave Love <fx@gnu.org>
parents:
diff changeset
297 flexible and general mechanism for customizing indentation. It separates
Dave Love <fx@gnu.org>
parents:
diff changeset
298 indentation calculation into two steps: first, @ccmode{} analyzes the
Dave Love <fx@gnu.org>
parents:
diff changeset
299 line of code being indented to determine the kind of language construct
Dave Love <fx@gnu.org>
parents:
diff changeset
300 it's looking at, then it applies user defined offsets to the current
Dave Love <fx@gnu.org>
parents:
diff changeset
301 line based on this analysis.
Dave Love <fx@gnu.org>
parents:
diff changeset
302
Dave Love <fx@gnu.org>
parents:
diff changeset
303 This section will briefly cover how indentation is calculated in
Dave Love <fx@gnu.org>
parents:
diff changeset
304 @ccmode{}. It is important to understand the indentation model
Dave Love <fx@gnu.org>
parents:
diff changeset
305 being used so that you will know how to customize @ccmode{} for
Dave Love <fx@gnu.org>
parents:
diff changeset
306 your personal coding style.
Dave Love <fx@gnu.org>
parents:
diff changeset
307
Dave Love <fx@gnu.org>
parents:
diff changeset
308 @menu
Dave Love <fx@gnu.org>
parents:
diff changeset
309 * Syntactic Analysis::
Dave Love <fx@gnu.org>
parents:
diff changeset
310 * Indentation Calculation::
Dave Love <fx@gnu.org>
parents:
diff changeset
311 @end menu
Dave Love <fx@gnu.org>
parents:
diff changeset
312
Dave Love <fx@gnu.org>
parents:
diff changeset
313
Dave Love <fx@gnu.org>
parents:
diff changeset
314 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
315 @node Syntactic Analysis, Indentation Calculation, , New Indentation Engine
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
316 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
317 @section Syntactic Analysis
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
318 @cindex syntactic analysis
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
319 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
320
Dave Love <fx@gnu.org>
parents:
diff changeset
321 @cindex relative buffer position
Dave Love <fx@gnu.org>
parents:
diff changeset
322 @cindex syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
323 @cindex syntactic component
Dave Love <fx@gnu.org>
parents:
diff changeset
324 @cindex syntactic component list
Dave Love <fx@gnu.org>
parents:
diff changeset
325 The first thing @ccmode{} does when indenting a line of code, is to
Dave Love <fx@gnu.org>
parents:
diff changeset
326 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
327 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
328 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
329 is a @dfn{syntactic symbol}, and the second part is a @dfn{relative
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
330 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
331 @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
332 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
333 @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
334 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
335 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
336 list of currently supported syntactic symbols.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
337
Dave Love <fx@gnu.org>
parents:
diff changeset
338 Conceptually, a line of C code is always indented relative to the
Dave Love <fx@gnu.org>
parents:
diff changeset
339 indentation of some line higher up in the buffer. This is represented
Dave Love <fx@gnu.org>
parents:
diff changeset
340 by the relative buffer position in the syntactic component.
Dave Love <fx@gnu.org>
parents:
diff changeset
341
Dave Love <fx@gnu.org>
parents:
diff changeset
342 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
343 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
344 don't actually appear in the buffer, of course!}:
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
345 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
346 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
347
Dave Love <fx@gnu.org>
parents:
diff changeset
348 1: void swap( int& a, int& b )
Dave Love <fx@gnu.org>
parents:
diff changeset
349 2: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
350 3: int tmp = a;
Dave Love <fx@gnu.org>
parents:
diff changeset
351 4: a = b;
Dave Love <fx@gnu.org>
parents:
diff changeset
352 5: b = tmp;
Dave Love <fx@gnu.org>
parents:
diff changeset
353 6: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
354
Dave Love <fx@gnu.org>
parents:
diff changeset
355 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
356 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
357
Dave Love <fx@gnu.org>
parents:
diff changeset
358 @kindex C-c C-s
Dave Love <fx@gnu.org>
parents:
diff changeset
359 @findex c-show-syntactic-information
Dave Love <fx@gnu.org>
parents:
diff changeset
360 @findex show-syntactic-information (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
361 We can use the command @kbd{C-c C-s}
Dave Love <fx@gnu.org>
parents:
diff changeset
362 (@code{c-show-syntactic-information}) to simply report what the
Dave Love <fx@gnu.org>
parents:
diff changeset
363 syntactic analysis is for the current line. Running this command on
Dave Love <fx@gnu.org>
parents:
diff changeset
364 line 4 of this example, we'd see in the echo area@footnote{With a universal
Dave Love <fx@gnu.org>
parents:
diff changeset
365 argument (i.e. @kbd{C-u C-c C-s}) the analysis is inserted into the
Dave Love <fx@gnu.org>
parents:
diff changeset
366 buffer as a comment
Dave Love <fx@gnu.org>
parents:
diff changeset
367 on the current line.}:
Dave Love <fx@gnu.org>
parents:
diff changeset
368 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
369
Dave Love <fx@gnu.org>
parents:
diff changeset
370 ((statement . 35))
Dave Love <fx@gnu.org>
parents:
diff changeset
371
Dave Love <fx@gnu.org>
parents:
diff changeset
372 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
373
Dave Love <fx@gnu.org>
parents:
diff changeset
374 This tells us that the line is a statement and it is indented relative
Dave Love <fx@gnu.org>
parents:
diff changeset
375 to buffer position 35, which happens to be the @samp{i} in @code{int} on
Dave Love <fx@gnu.org>
parents:
diff changeset
376 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
377 would see:
Dave Love <fx@gnu.org>
parents:
diff changeset
378 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
379
Dave Love <fx@gnu.org>
parents:
diff changeset
380 ((defun-block-intro . 29))
Dave Love <fx@gnu.org>
parents:
diff changeset
381
Dave Love <fx@gnu.org>
parents:
diff changeset
382 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
383
Dave Love <fx@gnu.org>
parents:
diff changeset
384 This indicates that the @samp{int} line is the first statement in a top
Dave Love <fx@gnu.org>
parents:
diff changeset
385 level function block, and is indented relative to buffer position 29,
Dave Love <fx@gnu.org>
parents:
diff changeset
386 which is the brace just after the function header.
Dave Love <fx@gnu.org>
parents:
diff changeset
387
Dave Love <fx@gnu.org>
parents:
diff changeset
388 Here's another example:
Dave Love <fx@gnu.org>
parents:
diff changeset
389 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
390 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
391
Dave Love <fx@gnu.org>
parents:
diff changeset
392 1: int add( int val, int incr, int doit )
Dave Love <fx@gnu.org>
parents:
diff changeset
393 2: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
394 3: if( doit )
Dave Love <fx@gnu.org>
parents:
diff changeset
395 4: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
396 5: return( val + incr );
Dave Love <fx@gnu.org>
parents:
diff changeset
397 6: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
398 7: return( val );
Dave Love <fx@gnu.org>
parents:
diff changeset
399 8: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
400
Dave Love <fx@gnu.org>
parents:
diff changeset
401 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
402 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
403
Dave Love <fx@gnu.org>
parents:
diff changeset
404 @noindent
Dave Love <fx@gnu.org>
parents:
diff changeset
405 Hitting @kbd{C-c C-s} on line 4 gives us:
Dave Love <fx@gnu.org>
parents:
diff changeset
406 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
407
Dave Love <fx@gnu.org>
parents:
diff changeset
408 ((substatement-open . 46))
Dave Love <fx@gnu.org>
parents:
diff changeset
409
Dave Love <fx@gnu.org>
parents:
diff changeset
410 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
411
Dave Love <fx@gnu.org>
parents:
diff changeset
412 @cindex substatement
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
413 @cindex substatement block
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
414 @noindent
Dave Love <fx@gnu.org>
parents:
diff changeset
415 which tells us that this is a brace that @emph{opens} a substatement
Dave Love <fx@gnu.org>
parents:
diff changeset
416 block. @footnote{A @dfn{substatement} is the line after a
Dave Love <fx@gnu.org>
parents:
diff changeset
417 conditional statement, such as @code{if}, @code{else}, @code{while},
Dave Love <fx@gnu.org>
parents:
diff changeset
418 @code{do}, @code{switch}, etc. A @dfn{substatement
Dave Love <fx@gnu.org>
parents:
diff changeset
419 block} is a brace block following one of these conditional statements.}
Dave Love <fx@gnu.org>
parents:
diff changeset
420
Dave Love <fx@gnu.org>
parents:
diff changeset
421 @cindex comment-only line
Dave Love <fx@gnu.org>
parents:
diff changeset
422 Syntactic component lists can contain more than one component, and
Dave Love <fx@gnu.org>
parents:
diff changeset
423 individual syntactic components need not have relative buffer positions.
Dave Love <fx@gnu.org>
parents:
diff changeset
424 The most common example of this is a line that contains a @dfn{comment
Dave Love <fx@gnu.org>
parents:
diff changeset
425 only line}.
Dave Love <fx@gnu.org>
parents:
diff changeset
426 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
427 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
428
Dave Love <fx@gnu.org>
parents:
diff changeset
429 1: void draw_list( List<Drawables>& drawables )
Dave Love <fx@gnu.org>
parents:
diff changeset
430 2: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
431 3: // call the virtual draw() method on each element in list
Dave Love <fx@gnu.org>
parents:
diff changeset
432 4: for( int i=0; i < drawables.count(), ++i )
Dave Love <fx@gnu.org>
parents:
diff changeset
433 5: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
434 6: drawables[i].draw();
Dave Love <fx@gnu.org>
parents:
diff changeset
435 7: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
436 8: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
437
Dave Love <fx@gnu.org>
parents:
diff changeset
438 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
439 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
440
Dave Love <fx@gnu.org>
parents:
diff changeset
441 @noindent
Dave Love <fx@gnu.org>
parents:
diff changeset
442 Hitting @kbd{C-c C-s} on line 3 of this example gives:
Dave Love <fx@gnu.org>
parents:
diff changeset
443 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
444
Dave Love <fx@gnu.org>
parents:
diff changeset
445 ((comment-intro) (defun-block-intro . 46))
Dave Love <fx@gnu.org>
parents:
diff changeset
446
Dave Love <fx@gnu.org>
parents:
diff changeset
447 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
448
Dave Love <fx@gnu.org>
parents:
diff changeset
449 @noindent
Dave Love <fx@gnu.org>
parents:
diff changeset
450 and you can see that the syntactic component list contains two syntactic
Dave Love <fx@gnu.org>
parents:
diff changeset
451 components. Also notice that the first component,
Dave Love <fx@gnu.org>
parents:
diff changeset
452 @samp{(comment-intro)} has no relative buffer position.
Dave Love <fx@gnu.org>
parents:
diff changeset
453
Dave Love <fx@gnu.org>
parents:
diff changeset
454
Dave Love <fx@gnu.org>
parents:
diff changeset
455 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
456 @node Indentation Calculation, , Syntactic Analysis, New Indentation Engine
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
457 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
458 @section Indentation Calculation
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
459 @cindex indentation calculation
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
460 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
461
Dave Love <fx@gnu.org>
parents:
diff changeset
462 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
463 component list derived in step 1 above (@pxref{Syntactic Analysis}).
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
464 Each component contributes to the final total indentation of the line in
Dave Love <fx@gnu.org>
parents:
diff changeset
465 two ways.
Dave Love <fx@gnu.org>
parents:
diff changeset
466
Dave Love <fx@gnu.org>
parents:
diff changeset
467 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
468 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
469 the offsets to apply for those symbols. These offsets are added to a
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
470 running total.
Dave Love <fx@gnu.org>
parents:
diff changeset
471
Dave Love <fx@gnu.org>
parents:
diff changeset
472 Second, if the component has a relative buffer position, @ccmode{}
Dave Love <fx@gnu.org>
parents:
diff changeset
473 adds the column number of that position to the running total. By adding
Dave Love <fx@gnu.org>
parents:
diff changeset
474 up the offsets and columns for every syntactic component on the list,
Dave Love <fx@gnu.org>
parents:
diff changeset
475 the final total indentation for the current line is computed.
Dave Love <fx@gnu.org>
parents:
diff changeset
476
Dave Love <fx@gnu.org>
parents:
diff changeset
477 Let's use our two code examples above to see how this works. Here is
Dave Love <fx@gnu.org>
parents:
diff changeset
478 our first example again:
Dave Love <fx@gnu.org>
parents:
diff changeset
479 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
480 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
481
Dave Love <fx@gnu.org>
parents:
diff changeset
482 1: void swap( int& a, int& b )
Dave Love <fx@gnu.org>
parents:
diff changeset
483 2: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
484 3: int tmp = a;
Dave Love <fx@gnu.org>
parents:
diff changeset
485 4: a = b;
Dave Love <fx@gnu.org>
parents:
diff changeset
486 5: b = tmp;
Dave Love <fx@gnu.org>
parents:
diff changeset
487 6: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
488
Dave Love <fx@gnu.org>
parents:
diff changeset
489 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
490 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
491
Dave Love <fx@gnu.org>
parents:
diff changeset
492 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
493 the line. Remember that the syntactic component list for that
Dave Love <fx@gnu.org>
parents:
diff changeset
494 line is:
Dave Love <fx@gnu.org>
parents:
diff changeset
495 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
496
Dave Love <fx@gnu.org>
parents:
diff changeset
497 ((defun-block-intro . 29))
Dave Love <fx@gnu.org>
parents:
diff changeset
498
Dave Love <fx@gnu.org>
parents:
diff changeset
499 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
500
Dave Love <fx@gnu.org>
parents:
diff changeset
501 @noindent
Dave Love <fx@gnu.org>
parents:
diff changeset
502 @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
503 @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
504 @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
505 yielding a running total indentation of 4 spaces.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
506
Dave Love <fx@gnu.org>
parents:
diff changeset
507 Next @ccmode{} goes to buffer position 29 and asks for the current
Dave Love <fx@gnu.org>
parents:
diff changeset
508 column. This brace is in column zero, so @ccmode{}
Dave Love <fx@gnu.org>
parents:
diff changeset
509 adds @samp{0} to the running total. Since there is only one syntactic
Dave Love <fx@gnu.org>
parents:
diff changeset
510 component on the list for this line, indentation calculation is
Dave Love <fx@gnu.org>
parents:
diff changeset
511 complete, and the total indentation for the line
Dave Love <fx@gnu.org>
parents:
diff changeset
512 is 4 spaces.
Dave Love <fx@gnu.org>
parents:
diff changeset
513
Dave Love <fx@gnu.org>
parents:
diff changeset
514 Here's another example:
Dave Love <fx@gnu.org>
parents:
diff changeset
515 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
516 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
517
Dave Love <fx@gnu.org>
parents:
diff changeset
518 1: int add( int val, int incr, int doit )
Dave Love <fx@gnu.org>
parents:
diff changeset
519 2: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
520 3: if( doit )
Dave Love <fx@gnu.org>
parents:
diff changeset
521 4: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
522 5: return( val + incr );
Dave Love <fx@gnu.org>
parents:
diff changeset
523 6: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
524 7: return( val );
Dave Love <fx@gnu.org>
parents:
diff changeset
525 8: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
526
Dave Love <fx@gnu.org>
parents:
diff changeset
527 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
528 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
529
Dave Love <fx@gnu.org>
parents:
diff changeset
530 If we were to hit @kbd{TAB} on line 4 in the above example, the same
Dave Love <fx@gnu.org>
parents:
diff changeset
531 basic process is performed, despite the differences in the syntactic
Dave Love <fx@gnu.org>
parents:
diff changeset
532 component list. Remember that the list for this line is:
Dave Love <fx@gnu.org>
parents:
diff changeset
533 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
534
Dave Love <fx@gnu.org>
parents:
diff changeset
535 ((substatement-open . 46))
Dave Love <fx@gnu.org>
parents:
diff changeset
536
Dave Love <fx@gnu.org>
parents:
diff changeset
537 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
538
Dave Love <fx@gnu.org>
parents:
diff changeset
539 Here, @ccmode{} first looks up the @code{substatement-open} symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
540 in @code{c-offsets-alist}. Let's say it finds the value @samp{4}. This
Dave Love <fx@gnu.org>
parents:
diff changeset
541 yields a running total of 4. @ccmode{} then goes to
Dave Love <fx@gnu.org>
parents:
diff changeset
542 buffer position 46, which is the @samp{i} in @code{if} on line 3. This
Dave Love <fx@gnu.org>
parents:
diff changeset
543 character is in the fourth column on that line so adding this to the
Dave Love <fx@gnu.org>
parents:
diff changeset
544 running total yields an indentation for the line of 8 spaces.
Dave Love <fx@gnu.org>
parents:
diff changeset
545
Dave Love <fx@gnu.org>
parents:
diff changeset
546 Simple, huh?
Dave Love <fx@gnu.org>
parents:
diff changeset
547
Dave Love <fx@gnu.org>
parents:
diff changeset
548 Actually, the mode usually just does The Right Thing without you having
Dave Love <fx@gnu.org>
parents:
diff changeset
549 to think about it in this much detail. But when customizing
Dave Love <fx@gnu.org>
parents:
diff changeset
550 indentation, it's helpful to understand the general indentation model
Dave Love <fx@gnu.org>
parents:
diff changeset
551 being used.
Dave Love <fx@gnu.org>
parents:
diff changeset
552
Dave Love <fx@gnu.org>
parents:
diff changeset
553 @vindex c-echo-syntactic-information-p
Dave Love <fx@gnu.org>
parents:
diff changeset
554 @vindex echo-syntactic-information-p (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
555 As you configure @ccmode{}, you might want to set the variable
Dave Love <fx@gnu.org>
parents:
diff changeset
556 @code{c-echo-syntactic-information-p} to non-@code{nil} so that the
Dave Love <fx@gnu.org>
parents:
diff changeset
557 syntactic component list and calculated offset will always be echoed in
Dave Love <fx@gnu.org>
parents:
diff changeset
558 the minibuffer when you hit @kbd{TAB}.
Dave Love <fx@gnu.org>
parents:
diff changeset
559
Dave Love <fx@gnu.org>
parents:
diff changeset
560
Dave Love <fx@gnu.org>
parents:
diff changeset
561 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
562 @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
563 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
564 @chapter Minor Modes
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
565 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
566
Dave Love <fx@gnu.org>
parents:
diff changeset
567 @ccmode{} contains two minor-mode-like features that you should
Dave Love <fx@gnu.org>
parents:
diff changeset
568 find useful while you enter new C code. The first is called
Dave Love <fx@gnu.org>
parents:
diff changeset
569 @dfn{auto-newline} mode, and the second is called @dfn{hungry-delete}
Dave Love <fx@gnu.org>
parents:
diff changeset
570 mode. These minor modes can be toggled on and off independently, and
Dave Love <fx@gnu.org>
parents:
diff changeset
571 @ccmode{} can be configured so that it starts up with any
Dave Love <fx@gnu.org>
parents:
diff changeset
572 combination of these minor modes. By default, both of these minor modes
Dave Love <fx@gnu.org>
parents:
diff changeset
573 are turned off.
Dave Love <fx@gnu.org>
parents:
diff changeset
574
Dave Love <fx@gnu.org>
parents:
diff changeset
575 The state of the minor modes is always reflected in the minor mode list
Dave Love <fx@gnu.org>
parents:
diff changeset
576 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
577 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
578 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
579 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
580 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
581 you'd see @samp{C/ah}.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
582
Dave Love <fx@gnu.org>
parents:
diff changeset
583 @kindex C-c C-a
Dave Love <fx@gnu.org>
parents:
diff changeset
584 @kindex C-c C-d
Dave Love <fx@gnu.org>
parents:
diff changeset
585 @kindex C-c C-t
Dave Love <fx@gnu.org>
parents:
diff changeset
586 @findex c-toggle-hungry-state
Dave Love <fx@gnu.org>
parents:
diff changeset
587 @findex c-toggle-auto-state
Dave Love <fx@gnu.org>
parents:
diff changeset
588 @findex c-toggle-auto-hungry-state
Dave Love <fx@gnu.org>
parents:
diff changeset
589 @findex toggle-hungry-state (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
590 @findex toggle-auto-state (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
591 @findex toggle-auto-hungry-state (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
592 @ccmode{} provides keybindings which allow you to toggle the minor
Dave Love <fx@gnu.org>
parents:
diff changeset
593 modes on the fly while editing code. To toggle just the auto-newline
Dave Love <fx@gnu.org>
parents:
diff changeset
594 state, hit @kbd{C-c C-a} (@code{c-toggle-auto-state}). When you do
Dave Love <fx@gnu.org>
parents:
diff changeset
595 this, you should see the @samp{a} indicator either appear or disappear
Dave Love <fx@gnu.org>
parents:
diff changeset
596 on the modeline. Similarly, to toggle just the hungry-delete state, use
Dave Love <fx@gnu.org>
parents:
diff changeset
597 @kbd{C-c C-d} (@code{c-toggle-hungry-state}), and to toggle both states,
Dave Love <fx@gnu.org>
parents:
diff changeset
598 use @kbd{C-c C-t} (@code{c-toggle-auto-hungry-state}).
Dave Love <fx@gnu.org>
parents:
diff changeset
599
Dave Love <fx@gnu.org>
parents:
diff changeset
600 To set up the auto-newline and hungry-delete states to your preferred
Dave Love <fx@gnu.org>
parents:
diff changeset
601 values, you would need to add some lisp to your @file{.emacs} file that
Dave Love <fx@gnu.org>
parents:
diff changeset
602 called one of the @code{c-toggle-*-state} functions directly. When
Dave Love <fx@gnu.org>
parents:
diff changeset
603 called programmatically, each function takes a numeric value, where
Dave Love <fx@gnu.org>
parents:
diff changeset
604 a positive number enables the minor mode, a negative number disables the
Dave Love <fx@gnu.org>
parents:
diff changeset
605 mode, and zero toggles the current state of the mode.
Dave Love <fx@gnu.org>
parents:
diff changeset
606
Dave Love <fx@gnu.org>
parents:
diff changeset
607 So for example, if you wanted to enable both auto-newline and
Dave Love <fx@gnu.org>
parents:
diff changeset
608 hungry-delete for all your C file editing, you could add the following
Dave Love <fx@gnu.org>
parents:
diff changeset
609 to your @file{.emacs} file:
Dave Love <fx@gnu.org>
parents:
diff changeset
610 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
611
Dave Love <fx@gnu.org>
parents:
diff changeset
612 (add-hook 'c-mode-common-hook
Dave Love <fx@gnu.org>
parents:
diff changeset
613 '(lambda () (c-toggle-auto-hungry-state 1)))
Dave Love <fx@gnu.org>
parents:
diff changeset
614
Dave Love <fx@gnu.org>
parents:
diff changeset
615 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
616
Dave Love <fx@gnu.org>
parents:
diff changeset
617
Dave Love <fx@gnu.org>
parents:
diff changeset
618 @cindex electric characters
Dave Love <fx@gnu.org>
parents:
diff changeset
619
Dave Love <fx@gnu.org>
parents:
diff changeset
620 @menu
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
621 * Auto-newline Insertion::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
622 * Hungry-deletion of Whitespace::
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
623 @end menu
Dave Love <fx@gnu.org>
parents:
diff changeset
624
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
625
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
626 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
627 @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
628 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
629 @section Auto-newline Insertion
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
630 @cindex auto-newline insertion
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
631 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
632
Dave Love <fx@gnu.org>
parents:
diff changeset
633 @cindex electric commands
Dave Love <fx@gnu.org>
parents:
diff changeset
634 Auto-newline minor mode works by enabling certain @dfn{electric
Dave Love <fx@gnu.org>
parents:
diff changeset
635 commands}. Electric commands are typically bound to special characters
Dave Love <fx@gnu.org>
parents:
diff changeset
636 such as the left and right braces, colons, semi-colons, etc., which when
Dave Love <fx@gnu.org>
parents:
diff changeset
637 typed, perform some magic formatting in addition to inserting the typed
Dave Love <fx@gnu.org>
parents:
diff changeset
638 character. As a general rule, electric commands are only electric when
Dave Love <fx@gnu.org>
parents:
diff changeset
639 the following conditions apply:
Dave Love <fx@gnu.org>
parents:
diff changeset
640
Dave Love <fx@gnu.org>
parents:
diff changeset
641 @itemize @bullet
Dave Love <fx@gnu.org>
parents:
diff changeset
642 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
643 Auto-newline minor mode is enabled, as evidenced by a @samp{C/a} or
Dave Love <fx@gnu.org>
parents:
diff changeset
644 @samp{C/ah} indicator on the modeline.
Dave Love <fx@gnu.org>
parents:
diff changeset
645
Dave Love <fx@gnu.org>
parents:
diff changeset
646 @cindex literal
Dave Love <fx@gnu.org>
parents:
diff changeset
647 @cindex syntactic whitespace
Dave Love <fx@gnu.org>
parents:
diff changeset
648 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
649 The character was not typed inside of a literal @footnote{A
Dave Love <fx@gnu.org>
parents:
diff changeset
650 @dfn{literal} is defined as any comment, string, or C preprocessor macro
Dave Love <fx@gnu.org>
parents:
diff changeset
651 definition. These constructs are also known as @dfn{syntactic
Dave Love <fx@gnu.org>
parents:
diff changeset
652 whitespace} since they are usually ignored when scanning C code.}.
Dave Love <fx@gnu.org>
parents:
diff changeset
653
Dave Love <fx@gnu.org>
parents:
diff changeset
654 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
655 @kindex C-u
Dave Love <fx@gnu.org>
parents:
diff changeset
656 No numeric argument was supplied to the command (i.e. it was typed as
Dave Love <fx@gnu.org>
parents:
diff changeset
657 normal, with no @kbd{C-u} prefix).
Dave Love <fx@gnu.org>
parents:
diff changeset
658
Dave Love <fx@gnu.org>
parents:
diff changeset
659 @end itemize
Dave Love <fx@gnu.org>
parents:
diff changeset
660
Dave Love <fx@gnu.org>
parents:
diff changeset
661 @menu
Dave Love <fx@gnu.org>
parents:
diff changeset
662 * Hanging Braces::
Dave Love <fx@gnu.org>
parents:
diff changeset
663 * Hanging Colons::
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
664 * Hanging Semi-colons and Commas::
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
665 * Other Electric Commands::
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
666 * Clean-ups::
Dave Love <fx@gnu.org>
parents:
diff changeset
667 @end menu
Dave Love <fx@gnu.org>
parents:
diff changeset
668
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
669
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
670 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
671 @node Hanging Braces, Hanging Colons, , Auto-newline Insertion
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
672 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
673 @subsection Hanging Braces
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
674 @cindex hanging braces
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
675 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
676
Dave Love <fx@gnu.org>
parents:
diff changeset
677 @findex c-electric-brace
Dave Love <fx@gnu.org>
parents:
diff changeset
678 @findex electric-brace (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
679 @vindex c-hanging-braces-alist
Dave Love <fx@gnu.org>
parents:
diff changeset
680 @vindex hanging-braces-alist (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
681 When you type either an open or close brace (i.e. @kbd{@{} or @kbd{@}}),
Dave Love <fx@gnu.org>
parents:
diff changeset
682 the electric command @code{c-electric-brace} gets run. This command has
Dave Love <fx@gnu.org>
parents:
diff changeset
683 two electric formatting behaviors. First, it will perform some
Dave Love <fx@gnu.org>
parents:
diff changeset
684 re-indentation of the line the brace was typed on, and second, it will
Dave Love <fx@gnu.org>
parents:
diff changeset
685 add various newlines before and/or after the typed brace.
Dave Love <fx@gnu.org>
parents:
diff changeset
686 Re-indentation occurs automatically whenever the electric behavior is
Dave Love <fx@gnu.org>
parents:
diff changeset
687 enabled. If the brace ends up on a line other than the one it was typed
Dave Love <fx@gnu.org>
parents:
diff changeset
688 on, then that line is also re-indented.
Dave Love <fx@gnu.org>
parents:
diff changeset
689
Dave Love <fx@gnu.org>
parents:
diff changeset
690 @cindex class-open syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
691 @cindex class-close syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
692 @cindex defun-open syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
693 @cindex defun-close syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
694 @cindex inline-open syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
695 @cindex inline-close syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
696 @cindex brace-list-open syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
697 @cindex brace-list-close syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
698 @cindex brace-list-intro syntactic symbol
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
699 @cindex brace-entry-open syntactic symbol
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
700 @cindex block-open syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
701 @cindex block-close syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
702 @cindex substatement-open syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
703 @cindex statement-case-open syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
704 @cindex extern-lang-open syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
705 @cindex extern-lang-close syntactic symbol
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
706 @cindex namespace-open syntactic symbol
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
707 @cindex namespace-close syntactic symbol
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
708 @cindex inexpr-class-open symbol
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
709 @cindex inexpr-class-close symbol
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
710
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
711 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
712 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
713 @code{c-hanging-braces-alist} style variable. This variable contains a
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
714 mapping between syntactic symbols related to braces, and a list of
Dave Love <fx@gnu.org>
parents:
diff changeset
715 places to insert a newline. The syntactic symbols that are useful for
Dave Love <fx@gnu.org>
parents:
diff changeset
716 this list are: @code{class-open}, @code{class-close}, @code{defun-open},
Dave Love <fx@gnu.org>
parents:
diff changeset
717 @code{defun-close}, @code{inline-open}, @code{inline-close},
Dave Love <fx@gnu.org>
parents:
diff changeset
718 @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
719 @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
720 @code{block-close}, @code{substatement-open},
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
721 @code{statement-case-open}, @code{extern-lang-open},
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
722 @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
723 @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
724 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
725 @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
726 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
727 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
728 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
729 description of these syntactic symbols, except for
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
730 @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
731 actual syntactic symbols.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
732
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
733 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
734 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
735 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
736 braces of anonymous classes produces a combination of
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
737 @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
738 normal indentation analysis.}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
739
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
740 The value associated with each syntactic symbol in this association list
Dave Love <fx@gnu.org>
parents:
diff changeset
741 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
742 @xref{Custom Brace and Colon Hanging}, for a more detailed discussion of
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
743 using a function as a brace hanging @var{ACTION}.
Dave Love <fx@gnu.org>
parents:
diff changeset
744
Dave Love <fx@gnu.org>
parents:
diff changeset
745 When the @var{ACTION} is a list, it can contain any combination of the
Dave Love <fx@gnu.org>
parents:
diff changeset
746 symbols @code{before} and @code{after}, directing @ccmode{} where to
Dave Love <fx@gnu.org>
parents:
diff changeset
747 put newlines in relationship to the brace being inserted. Thus, if the
Dave Love <fx@gnu.org>
parents:
diff changeset
748 list contains only the symbol @code{after}, then the brace is said to
Dave Love <fx@gnu.org>
parents:
diff changeset
749 @dfn{hang} on the right side of the line, as in:
Dave Love <fx@gnu.org>
parents:
diff changeset
750 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
751 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
752
Dave Love <fx@gnu.org>
parents:
diff changeset
753 // here, open braces always `hang'
Dave Love <fx@gnu.org>
parents:
diff changeset
754 void spam( int i ) @{
Dave Love <fx@gnu.org>
parents:
diff changeset
755 if( i == 7 ) @{
Dave Love <fx@gnu.org>
parents:
diff changeset
756 dosomething(i);
Dave Love <fx@gnu.org>
parents:
diff changeset
757 @}
Dave Love <fx@gnu.org>
parents:
diff changeset
758 @}
Dave Love <fx@gnu.org>
parents:
diff changeset
759
Dave Love <fx@gnu.org>
parents:
diff changeset
760
Dave Love <fx@gnu.org>
parents:
diff changeset
761 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
762 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
763
Dave Love <fx@gnu.org>
parents:
diff changeset
764 When the list contains both @code{after} and @code{before}, the braces
Dave Love <fx@gnu.org>
parents:
diff changeset
765 will appear on a line by themselves, as shown by the close braces in the
Dave Love <fx@gnu.org>
parents:
diff changeset
766 above example. The list can also be empty, in which case no newlines
Dave Love <fx@gnu.org>
parents:
diff changeset
767 are added either before or after the brace.
Dave Love <fx@gnu.org>
parents:
diff changeset
768
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
769 If a syntactic symbol is missing entirely from
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
770 @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
771 @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
772 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
773
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
774 For example, the default value of @code{c-hanging-braces-alist} is:
Dave Love <fx@gnu.org>
parents:
diff changeset
775 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
776 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
777
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
778 ((brace-list-open)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
779 (brace-entry-open)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
780 (substatement-open after)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
781 (block-close . c-snug-do-while)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
782 (extern-lang-open after)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
783 (inexpr-class-open after)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
784 (inexpr-class-close before))
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
785
Dave Love <fx@gnu.org>
parents:
diff changeset
786 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
787 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
788
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
789 @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
790 @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
791 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
792 @code{substatement-open}, @code{extern-lang-open}, and
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
793 @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
794 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
795 @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
796 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
797 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
798 other cases, braces are put on a line by themselves.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
799
Dave Love <fx@gnu.org>
parents:
diff changeset
800 A word of caution: it is not a good idea to hang top-level construct
Dave Love <fx@gnu.org>
parents:
diff changeset
801 introducing braces, such as @code{class-open} or @code{defun-open}.
Dave Love <fx@gnu.org>
parents:
diff changeset
802 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
803 zero, hanging them can introduce performance problems.
26490
2b08d829af86 Fix complaints from makeinfo 4.0.
Eli Zaretskii <eliz@gnu.org>
parents: 25829
diff changeset
804 @xref{Performance Issues}, for more information.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
805
Dave Love <fx@gnu.org>
parents:
diff changeset
806
Dave Love <fx@gnu.org>
parents:
diff changeset
807 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
808 @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
809 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
810 @subsection Hanging Colons
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
811 @cindex hanging colons
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
812 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
813
Dave Love <fx@gnu.org>
parents:
diff changeset
814 @vindex hanging-colons-alist (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
815 @vindex c-hanging-colons-alist
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
816 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
817 colons can also be made to hang using the style variable
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
818 @code{c-hanging-colons-alist}. The syntactic symbols appropriate for
Dave Love <fx@gnu.org>
parents:
diff changeset
819 this assocation list are: @code{case-label}, @code{label},
Dave Love <fx@gnu.org>
parents:
diff changeset
820 @code{access-label}, @code{member-init-intro}, and @code{inher-intro}.
Dave Love <fx@gnu.org>
parents:
diff changeset
821 Note however that for @code{c-hanging-colons-alist}, @var{ACTION}s as
Dave Love <fx@gnu.org>
parents:
diff changeset
822 functions are not supported. See also @ref{Custom Brace and Colon
Dave Love <fx@gnu.org>
parents:
diff changeset
823 Hanging} for details.
Dave Love <fx@gnu.org>
parents:
diff changeset
824
Dave Love <fx@gnu.org>
parents:
diff changeset
825 In C++, double-colons are used as a scope operator but because these
Dave Love <fx@gnu.org>
parents:
diff changeset
826 colons always appear right next to each other, newlines before and after
Dave Love <fx@gnu.org>
parents:
diff changeset
827 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
828 @ccmode{}. @xref{Clean-ups}, for details.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
829
Dave Love <fx@gnu.org>
parents:
diff changeset
830
Dave Love <fx@gnu.org>
parents:
diff changeset
831 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
832 @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
833 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
834 @subsection Hanging Semi-colons and Commas
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
835 @cindex hanging semi-colons
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
836 @cindex hanging commas
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
837 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
838
Dave Love <fx@gnu.org>
parents:
diff changeset
839 Semicolons and commas are also electric in @ccmode{}, but since
Dave Love <fx@gnu.org>
parents:
diff changeset
840 these characters do not correspond directly to syntactic symbols, a
Dave Love <fx@gnu.org>
parents:
diff changeset
841 different mechanism is used to determine whether newlines should be
Dave Love <fx@gnu.org>
parents:
diff changeset
842 automatically inserted after these characters. @xref{Customizing
26490
2b08d829af86 Fix complaints from makeinfo 4.0.
Eli Zaretskii <eliz@gnu.org>
parents: 25829
diff changeset
843 Semi-colons and Commas}, for details.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
844
Dave Love <fx@gnu.org>
parents:
diff changeset
845
Dave Love <fx@gnu.org>
parents:
diff changeset
846 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
847 @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
848 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
849 @subsection Other Electric Commands
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
850 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
851
Dave Love <fx@gnu.org>
parents:
diff changeset
852 @kindex #
Dave Love <fx@gnu.org>
parents:
diff changeset
853 @findex c-electric-pound
Dave Love <fx@gnu.org>
parents:
diff changeset
854 @vindex c-electric-pound-behavior
Dave Love <fx@gnu.org>
parents:
diff changeset
855 @findex electric-pound (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
856 @vindex electric-pound-behavior (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
857 A few other keys also provide electric behavior. For example
Dave Love <fx@gnu.org>
parents:
diff changeset
858 @kbd{#} (@code{c-electric-pound}) is electric when typed as
Dave Love <fx@gnu.org>
parents:
diff changeset
859 the first non-whitespace character on a line. In this case, the
Dave Love <fx@gnu.org>
parents:
diff changeset
860 variable @code{c-electric-pound-behavior} is consulted for the electric
Dave Love <fx@gnu.org>
parents:
diff changeset
861 behavior. This variable takes a list value, although the only element
Dave Love <fx@gnu.org>
parents:
diff changeset
862 currently defined is @code{alignleft}, which tells this command to force
Dave Love <fx@gnu.org>
parents:
diff changeset
863 the @samp{#} character into column zero. This is useful for entering
Dave Love <fx@gnu.org>
parents:
diff changeset
864 C preprocessor macro definitions.
Dave Love <fx@gnu.org>
parents:
diff changeset
865
Dave Love <fx@gnu.org>
parents:
diff changeset
866 @findex c-electric-star
Dave Love <fx@gnu.org>
parents:
diff changeset
867 @findex c-electric-slash
Dave Love <fx@gnu.org>
parents:
diff changeset
868 @findex electric-star (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
869 @findex electric-slash (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
870 Stars and slashes (i.e. @kbd{*} and @kbd{/}, @code{c-electric-star} and
Dave Love <fx@gnu.org>
parents:
diff changeset
871 @code{c-electric-slash} respectively) are also electric under
Dave Love <fx@gnu.org>
parents:
diff changeset
872 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
873 a C style block comment on a comment-only line, then the comment
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
874 delimiter is indented as defined by @code{c-offsets-alist}. A
Dave Love <fx@gnu.org>
parents:
diff changeset
875 comment-only line is defined as a line which contains only a comment, as
Dave Love <fx@gnu.org>
parents:
diff changeset
876 in:
Dave Love <fx@gnu.org>
parents:
diff changeset
877 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
878 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
879
Dave Love <fx@gnu.org>
parents:
diff changeset
880 void spam( int i )
Dave Love <fx@gnu.org>
parents:
diff changeset
881 @{
Dave Love <fx@gnu.org>
parents:
diff changeset
882 // this is a comment-only line...
Dave Love <fx@gnu.org>
parents:
diff changeset
883 if( i == 7 ) // but this is not
Dave Love <fx@gnu.org>
parents:
diff changeset
884 @{
Dave Love <fx@gnu.org>
parents:
diff changeset
885 dosomething(i);
Dave Love <fx@gnu.org>
parents:
diff changeset
886 @}
Dave Love <fx@gnu.org>
parents:
diff changeset
887 @}
Dave Love <fx@gnu.org>
parents:
diff changeset
888
Dave Love <fx@gnu.org>
parents:
diff changeset
889 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
890 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
891
Dave Love <fx@gnu.org>
parents:
diff changeset
892 Likewise, if a slash is inserted as the second slash in a C++ style line
Dave Love <fx@gnu.org>
parents:
diff changeset
893 comment (also only on a comment-only line), then the line is indented as
Dave Love <fx@gnu.org>
parents:
diff changeset
894 defined by @code{c-offsets-alist}.
Dave Love <fx@gnu.org>
parents:
diff changeset
895
Dave Love <fx@gnu.org>
parents:
diff changeset
896 @findex c-electric-lt-gt
Dave Love <fx@gnu.org>
parents:
diff changeset
897 @findex electric-lt-gt (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
898 @kindex <
Dave Love <fx@gnu.org>
parents:
diff changeset
899 @kindex >
Dave Love <fx@gnu.org>
parents:
diff changeset
900 Less-than and greater-than signs (@code{c-electric-lt-gt}) are also
Dave Love <fx@gnu.org>
parents:
diff changeset
901 electric, but only in C++ mode. Hitting the second of two @kbd{<} or
Dave Love <fx@gnu.org>
parents:
diff changeset
902 @kbd{>} keys re-indents the line if it is a C++ style stream operator.
Dave Love <fx@gnu.org>
parents:
diff changeset
903
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
904 @findex c-electric-paren
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
905 @findex electric-paren (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
906 @kindex (
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
907 @kindex )
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
908 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
909 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
910 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
911 automatically.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
912
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
913
Dave Love <fx@gnu.org>
parents:
diff changeset
914 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
915 @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
916 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
917 @subsection Clean-ups
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
918 @cindex clean-ups
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
919 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
920
Dave Love <fx@gnu.org>
parents:
diff changeset
921 @dfn{Clean-ups} are a mechanism complementary to colon and brace
Dave Love <fx@gnu.org>
parents:
diff changeset
922 hanging. On the surface, it would seem that clean-ups overlap the
Dave Love <fx@gnu.org>
parents:
diff changeset
923 functionality provided by the @code{c-hanging-*-alist} variables, and
Dave Love <fx@gnu.org>
parents:
diff changeset
924 similarly, clean-ups are only enabled when auto-newline minor mode is
Dave Love <fx@gnu.org>
parents:
diff changeset
925 enabled. Clean-ups are used however to adjust code ``after-the-fact'',
Dave Love <fx@gnu.org>
parents:
diff changeset
926 i.e. to eliminate some whitespace that is inserted by electric
Dave Love <fx@gnu.org>
parents:
diff changeset
927 commands, or whitespace that contains intervening constructs.
Dave Love <fx@gnu.org>
parents:
diff changeset
928
Dave Love <fx@gnu.org>
parents:
diff changeset
929 @vindex c-cleanup-list
Dave Love <fx@gnu.org>
parents:
diff changeset
930 @vindex cleanup-list (c-)
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
931 @cindex literal
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
932 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
933 @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
934 @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
935 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
936 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
937 (@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
938 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
939
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
940 There are currently only five specific constructs that @ccmode{}
Dave Love <fx@gnu.org>
parents:
diff changeset
941 can clean up, as indicated by these symbols:
Dave Love <fx@gnu.org>
parents:
diff changeset
942
Dave Love <fx@gnu.org>
parents:
diff changeset
943 @itemize @bullet
Dave Love <fx@gnu.org>
parents:
diff changeset
944 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
945 @code{brace-else-brace} --- cleans up @samp{@} else @{} constructs by
Dave Love <fx@gnu.org>
parents:
diff changeset
946 placing the entire construct on a single line. Clean-up occurs when the
Dave Love <fx@gnu.org>
parents:
diff changeset
947 open brace after the @samp{else} is typed. So for example, this:
Dave Love <fx@gnu.org>
parents:
diff changeset
948 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
949 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
950
Dave Love <fx@gnu.org>
parents:
diff changeset
951 void spam(int i)
Dave Love <fx@gnu.org>
parents:
diff changeset
952 @{
Dave Love <fx@gnu.org>
parents:
diff changeset
953 if( i==7 )
Dave Love <fx@gnu.org>
parents:
diff changeset
954 @{
Dave Love <fx@gnu.org>
parents:
diff changeset
955 dosomething();
Dave Love <fx@gnu.org>
parents:
diff changeset
956 @}
Dave Love <fx@gnu.org>
parents:
diff changeset
957 else
Dave Love <fx@gnu.org>
parents:
diff changeset
958 @{
Dave Love <fx@gnu.org>
parents:
diff changeset
959
Dave Love <fx@gnu.org>
parents:
diff changeset
960 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
961 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
962 @noindent
Dave Love <fx@gnu.org>
parents:
diff changeset
963 appears like this after the open brace is typed:
Dave Love <fx@gnu.org>
parents:
diff changeset
964 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
965 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
966
Dave Love <fx@gnu.org>
parents:
diff changeset
967 void spam(int i)
Dave Love <fx@gnu.org>
parents:
diff changeset
968 @{
Dave Love <fx@gnu.org>
parents:
diff changeset
969 if( i==7 ) @{
Dave Love <fx@gnu.org>
parents:
diff changeset
970 dosomething();
Dave Love <fx@gnu.org>
parents:
diff changeset
971 @} else @{
Dave Love <fx@gnu.org>
parents:
diff changeset
972
Dave Love <fx@gnu.org>
parents:
diff changeset
973 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
974 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
975
Dave Love <fx@gnu.org>
parents:
diff changeset
976 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
977 @code{brace-elseif-brace} --- similar to the @code{brace-else-brace}
Dave Love <fx@gnu.org>
parents:
diff changeset
978 clean-up, but this cleans up @samp{@} else if (...) @{} constructs. For
Dave Love <fx@gnu.org>
parents:
diff changeset
979 example:
Dave Love <fx@gnu.org>
parents:
diff changeset
980 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
981 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
982
Dave Love <fx@gnu.org>
parents:
diff changeset
983 void spam(int i)
Dave Love <fx@gnu.org>
parents:
diff changeset
984 @{
Dave Love <fx@gnu.org>
parents:
diff changeset
985 if( i==7 )
Dave Love <fx@gnu.org>
parents:
diff changeset
986 @{
Dave Love <fx@gnu.org>
parents:
diff changeset
987 dosomething();
Dave Love <fx@gnu.org>
parents:
diff changeset
988 @}
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
989 else if( i==3 )
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
990 @{
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
991
Dave Love <fx@gnu.org>
parents:
diff changeset
992 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
993 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
994 @noindent
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
995 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
996 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
997 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
998
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
999 void spam(int i)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1000 @{
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1001 if( i==7 ) @{
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1002 dosomething();
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1003 @} else if( i==3 )
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1004 @{
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1005
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1006 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1007 @end example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1008 @noindent
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1009 and like this after the open brace is typed:
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1010 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
1011 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
1012
Dave Love <fx@gnu.org>
parents:
diff changeset
1013 void spam(int i)
Dave Love <fx@gnu.org>
parents:
diff changeset
1014 @{
Dave Love <fx@gnu.org>
parents:
diff changeset
1015 if( i==7 ) @{
Dave Love <fx@gnu.org>
parents:
diff changeset
1016 dosomething();
Dave Love <fx@gnu.org>
parents:
diff changeset
1017 @} else if( i==3 ) @{
Dave Love <fx@gnu.org>
parents:
diff changeset
1018
Dave Love <fx@gnu.org>
parents:
diff changeset
1019 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
1020 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
1021
Dave Love <fx@gnu.org>
parents:
diff changeset
1022 @item
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1023 @code{brace-catch-brace} --- analogous to @code{brace-elseif-brace}, but
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1024 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
1025
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1026 @item
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1027 @code{empty-defun-braces} --- cleans up braces following a top-level
Dave Love <fx@gnu.org>
parents:
diff changeset
1028 function or class definition that contains no body. Clean up occurs
Dave Love <fx@gnu.org>
parents:
diff changeset
1029 when the closing brace is typed. Thus the following:
Dave Love <fx@gnu.org>
parents:
diff changeset
1030 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
1031 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
1032
Dave Love <fx@gnu.org>
parents:
diff changeset
1033 class Spam
Dave Love <fx@gnu.org>
parents:
diff changeset
1034 @{
Dave Love <fx@gnu.org>
parents:
diff changeset
1035 @}
Dave Love <fx@gnu.org>
parents:
diff changeset
1036
Dave Love <fx@gnu.org>
parents:
diff changeset
1037 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
1038 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
1039 @noindent
Dave Love <fx@gnu.org>
parents:
diff changeset
1040 is transformed into this when the close brace is typed:
Dave Love <fx@gnu.org>
parents:
diff changeset
1041 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
1042 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
1043
Dave Love <fx@gnu.org>
parents:
diff changeset
1044 class Spam
Dave Love <fx@gnu.org>
parents:
diff changeset
1045 @{@}
Dave Love <fx@gnu.org>
parents:
diff changeset
1046
Dave Love <fx@gnu.org>
parents:
diff changeset
1047 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
1048 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
1049
Dave Love <fx@gnu.org>
parents:
diff changeset
1050 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
1051 @code{defun-close-semi} --- cleans up the terminating semi-colon on
Dave Love <fx@gnu.org>
parents:
diff changeset
1052 top-level function or class definitions when they follow a close
Dave Love <fx@gnu.org>
parents:
diff changeset
1053 brace. Clean up occurs when the semi-colon is typed.
Dave Love <fx@gnu.org>
parents:
diff changeset
1054 So for example, the following:
Dave Love <fx@gnu.org>
parents:
diff changeset
1055 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
1056 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
1057
Dave Love <fx@gnu.org>
parents:
diff changeset
1058 class Spam
Dave Love <fx@gnu.org>
parents:
diff changeset
1059 @{
Dave Love <fx@gnu.org>
parents:
diff changeset
1060 @}
Dave Love <fx@gnu.org>
parents:
diff changeset
1061 ;
Dave Love <fx@gnu.org>
parents:
diff changeset
1062
Dave Love <fx@gnu.org>
parents:
diff changeset
1063 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
1064 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
1065 @noindent
Dave Love <fx@gnu.org>
parents:
diff changeset
1066 is transformed into this when the semi-colon is typed:
Dave Love <fx@gnu.org>
parents:
diff changeset
1067
Dave Love <fx@gnu.org>
parents:
diff changeset
1068 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
1069 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
1070
Dave Love <fx@gnu.org>
parents:
diff changeset
1071 class Spam
Dave Love <fx@gnu.org>
parents:
diff changeset
1072 @{
Dave Love <fx@gnu.org>
parents:
diff changeset
1073 @};
Dave Love <fx@gnu.org>
parents:
diff changeset
1074
Dave Love <fx@gnu.org>
parents:
diff changeset
1075 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
1076 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
1077
Dave Love <fx@gnu.org>
parents:
diff changeset
1078 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
1079 @code{list-close-comma} --- cleans up commas following braces in array
Dave Love <fx@gnu.org>
parents:
diff changeset
1080 and aggregate initializers. Clean up occurs when the comma is typed.
Dave Love <fx@gnu.org>
parents:
diff changeset
1081
Dave Love <fx@gnu.org>
parents:
diff changeset
1082 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
1083 @code{scope-operator} --- cleans up double colons which may designate a
Dave Love <fx@gnu.org>
parents:
diff changeset
1084 C++ scope operator split across multiple lines@footnote{Certain C++
Dave Love <fx@gnu.org>
parents:
diff changeset
1085 constructs introduce ambiguous situations, so @code{scope-operator}
Dave Love <fx@gnu.org>
parents:
diff changeset
1086 clean-ups may not always be correct. This usually only occurs when
Dave Love <fx@gnu.org>
parents:
diff changeset
1087 scoped identifiers appear in switch label tags.}. Clean up occurs when
Dave Love <fx@gnu.org>
parents:
diff changeset
1088 the second colon is typed. You will always want @code{scope-operator}
Dave Love <fx@gnu.org>
parents:
diff changeset
1089 in the @code{c-cleanup-list} when you are editing C++ code.
Dave Love <fx@gnu.org>
parents:
diff changeset
1090
Dave Love <fx@gnu.org>
parents:
diff changeset
1091 @end itemize
Dave Love <fx@gnu.org>
parents:
diff changeset
1092
Dave Love <fx@gnu.org>
parents:
diff changeset
1093
Dave Love <fx@gnu.org>
parents:
diff changeset
1094 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1095 @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
1096 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1097 @section Hungry-deletion of Whitespace
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1098 @cindex hungry-deletion of whitespace
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1099 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
1100
Dave Love <fx@gnu.org>
parents:
diff changeset
1101 Hungry deletion of whitespace, or as it more commonly called,
Dave Love <fx@gnu.org>
parents:
diff changeset
1102 @dfn{hungry-delete mode}, is a simple feature that some people find
Dave Love <fx@gnu.org>
parents:
diff changeset
1103 extremely useful. In fact, you might find yourself wanting
Dave Love <fx@gnu.org>
parents:
diff changeset
1104 hungry-delete in @strong{all} your editing modes!
Dave Love <fx@gnu.org>
parents:
diff changeset
1105
Dave Love <fx@gnu.org>
parents:
diff changeset
1106 @kindex DEL
Dave Love <fx@gnu.org>
parents:
diff changeset
1107 @kindex Backspace
Dave Love <fx@gnu.org>
parents:
diff changeset
1108 In a nutshell, when hungry-delete mode is enabled, hitting the
Dave Love <fx@gnu.org>
parents:
diff changeset
1109 @key{Backspace} key@footnote{I say ``hit the @key{Backspace} key'' but
Dave Love <fx@gnu.org>
parents:
diff changeset
1110 what I really mean is ``when Emacs receives the @code{BackSpace} key
Dave Love <fx@gnu.org>
parents:
diff changeset
1111 event''. The difference usually isn't significant to most users, but
Dave Love <fx@gnu.org>
parents:
diff changeset
1112 advanced users will realize that under window systems such as X, any
Dave Love <fx@gnu.org>
parents:
diff changeset
1113 physical key (keycap) on the keyboard can be configured to generate any
Dave Love <fx@gnu.org>
parents:
diff changeset
1114 keysym, and thus any Emacs key event. Also, the use of Emacs on TTYs
Dave Love <fx@gnu.org>
parents:
diff changeset
1115 will affect which keycap generates which key event. From a pedantic
Dave Love <fx@gnu.org>
parents:
diff changeset
1116 point of view, here we are only concerned with the key event that
Dave Love <fx@gnu.org>
parents:
diff changeset
1117 Emacs receives.} will consume all preceding whitespace, including
Dave Love <fx@gnu.org>
parents:
diff changeset
1118 newlines and tabs. This can really cut down on the number of
Dave Love <fx@gnu.org>
parents:
diff changeset
1119 @key{Backspace}'s you have to type if, for example you made a mistake on
Dave Love <fx@gnu.org>
parents:
diff changeset
1120 the preceding line.
Dave Love <fx@gnu.org>
parents:
diff changeset
1121
Dave Love <fx@gnu.org>
parents:
diff changeset
1122 @findex c-electric-backspace
Dave Love <fx@gnu.org>
parents:
diff changeset
1123 @findex electric-backspace (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
1124 @vindex c-backspace-function
Dave Love <fx@gnu.org>
parents:
diff changeset
1125 @vindex backspace-function (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
1126
Dave Love <fx@gnu.org>
parents:
diff changeset
1127 @findex c-electric-delete
Dave Love <fx@gnu.org>
parents:
diff changeset
1128 @findex electric-delete (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
1129 @vindex c-delete-function
Dave Love <fx@gnu.org>
parents:
diff changeset
1130 @vindex delete-function (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
1131 @cindex literal
Dave Love <fx@gnu.org>
parents:
diff changeset
1132
Dave Love <fx@gnu.org>
parents:
diff changeset
1133 @findex backward-delete-char-untabify
Dave Love <fx@gnu.org>
parents:
diff changeset
1134
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1135 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
1136 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
1137 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
1138 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
1139 mode is disabled, the function contained in the
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1140 @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
1141 number of characters to delete). This variable is set to
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1142 @code{backward-delete-char-untabify} by default.
Dave Love <fx@gnu.org>
parents:
diff changeset
1143
Dave Love <fx@gnu.org>
parents:
diff changeset
1144 @vindex delete-key-deletes-forward
Dave Love <fx@gnu.org>
parents:
diff changeset
1145 @findex delete-char
Dave Love <fx@gnu.org>
parents:
diff changeset
1146
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1147 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
1148 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
1149 @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
1150 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
1151 @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
1152 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
1153 @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
1154 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
1155 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
1156 @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
1157 @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
1158 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
1159 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
1160 @code{delete-char} by default.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1161
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1162 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
1163 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
1164 explicitly binding @code{[delete]}@footnote{E.g. to
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1165 @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
1166 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
1167 @code{delete-key-deletes-forward}.}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1168
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1169 XEmacsen older than 20.3 behave similar to Emacs 19 and Emacs 20.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1170
Dave Love <fx@gnu.org>
parents:
diff changeset
1171
Dave Love <fx@gnu.org>
parents:
diff changeset
1172 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1173 @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
1174 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1175 @chapter Text Filling and Line Breaking
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1176 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
1177
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1178 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
1179 @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
1180 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
1181 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
1182 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
1183 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
1184 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
1185 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
1186 necessary.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1187
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1188 @vindex c-comment-prefix-regexp
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1189 @vindex comment-prefix-regexp (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1190 @cindex comment line prefix
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1191 @vindex comment-start
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1192 @vindex comment-end
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1193 @vindex comment-start-skip
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1194 @vindex paragraph-start
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1195 @vindex paragraph-separate
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1196 @vindex paragraph-ignore-fill-prefix
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1197 @vindex adaptive-fill-mode
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1198 @vindex adaptive-fill-regexp
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1199 @vindex adaptive-fill-first-line-regexp
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1200 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
1201 paragraphs, @ccmode{} makes several standard
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1202 variables@footnote{@code{comment-start}, @code{comment-end},
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1203 @code{comment-start-skip}, @code{paragraph-start},
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1204 @code{paragraph-separate}, @code{paragraph-ignore-fill-prefix},
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1205 @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
1206 @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
1207 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
1208 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
1209 @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
1210 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
1211 matches C++ style line comments like
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1212 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1213
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1214 // blah blah
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1215
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1216 @end example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1217
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1218 @noindent
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1219 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
1220 like
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1221 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1222 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1223
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1224 /*
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1225 * blah blah
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1226 */
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 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1229 @end example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1230
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1231 @noindent
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1232 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
1233 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
1234 (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
1235 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
1236 @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
1237 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
1238 it inside a @ccmode{} buffer.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1239
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1240 @findex auto-fill-mode
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1241 @cindex auto fill mode
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1242 @cindex paragraph fill
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1243 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
1244 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
1245 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
1246 @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
1247 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
1248 @code{string} syntactic symbol). In comments, @ccmode{} uses
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1249 @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
1250 lines in the comment.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1251
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1252 @vindex adaptive-fill-mode
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1253 @cindex adaptive fill mode
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1254 @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
1255 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
1256 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
1257 @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
1258 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
1259 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1260 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1261
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1262 /* 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
1263 * 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
1264 * Knuth,
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1265 *
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1266 * 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
1267 * proved it correct, not tried it.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1268 */
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1269
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1270 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1271 @end 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 @findex c-setup-filladapt
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1274 @findex setup-filladapt (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1275 @findex filladapt-mode
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1276 @vindex filladapt-mode
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1277 @cindex Filladapt mode
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1278 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
1279 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
1280 @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
1281 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
1282 @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
1283 by default). A patch for that is available from
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1284 @uref{http://www.python.org/emacs/cc-mode/,, the CC Mode site}.},
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1285 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
1286 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
1287 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
1288 something like this in your @file{.emacs}:
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1289 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1290 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1291
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1292 (defun my-c-mode-common-hook ()
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1293 (c-setup-filladapt)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1294 (filladapt-mode 1))
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1295 (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
1296
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1297 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1298 @end example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1299
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1300 @vindex c-block-comment-prefix
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1301 @vindex block-comment-prefix (c-)
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1302 @vindex c-comment-continuation-stars
Dave Love <fx@gnu.org>
parents:
diff changeset
1303 @vindex comment-continuation-stars (c-)
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1304 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
1305 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
1306 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
1307 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
1308 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
1309 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
1310 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
1311 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
1312 makes a comment
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1313 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1314
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1315 /* 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
1316
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1317 @end example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1318
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1319 @noindent
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1320 break into
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1321 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1322 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1323
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1324 /* Got O(n^2) here,
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1325 * which is a Bad Thing. */
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1326
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1327 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1328 @end example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1329
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1330 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
1331 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
1332 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
1333 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
1334 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
1335 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
1336 Functions}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1337
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1338 @vindex c-ignore-auto-fill
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1339 @vindex ignore-auto-fill (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1340 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
1341 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
1342 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
1343 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
1344 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
1345 should occur:
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1346
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1347 @itemize @bullet
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1348 @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
1349 @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
1350 @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
1351 @item @code{cpp} --- Inside a preprocessor directive.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1352 @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
1353 @end itemize
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1354
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1355 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
1356 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
1357 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
1358 explicit control over newlines. In preprocessor directives, the
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1359 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
1360 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
1361 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
1362 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
1363 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
1364 implementation.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1365
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1366 The commands that does the actual work follows.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1367
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1368 @table @asis
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1369
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1370 @kindex M-q
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1371 @findex c-fill-paragraph
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1372 @findex fill-paragraph (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1373 @cindex Javadoc markup
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1374 @item @kbd{M-q} (@code{c-fill-paragraph})
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1375 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
1376 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
1377 line style comments. In Java buffers, the Javadoc markup words are
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1378 recognized as paragraph starters.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1379
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1380 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
1381 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
1382 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
1383 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
1384 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
1385 @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
1386 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
1387 obsolete.}.
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 @kindex M-j
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1390 @findex c-indent-new-comment-line
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1391 @findex indent-new-comment-line (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1392 @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
1393 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
1394 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
1395
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1396 @vindex comment-multi-line
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1397 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
1398 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
1399 @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
1400 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
1401
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1402 @findex c-context-line-break
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1403 @findex context-line-break (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1404 @item @kbd{M-x c-context-line-break}
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1405 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
1406 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
1407 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
1408 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
1409 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
1410 indentation engine.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1411
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1412 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
1413 @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
1414 @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
1415
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1416 @end table
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1417
Dave Love <fx@gnu.org>
parents:
diff changeset
1418
Dave Love <fx@gnu.org>
parents:
diff changeset
1419 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1420 @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
1421 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1422 @chapter Commands
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1423 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
1424
Dave Love <fx@gnu.org>
parents:
diff changeset
1425 @menu
Dave Love <fx@gnu.org>
parents:
diff changeset
1426 * Indentation Commands::
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1427 * Movement Commands::
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1428 * Other Commands::
Dave Love <fx@gnu.org>
parents:
diff changeset
1429 @end menu
Dave Love <fx@gnu.org>
parents:
diff changeset
1430
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1431 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
1432 that bit.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1433
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1434
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1435 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1436 @node Indentation Commands, Movement Commands, , Commands
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1437 @comment node-name, next, previous,up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1438 @section Indentation Commands
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1439 @cindex indentation commands
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1440 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
1441
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1442 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
1443 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
1444 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
1445 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
1446 your changes.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1447
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1448 @cindex GNU indent program
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1449 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
1450 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
1451 ``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
1452 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
1453 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
1454 among other things.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1455
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1456 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
1457 @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
1458 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
1459 code generator output@footnote{In particular, I have had people
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1460 complain about the speed with which @code{lex(1)} output is re-indented.
Dave Love <fx@gnu.org>
parents:
diff changeset
1461 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
1462 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
1463
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1464 These commands are useful when indenting code:
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1465
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1466 @table @asis
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1467
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1468 @kindex TAB
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1469 @findex c-indent-command
Dave Love <fx@gnu.org>
parents:
diff changeset
1470 @findex indent-command (c-)
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1471 @item @kbd{TAB} (@code{c-indent-command})
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1472 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
1473 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
1474 @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
1475 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
1476 the relative indentation among the lines.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1477
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1478 @kindex M-C-q
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1479 @findex c-indent-exp
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1480 @findex indent-exp (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1481 @item @kbd{M-C-q} (@code{c-indent-exp})
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1482 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
1483 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
1484 want to indent.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1485
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1486 @kindex C-c C-q
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1487 @findex c-indent-defun
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1488 @findex indent-defun (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1489 @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
1490 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
1491 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
1492 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
1493 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
1494 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
1495
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1496 @kindex M-C-\
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1497 @findex indent-region
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1498 @item @kbd{M-C-\} (@code{indent-region})
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1499 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
1500 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
1501 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
1502
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1503 @kindex M-C-h
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1504 @findex c-mark-function
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1505 @findex mark-function (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1506 @item @kbd{M-C-h} (@code{c-mark-function})
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1507 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
1508 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
1509 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
1510 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
1511
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1512 @end table
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1513
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1514 These variables are also useful when indenting code:
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1515
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1516 @table @code
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1517
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1518 @vindex c-tab-always-indent
Dave Love <fx@gnu.org>
parents:
diff changeset
1519 @vindex tab-always-indent (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
1520 @kindex TAB
Dave Love <fx@gnu.org>
parents:
diff changeset
1521 @cindex literal
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1522 @item c-tab-always-indent
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1523 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
1524 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
1525 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
1526 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
1527 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
1528 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
1529 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
1530 directives, but the line is always reindented.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1531
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1532 @vindex c-insert-tab-function
Dave Love <fx@gnu.org>
parents:
diff changeset
1533 @vindex insert-tab-function (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
1534 @findex tab-to-tab-stop
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1535 @item c-insert-tab-function
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1536 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
1537 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
1538 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
1539 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
1540 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
1541 @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
1542
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1543 @vindex indent-tabs-mode
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1544 @item indent-tabs-mode
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1545 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
1546 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
1547 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
1548
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1549 @vindex c-progress-interval
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1550 @vindex progress-interval (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1551 @item c-progress-interval
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1552 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
1553 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
1554 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
1555 interval in seconds that progress messages are displayed.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1556
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1557 @end table
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1558
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1559
Dave Love <fx@gnu.org>
parents:
diff changeset
1560 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1561 @node Movement Commands, Other Commands, Indentation Commands, Commands
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1562 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1563 @section Movement Commands
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1564 @cindex movement commands
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1565 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
1566
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1567 @ccmode{} contains some useful command for moving around in C
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1568 code.
Dave Love <fx@gnu.org>
parents:
diff changeset
1569
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1570 @table @asis
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1571
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1572 @findex c-beginning-of-defun
Dave Love <fx@gnu.org>
parents:
diff changeset
1573 @findex beginning-of-defun (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
1574 @findex beginning-of-defun
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1575 @item @kbd{M-x c-beginning-of-defun}
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1576 Moves point back to the least-enclosing brace. This function is
Dave Love <fx@gnu.org>
parents:
diff changeset
1577 analogous to the Emacs built-in command @code{beginning-of-defun},
Dave Love <fx@gnu.org>
parents:
diff changeset
1578 except it eliminates the constraint that the top-level opening brace
Dave Love <fx@gnu.org>
parents:
diff changeset
1579 must be in column zero. See @code{beginning-of-defun} for more
Dave Love <fx@gnu.org>
parents:
diff changeset
1580 information.
Dave Love <fx@gnu.org>
parents:
diff changeset
1581
Dave Love <fx@gnu.org>
parents:
diff changeset
1582 Depending on the coding style being used, you might prefer
Dave Love <fx@gnu.org>
parents:
diff changeset
1583 @code{c-beginning-of-defun} to @code{beginning-of-defun}. If so,
Dave Love <fx@gnu.org>
parents:
diff changeset
1584 consider binding @kbd{C-M-a} to the former instead. For backwards
Dave Love <fx@gnu.org>
parents:
diff changeset
1585 compatibility reasons, the default binding remains in effect.
Dave Love <fx@gnu.org>
parents:
diff changeset
1586
Dave Love <fx@gnu.org>
parents:
diff changeset
1587 @findex c-end-of-defun
Dave Love <fx@gnu.org>
parents:
diff changeset
1588 @findex end-of-defun (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
1589 @findex end-of-defun
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1590 @item @kbd{M-x c-end-of-defun}
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1591 Moves point to the end of the current top-level definition. This
Dave Love <fx@gnu.org>
parents:
diff changeset
1592 function is analogous to the Emacs built-in command @code{end-of-defun},
Dave Love <fx@gnu.org>
parents:
diff changeset
1593 except it eliminates the constraint that the top-level opening brace of
Dave Love <fx@gnu.org>
parents:
diff changeset
1594 the defun must be in column zero. See @code{beginning-of-defun} for more
Dave Love <fx@gnu.org>
parents:
diff changeset
1595 information.
Dave Love <fx@gnu.org>
parents:
diff changeset
1596
Dave Love <fx@gnu.org>
parents:
diff changeset
1597 Depending on the coding style being used, you might prefer
Dave Love <fx@gnu.org>
parents:
diff changeset
1598 @code{c-end-of-defun} to @code{end-of-defun}. If so,
Dave Love <fx@gnu.org>
parents:
diff changeset
1599 consider binding @kbd{C-M-e} to the former instead. For backwards
Dave Love <fx@gnu.org>
parents:
diff changeset
1600 compatibility reasons, the default binding remains in effect.
Dave Love <fx@gnu.org>
parents:
diff changeset
1601
Dave Love <fx@gnu.org>
parents:
diff changeset
1602 @kindex C-c C-u
Dave Love <fx@gnu.org>
parents:
diff changeset
1603 @findex c-up-conditional
Dave Love <fx@gnu.org>
parents:
diff changeset
1604 @findex up-conditional (c-)
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1605 @item @kbd{C-c C-u} (@code{c-up-conditional})
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1606 Move point back to the containing preprocessor conditional, leaving the
Dave Love <fx@gnu.org>
parents:
diff changeset
1607 mark behind. A prefix argument acts as a repeat count. With a negative
Dave Love <fx@gnu.org>
parents:
diff changeset
1608 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
1609 preprocessor conditional.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1610
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1611 @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
1612 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
1613
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1614 @findex c-up-conditional-with-else
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1615 @findex up-conditional-with-else (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1616 @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
1617 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
1618 lines. Normally those lines are ignored.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1619
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1620 @findex c-down-conditional
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1621 @findex down-conditional (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1622 @item @kbd{M-x c-down-conditional}
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1623 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
1624 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
1625 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
1626 nested preprocessor conditional.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1627
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1628 @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
1629 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
1630
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1631 @findex c-down-conditional-with-else
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1632 @findex down-conditional-with-else (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1633 @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
1634 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
1635 lines. Normally those lines are ignored.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1636
Dave Love <fx@gnu.org>
parents:
diff changeset
1637 @kindex C-c C-p
Dave Love <fx@gnu.org>
parents:
diff changeset
1638 @findex c-backward-conditional
Dave Love <fx@gnu.org>
parents:
diff changeset
1639 @findex backward-conditional (c-)
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1640 @item @kbd{C-c C-p} (@code{c-backward-conditional})
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1641 Move point back over a preprocessor conditional, leaving the mark
Dave Love <fx@gnu.org>
parents:
diff changeset
1642 behind. A prefix argument acts as a repeat count. With a negative
Dave Love <fx@gnu.org>
parents:
diff changeset
1643 argument, move forward.
Dave Love <fx@gnu.org>
parents:
diff changeset
1644
Dave Love <fx@gnu.org>
parents:
diff changeset
1645 @kindex C-c C-n
Dave Love <fx@gnu.org>
parents:
diff changeset
1646 @findex c-forward-conditional
Dave Love <fx@gnu.org>
parents:
diff changeset
1647 @findex forward-conditional (c-)
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1648 @item @kbd{C-c C-n} (@code{c-forward-conditional})
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1649 Move point forward across a preprocessor conditional, leaving the mark
Dave Love <fx@gnu.org>
parents:
diff changeset
1650 behind. A prefix argument acts as a repeat count. With a negative
Dave Love <fx@gnu.org>
parents:
diff changeset
1651 argument, move backward.
Dave Love <fx@gnu.org>
parents:
diff changeset
1652
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1653 @kindex M-a
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1654 @findex c-beginning-of-statement
Dave Love <fx@gnu.org>
parents:
diff changeset
1655 @findex beginning-of-statement (c-)
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1656 @item @kbd{M-a} (@code{c-beginning-of-statement})
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1657 Move point to the beginning of the innermost C statement. If point is
Dave Love <fx@gnu.org>
parents:
diff changeset
1658 already at the beginning of a statement, it moves to the beginning of
Dave Love <fx@gnu.org>
parents:
diff changeset
1659 the closest preceding statement, even if that means moving into a block
Dave Love <fx@gnu.org>
parents:
diff changeset
1660 (you can use @kbd{M-C-b} to move over a balanced block). With prefix
Dave Love <fx@gnu.org>
parents:
diff changeset
1661 argument @var{n}, move back @var{n} @minus{} 1 statements.
Dave Love <fx@gnu.org>
parents:
diff changeset
1662
Dave Love <fx@gnu.org>
parents:
diff changeset
1663 If point is within a comment, or next to a comment, this command moves
Dave Love <fx@gnu.org>
parents:
diff changeset
1664 by sentences instead of statements.
Dave Love <fx@gnu.org>
parents:
diff changeset
1665
Dave Love <fx@gnu.org>
parents:
diff changeset
1666 When called from a program, this function takes three optional
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1667 arguments: the numeric prefix argument, a buffer position limit which is
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1668 the farthest back to search, and a flag to enable moving by sentence
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1669 inside comments.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1670
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1671 @kindex M-e
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1672 @findex c-end-of-statement
Dave Love <fx@gnu.org>
parents:
diff changeset
1673 @findex end-of-statement (c-)
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1674 @item @kbd{M-e} (@code{c-end-of-statement})
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1675 Move point to the end of the innermost C statement. If point is at the
Dave Love <fx@gnu.org>
parents:
diff changeset
1676 end of a statement, move to the end of the next statement, even if it's
Dave Love <fx@gnu.org>
parents:
diff changeset
1677 inside a nested block (use @kbd{M-C-f} to move to the other side of the
Dave Love <fx@gnu.org>
parents:
diff changeset
1678 block). With prefix argument @var{n}, move forward @var{n} @minus{} 1
Dave Love <fx@gnu.org>
parents:
diff changeset
1679 statements.
Dave Love <fx@gnu.org>
parents:
diff changeset
1680
Dave Love <fx@gnu.org>
parents:
diff changeset
1681 If point is within a comment, or next to a comment, this command moves
Dave Love <fx@gnu.org>
parents:
diff changeset
1682 by sentences instead of statements.
Dave Love <fx@gnu.org>
parents:
diff changeset
1683
Dave Love <fx@gnu.org>
parents:
diff changeset
1684 When called from a program, this function takes three optional
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1685 arguments: the numeric prefix argument, a buffer position limit which is
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1686 the farthest back to search, and a flag to enable moving by sentence
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1687 inside comments.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1688
Dave Love <fx@gnu.org>
parents:
diff changeset
1689 @findex c-forward-into-nomenclature
Dave Love <fx@gnu.org>
parents:
diff changeset
1690 @findex forward-into-nomenclature (c-)
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1691 @item @kbd{M-x c-forward-into-nomenclature}
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1692 A popular programming style, especially for object-oriented languages
Dave Love <fx@gnu.org>
parents:
diff changeset
1693 such as C++ is to write symbols in a mixed case format, where the first
Dave Love <fx@gnu.org>
parents:
diff changeset
1694 letter of each word is capitalized, and not separated by underscores.
Dave Love <fx@gnu.org>
parents:
diff changeset
1695 E.g. @samp{SymbolsWithMixedCaseAndNoUnderlines}.
Dave Love <fx@gnu.org>
parents:
diff changeset
1696
Dave Love <fx@gnu.org>
parents:
diff changeset
1697 This command moves point forward to next capitalized word. With prefix
Dave Love <fx@gnu.org>
parents:
diff changeset
1698 argument @var{n}, move @var{n} times.
Dave Love <fx@gnu.org>
parents:
diff changeset
1699
Dave Love <fx@gnu.org>
parents:
diff changeset
1700 @findex c-backward-into-nomenclature
Dave Love <fx@gnu.org>
parents:
diff changeset
1701 @findex backward-into-nomenclature (c-)
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1702 @item @kbd{M-x c-backward-into-nomenclature}
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1703 Move point backward to beginning of the next capitalized
Dave Love <fx@gnu.org>
parents:
diff changeset
1704 word. With prefix argument @var{n}, move @var{n} times. If
Dave Love <fx@gnu.org>
parents:
diff changeset
1705 @var{n} is negative, move forward.
Dave Love <fx@gnu.org>
parents:
diff changeset
1706
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1707 @end table
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1708
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1709
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1710 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1711 @node Other Commands, , Movement Commands, Commands
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1712 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1713 @section Other Commands
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1714 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1715
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1716 @ccmode{} contains a few other useful commands:
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1717
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1718 @table @asis
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1719
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1720 @kindex C-c :
Dave Love <fx@gnu.org>
parents:
diff changeset
1721 @findex c-scope-operator
Dave Love <fx@gnu.org>
parents:
diff changeset
1722 @findex scope-operator (c-)
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1723 @item @kbd{C-c :} (@code{c-scope-operator})
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1724 In C++, it is also sometimes desirable to insert the double-colon scope
Dave Love <fx@gnu.org>
parents:
diff changeset
1725 operator without performing the electric behavior of colon insertion.
Dave Love <fx@gnu.org>
parents:
diff changeset
1726 @kbd{C-c :} does just this.
Dave Love <fx@gnu.org>
parents:
diff changeset
1727
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1728 @kindex C-c C-\
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1729 @findex c-backslash-region
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1730 @findex backslash-region (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1731 @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
1732 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
1733 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
1734 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
1735
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1736 @vindex c-backslash-column
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1737 @vindex backslash-column (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1738 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
1739 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
1740 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
1741
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1742 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
1743 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
1744 (if any) at the end of the previous line.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1745
Dave Love <fx@gnu.org>
parents:
diff changeset
1746 @end table
Dave Love <fx@gnu.org>
parents:
diff changeset
1747
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1748
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1749 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1750 @node Customizing Indentation, Syntactic Symbols, Commands, Top
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1751 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1752 @chapter Customizing Indentation
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1753 @cindex customizing indentation
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1754 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
1755
Dave Love <fx@gnu.org>
parents:
diff changeset
1756 @vindex c-offsets-alist
Dave Love <fx@gnu.org>
parents:
diff changeset
1757 @vindex offsets-alist (c-)
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1758 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
1759 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
1760 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
1761 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
1762 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
1763 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
1764 styles.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1765
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1766 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
1767 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
1768 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
1769 @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
1770 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
1771 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
1772 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
1773 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
1774
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1775 @kindex C-c C-o
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1776 @findex c-set-offset
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1777 @findex set-offset (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1778 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
1779 to set offsets, both interactively and from your mode
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1780 hook@footnote{Obviously, you use the keybinding interactively, and the
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1781 function call programmatically!}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1782
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1783 @vindex c-basic-offset
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1784 @vindex basic-offset (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1785 The offset associated with any particular syntactic symbol can be any of
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1786 an integer, a function or lambda expression, a variable name, or one of
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1787 the following symbols: @code{+}, @code{-}, @code{++}, @code{--},
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1788 @code{*}, or @code{/}. These latter describe offset in multiples of the
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1789 value of the style variable @code{c-basic-offset}. By defining a
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1790 style's indentation in terms of this fundamental variable, you can
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1791 change the amount of whitespace given to an indentation level while
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1792 maintaining the same basic shape of your code. Here are the values that
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1793 the special symbols correspond to:
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1794
Dave Love <fx@gnu.org>
parents:
diff changeset
1795 @table @code
Dave Love <fx@gnu.org>
parents:
diff changeset
1796
Dave Love <fx@gnu.org>
parents:
diff changeset
1797 @item +
Dave Love <fx@gnu.org>
parents:
diff changeset
1798 @code{c-basic-offset} times 1
Dave Love <fx@gnu.org>
parents:
diff changeset
1799 @item -
Dave Love <fx@gnu.org>
parents:
diff changeset
1800 @code{c-basic-offset} times -1
Dave Love <fx@gnu.org>
parents:
diff changeset
1801 @item ++
Dave Love <fx@gnu.org>
parents:
diff changeset
1802 @code{c-basic-offset} times 2
Dave Love <fx@gnu.org>
parents:
diff changeset
1803 @item --
Dave Love <fx@gnu.org>
parents:
diff changeset
1804 @code{c-basic-offset} times -2
Dave Love <fx@gnu.org>
parents:
diff changeset
1805 @item *
Dave Love <fx@gnu.org>
parents:
diff changeset
1806 @code{c-basic-offset} times 0.5
Dave Love <fx@gnu.org>
parents:
diff changeset
1807 @item /
Dave Love <fx@gnu.org>
parents:
diff changeset
1808 @code{c-basic-offset} times -0.5
Dave Love <fx@gnu.org>
parents:
diff changeset
1809
Dave Love <fx@gnu.org>
parents:
diff changeset
1810 @end table
Dave Love <fx@gnu.org>
parents:
diff changeset
1811
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1812 @cindex indentation functions
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1813
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1814 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
1815 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
1816 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
1817 @xref{Indentation Functions}, and @ref{Custom Indentation Functions},
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1818 for details about them.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1820 @vindex c-strict-syntax-p
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1821 @vindex strict-syntax-p (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1822 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
1823 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
1824 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
1825 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
1826 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
1827 @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
1828 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
1829 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
1830 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
1831 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
1832
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1833 So, for example, because most of the default offsets are defined in
Dave Love <fx@gnu.org>
parents:
diff changeset
1834 terms of @code{+}, @code{-}, and @code{0}, if you like the general
Dave Love <fx@gnu.org>
parents:
diff changeset
1835 indentation style, but you use 4 spaces instead of 2 spaces per level,
Dave Love <fx@gnu.org>
parents:
diff changeset
1836 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
1837 @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
1838 a C buffer by typing the text that appears in italics.}:
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1839 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
1840
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1841 @emph{M-x set-variable RET}
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1842 Set variable: @emph{c-basic-offset RET}
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1843 Set c-basic-offset to value: @emph{4 RET}
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1844
Dave Love <fx@gnu.org>
parents:
diff changeset
1845 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
1846
Dave Love <fx@gnu.org>
parents:
diff changeset
1847 @noindent
Dave Love <fx@gnu.org>
parents:
diff changeset
1848 This would change
Dave Love <fx@gnu.org>
parents:
diff changeset
1849 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
1850 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
1851
Dave Love <fx@gnu.org>
parents:
diff changeset
1852 int add( int val, int incr, int doit )
Dave Love <fx@gnu.org>
parents:
diff changeset
1853 @{
Dave Love <fx@gnu.org>
parents:
diff changeset
1854 if( doit )
Dave Love <fx@gnu.org>
parents:
diff changeset
1855 @{
Dave Love <fx@gnu.org>
parents:
diff changeset
1856 return( val + incr );
Dave Love <fx@gnu.org>
parents:
diff changeset
1857 @}
Dave Love <fx@gnu.org>
parents:
diff changeset
1858 return( val );
Dave Love <fx@gnu.org>
parents:
diff changeset
1859 @}
Dave Love <fx@gnu.org>
parents:
diff changeset
1860
Dave Love <fx@gnu.org>
parents:
diff changeset
1861 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
1862 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
1863 @noindent
Dave Love <fx@gnu.org>
parents:
diff changeset
1864 to
Dave Love <fx@gnu.org>
parents:
diff changeset
1865 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
1866 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
1867
Dave Love <fx@gnu.org>
parents:
diff changeset
1868 int add( int val, int incr, int doit )
Dave Love <fx@gnu.org>
parents:
diff changeset
1869 @{
Dave Love <fx@gnu.org>
parents:
diff changeset
1870 if( doit )
Dave Love <fx@gnu.org>
parents:
diff changeset
1871 @{
Dave Love <fx@gnu.org>
parents:
diff changeset
1872 return( val + incr );
Dave Love <fx@gnu.org>
parents:
diff changeset
1873 @}
Dave Love <fx@gnu.org>
parents:
diff changeset
1874 return( val );
Dave Love <fx@gnu.org>
parents:
diff changeset
1875 @}
Dave Love <fx@gnu.org>
parents:
diff changeset
1876
Dave Love <fx@gnu.org>
parents:
diff changeset
1877 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
1878 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
1879
Dave Love <fx@gnu.org>
parents:
diff changeset
1880 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
1881 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
1882 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
1883 your @file{.emacs} file so that your changes are more permanent.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1884
Dave Love <fx@gnu.org>
parents:
diff changeset
1885 @menu
Dave Love <fx@gnu.org>
parents:
diff changeset
1886 * Interactive Customization::
Dave Love <fx@gnu.org>
parents:
diff changeset
1887 * Permanent Customization::
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1888 * Hooks::
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1889 * Styles::
Dave Love <fx@gnu.org>
parents:
diff changeset
1890 * Advanced Customizations::
Dave Love <fx@gnu.org>
parents:
diff changeset
1891 @end menu
Dave Love <fx@gnu.org>
parents:
diff changeset
1892
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1893
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1894 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1895 @node Interactive Customization, Permanent Customization, , Customizing Indentation
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1896 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1897 @section Interactive Customization
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1898 @cindex interactive customization
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1899 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
1900
Dave Love <fx@gnu.org>
parents:
diff changeset
1901 As an example of how to customize indentation, let's change the
Dave Love <fx@gnu.org>
parents:
diff changeset
1902 style of this example@footnote{In this an subsequent examples, the
Dave Love <fx@gnu.org>
parents:
diff changeset
1903 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
1904 indicated. @xref{Styles}.}:
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1905 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
1906 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
1907
Dave Love <fx@gnu.org>
parents:
diff changeset
1908 1: int add( int val, int incr, int doit )
Dave Love <fx@gnu.org>
parents:
diff changeset
1909 2: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
1910 3: if( doit )
Dave Love <fx@gnu.org>
parents:
diff changeset
1911 4: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
1912 5: return( val + incr );
Dave Love <fx@gnu.org>
parents:
diff changeset
1913 6: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
1914 7: return( val );
Dave Love <fx@gnu.org>
parents:
diff changeset
1915 8: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
1916
Dave Love <fx@gnu.org>
parents:
diff changeset
1917 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
1918 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
1919 @noindent
Dave Love <fx@gnu.org>
parents:
diff changeset
1920 to:
Dave Love <fx@gnu.org>
parents:
diff changeset
1921 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
1922 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
1923
Dave Love <fx@gnu.org>
parents:
diff changeset
1924 1: int add( int val, int incr, int doit )
Dave Love <fx@gnu.org>
parents:
diff changeset
1925 2: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
1926 3: if( doit )
Dave Love <fx@gnu.org>
parents:
diff changeset
1927 4: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
1928 5: return( val + incr );
Dave Love <fx@gnu.org>
parents:
diff changeset
1929 6: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
1930 7: return( val );
Dave Love <fx@gnu.org>
parents:
diff changeset
1931 8: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
1932
Dave Love <fx@gnu.org>
parents:
diff changeset
1933 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
1934 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
1935
Dave Love <fx@gnu.org>
parents:
diff changeset
1936 In other words, we want to change the indentation of braces that open a
Dave Love <fx@gnu.org>
parents:
diff changeset
1937 block following a condition so that the braces line up under the
Dave Love <fx@gnu.org>
parents:
diff changeset
1938 conditional, instead of being indented. Notice that the construct we
Dave Love <fx@gnu.org>
parents:
diff changeset
1939 want to change starts on line 4. To change the indentation of a line,
Dave Love <fx@gnu.org>
parents:
diff changeset
1940 we need to see which syntactic components affect the offset calculations
Dave Love <fx@gnu.org>
parents:
diff changeset
1941 for that line. Hitting @kbd{C-c C-s} on line 4 yields:
Dave Love <fx@gnu.org>
parents:
diff changeset
1942 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
1943
Dave Love <fx@gnu.org>
parents:
diff changeset
1944 ((substatement-open . 44))
Dave Love <fx@gnu.org>
parents:
diff changeset
1945
Dave Love <fx@gnu.org>
parents:
diff changeset
1946 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
1947
Dave Love <fx@gnu.org>
parents:
diff changeset
1948 @noindent
Dave Love <fx@gnu.org>
parents:
diff changeset
1949 so we know that to change the offset of the open brace, we need to
Dave Love <fx@gnu.org>
parents:
diff changeset
1950 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
1951 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
1952 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
1953 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
1954 syntactic symbol we want to change!
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1955
Dave Love <fx@gnu.org>
parents:
diff changeset
1956 After you hit return, @ccmode{} will then prompt you for the new
Dave Love <fx@gnu.org>
parents:
diff changeset
1957 offset value, with the old value as the default. The default in this
Dave Love <fx@gnu.org>
parents:
diff changeset
1958 case is @samp{+}, but we want no extra indentation so enter
Dave Love <fx@gnu.org>
parents:
diff changeset
1959 @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
1960 syntactic symbol @code{substatement-open}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1961
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1962 To check your changes quickly, just hit @kbd{C-c C-q}
Dave Love <fx@gnu.org>
parents:
diff changeset
1963 (@code{c-indent-defun}) to reindent the entire function. The example
Dave Love <fx@gnu.org>
parents:
diff changeset
1964 should now look like:
Dave Love <fx@gnu.org>
parents:
diff changeset
1965 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
1966 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
1967
Dave Love <fx@gnu.org>
parents:
diff changeset
1968 1: int add( int val, int incr, int doit )
Dave Love <fx@gnu.org>
parents:
diff changeset
1969 2: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
1970 3: if( doit )
Dave Love <fx@gnu.org>
parents:
diff changeset
1971 4: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
1972 5: return( val + incr );
Dave Love <fx@gnu.org>
parents:
diff changeset
1973 6: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
1974 7: return( val );
Dave Love <fx@gnu.org>
parents:
diff changeset
1975 8: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
1976
Dave Love <fx@gnu.org>
parents:
diff changeset
1977 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
1978 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
1979
Dave Love <fx@gnu.org>
parents:
diff changeset
1980 Notice how just changing the open brace offset on line 4 is all we
Dave Love <fx@gnu.org>
parents:
diff changeset
1981 needed to do. Since the other affected lines are indented relative to
Dave Love <fx@gnu.org>
parents:
diff changeset
1982 line 4, they are automatically indented the way you'd expect. For more
Dave Love <fx@gnu.org>
parents:
diff changeset
1983 complicated examples, this may not always work. The general approach to
Dave Love <fx@gnu.org>
parents:
diff changeset
1984 take is to always start adjusting offsets for lines higher up in the
Dave Love <fx@gnu.org>
parents:
diff changeset
1985 file, then re-indent and see if any following lines need further
Dave Love <fx@gnu.org>
parents:
diff changeset
1986 adjustments.
Dave Love <fx@gnu.org>
parents:
diff changeset
1987
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1988
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1989 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1990 @node Permanent Customization, Hooks, Interactive Customization, Customizing Indentation
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1991 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1992 @section Permanent Customization
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1993 @cindex permanent customization
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1994 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1995
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
1996 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
1997 @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
1998 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
1999 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
2000 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
2001
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2002 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
2003 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
2004 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
2005 to the @file{.emacs} file:
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2006 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2007 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2008
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2009 (require 'cc-mode)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2010 (c-set-offset 'substatement-open 0)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2011
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2012 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2013 @end example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2014
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2015 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
2016 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
2017 defined.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2018
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2019 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
2020 this manual does not cover how that works.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2021
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2022 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
2023 all @ccmode{} buffers, regardless of language. The indentation style
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2024 related variables that you don't set get their value from the style
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2025 system (@pxref{Styles}), and they therefore depend on the setting of
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2026 @code{c-default-style}. Note that if you use Customize, this means that
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2027 the greyed-out default values presented there might not be the ones you
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2028 actually get, since the actual values depend on the style, which may
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2029 very well be different for different languages.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2030
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2031 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
2032 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
2033 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
2034 @ref{Styles}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2035
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2036 @vindex c-style-variables-are-local-p
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2037 @vindex style-variables-are-local-p (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2038 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
2039 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
2040 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
2041 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
2042 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
2043 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
2044 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
2045 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
2046 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
2047 without restarting Emacs.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2048
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2049
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2050 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2051 @node Hooks, Styles, Permanent Customization, Customizing Indentation
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2052 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2053 @section Hooks
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2054 @cindex hooks
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2055 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
2056
Dave Love <fx@gnu.org>
parents:
diff changeset
2057 @vindex c-mode-common-hook
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2058 @vindex mode-common-hook (c-)
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2059 @vindex c-mode-hook
Dave Love <fx@gnu.org>
parents:
diff changeset
2060 @vindex c++-mode-hook
Dave Love <fx@gnu.org>
parents:
diff changeset
2061 @vindex objc-mode-hook
Dave Love <fx@gnu.org>
parents:
diff changeset
2062 @vindex java-mode-hook
Dave Love <fx@gnu.org>
parents:
diff changeset
2063 @vindex idl-mode-hook
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2064 @vindex pike-mode-hook
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2065 @vindex c-initialization-hook
Dave Love <fx@gnu.org>
parents:
diff changeset
2066 @vindex initialization-hook (c-)
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2067 @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
2068 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
2069 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
2070 general hook and one package initialization hook:
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2071
Dave Love <fx@gnu.org>
parents:
diff changeset
2072 @itemize @bullet
Dave Love <fx@gnu.org>
parents:
diff changeset
2073
Dave Love <fx@gnu.org>
parents:
diff changeset
2074 @item
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2075 @code{c-mode-hook} --- For C buffers only.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2076 @item
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2077 @code{c++-mode-hook} --- For C++ buffers only.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2078 @item
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2079 @code{objc-mode-hook} --- For Objective-C buffers only.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2080 @item
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2081 @code{java-mode-hook} --- For Java buffers only.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2082 @item
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2083 @code{idl-mode-hook} --- For CORBA IDL buffers only.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2084 @item
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2085 @code{pike-mode-hook} --- For Pike buffers only.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2086 @item
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2087 @code{c-mode-common-hook} --- Common across all languages.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2088 @item
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2089 @code{c-initialization-hook} --- Hook run only once per Emacs session,
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2090 when @ccmode{} is initialized.
Dave Love <fx@gnu.org>
parents:
diff changeset
2091
Dave Love <fx@gnu.org>
parents:
diff changeset
2092 @end itemize
Dave Love <fx@gnu.org>
parents:
diff changeset
2093
Dave Love <fx@gnu.org>
parents:
diff changeset
2094 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
2095 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
2096 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
2097 customizations that are common across all languages. Most of the
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2098 examples in this section will assume you are using the common
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2099 hook.@footnote{@code{java-mode} and the hook variables interact in a
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2100 slightly different way than the other modes. @code{java-mode} normally
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2101 sets the style of the buffer to @samp{java} @emph{before} running the
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2102 @code{c-mode-common-hook} or @code{java-mode-hook}. You need to be
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2103 aware of this so that style settings in @code{c-mode-common-hook} don't
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2104 clobber your Java style. This is arguably bogus, but it's kept for
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2105 historical reasons. @xref{Built-in Styles}, the documentation of
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2106 @code{c-default-style}, for details.}
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2107
Dave Love <fx@gnu.org>
parents:
diff changeset
2108 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
2109 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
2110 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
2111 @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
2112 file.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2113 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
2114 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
2115
Dave Love <fx@gnu.org>
parents:
diff changeset
2116 (defun my-c-mode-common-hook ()
Dave Love <fx@gnu.org>
parents:
diff changeset
2117 ;; 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
2118 (no-case-fold-search)
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2119 )
Dave Love <fx@gnu.org>
parents:
diff changeset
2120 (add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
Dave Love <fx@gnu.org>
parents:
diff changeset
2121
Dave Love <fx@gnu.org>
parents:
diff changeset
2122 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
2123 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
2124
Dave Love <fx@gnu.org>
parents:
diff changeset
2125
Dave Love <fx@gnu.org>
parents:
diff changeset
2126 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2127 @node Styles, Advanced Customizations, Hooks, Customizing Indentation
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2128 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2129 @section Styles
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2130 @cindex styles
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2131 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
2132
Dave Love <fx@gnu.org>
parents:
diff changeset
2133 Most people only need to edit code formatted in just a few well-defined
Dave Love <fx@gnu.org>
parents:
diff changeset
2134 and consistent styles. For example, their organization might impose a
Dave Love <fx@gnu.org>
parents:
diff changeset
2135 ``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
2136 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
2137 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
2138 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
2139 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
2140 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
2141 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
2142 existing code using these styles.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2143
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2144 @cindex style variables
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2145 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
2146 variables}. They are handled specially in several ways:
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2147
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2148 @itemize @bullet
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2149 @item
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2150 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
2151 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
2152 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
2153 non-@code{nil} before @ccmode{} is initialized.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2154
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2155 @vindex c-old-style-variable-behavior
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2156 @vindex old-style-variable-behavior (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2157 @item
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2158 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
2159 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
2160 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
2161 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
2162 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
2163 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
2164 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
2165 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
2166 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
2167 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
2168
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2169 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
2170 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
2171 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
2172 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
2173 value.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2174
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2175 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
2176 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
2177 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
2178 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
2179 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
2180
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2181 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
2182 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
2183 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
2184 in version 5.26.}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2185
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2186 @item
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2187 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
2188 @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
2189 @xref{Built-in Styles}, for details.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2190
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2191 @end itemize
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2192
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2193 The style variables are:
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2194 @code{c-basic-offset},
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2195 @code{c-comment-only-line-offset},
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2196 @code{c-block-comment-prefix},
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2197 @code{c-comment-prefix-regexp},
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2198 @code{c-cleanup-list},
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2199 @code{c-hanging-braces-alist},
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2200 @code{c-hanging-colons-alist},
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2201 @code{c-hanging-semi&comma-criteria},
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2202 @code{c-backslash-column},
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2203 @code{c-special-indent-hook},
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2204 @code{c-label-minimum-indentation}, and
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2205 @code{c-offsets-alist}.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2206
Dave Love <fx@gnu.org>
parents:
diff changeset
2207 @menu
Dave Love <fx@gnu.org>
parents:
diff changeset
2208 * Built-in Styles::
Dave Love <fx@gnu.org>
parents:
diff changeset
2209 * Adding Styles::
Dave Love <fx@gnu.org>
parents:
diff changeset
2210 * File Styles::
Dave Love <fx@gnu.org>
parents:
diff changeset
2211 @end menu
Dave Love <fx@gnu.org>
parents:
diff changeset
2212
Dave Love <fx@gnu.org>
parents:
diff changeset
2213
Dave Love <fx@gnu.org>
parents:
diff changeset
2214 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2215 @node Built-in Styles, Adding Styles, , Styles
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2216 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2217 @subsection Built-in Styles
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2218 @cindex built-in styles
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2219 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
2220
Dave Love <fx@gnu.org>
parents:
diff changeset
2221 If you're lucky, one of @ccmode{}'s built-in styles might be just
Dave Love <fx@gnu.org>
parents:
diff changeset
2222 what you're looking for. These include:
Dave Love <fx@gnu.org>
parents:
diff changeset
2223
Dave Love <fx@gnu.org>
parents:
diff changeset
2224 @itemize @bullet
Dave Love <fx@gnu.org>
parents:
diff changeset
2225 @cindex GNU style
Dave Love <fx@gnu.org>
parents:
diff changeset
2226 @item
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2227 @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
2228 for C code in GNU programs.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2229
Dave Love <fx@gnu.org>
parents:
diff changeset
2230 @cindex K&R style
Dave Love <fx@gnu.org>
parents:
diff changeset
2231 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
2232 @code{k&r} --- The classic Kernighan and Ritchie style for C code.
Dave Love <fx@gnu.org>
parents:
diff changeset
2233
Dave Love <fx@gnu.org>
parents:
diff changeset
2234 @cindex BSD style
Dave Love <fx@gnu.org>
parents:
diff changeset
2235 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
2236 @code{bsd} --- Also known as ``Allman style'' after Eric Allman.
Dave Love <fx@gnu.org>
parents:
diff changeset
2237
Dave Love <fx@gnu.org>
parents:
diff changeset
2238 @cindex Whitesmith style
Dave Love <fx@gnu.org>
parents:
diff changeset
2239 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
2240 @code{whitesmith} --- Popularized by the examples that came with
Dave Love <fx@gnu.org>
parents:
diff changeset
2241 Whitesmiths C, an early commercial C compiler.
Dave Love <fx@gnu.org>
parents:
diff changeset
2242
Dave Love <fx@gnu.org>
parents:
diff changeset
2243 @cindex Stroustrup style
Dave Love <fx@gnu.org>
parents:
diff changeset
2244 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
2245 @code{stroustrup} --- The classic Stroustrup style for C++ code.
Dave Love <fx@gnu.org>
parents:
diff changeset
2246
Dave Love <fx@gnu.org>
parents:
diff changeset
2247 @cindex Ellemtel style
Dave Love <fx@gnu.org>
parents:
diff changeset
2248 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
2249 @code{ellemtel} --- Popular C++ coding standards as defined by
Dave Love <fx@gnu.org>
parents:
diff changeset
2250 ``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
2251 Henricson, Ellemtel@footnote{This document is available at
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2252 @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
2253 places.}.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2254
Dave Love <fx@gnu.org>
parents:
diff changeset
2255 @cindex Linux style
Dave Love <fx@gnu.org>
parents:
diff changeset
2256 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
2257 @code{linux} --- C coding standard for Linux development.
Dave Love <fx@gnu.org>
parents:
diff changeset
2258
Dave Love <fx@gnu.org>
parents:
diff changeset
2259 @cindex Python style
Dave Love <fx@gnu.org>
parents:
diff changeset
2260 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
2261 @code{python} --- C coding standard for Python extension
Dave Love <fx@gnu.org>
parents:
diff changeset
2262 modules@footnote{Python is a high level scripting language with a C/C++
Dave Love <fx@gnu.org>
parents:
diff changeset
2263 foreign function interface. For more information, see
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2264 @uref{http://www.python.org/}.}.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2265
Dave Love <fx@gnu.org>
parents:
diff changeset
2266 @cindex Java style
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2267 @findex java-mode
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2268 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
2269 @code{java} --- The style for editing Java code. Note that this style is
Dave Love <fx@gnu.org>
parents:
diff changeset
2270 automatically installed when you enter @code{java-mode}.
Dave Love <fx@gnu.org>
parents:
diff changeset
2271
Dave Love <fx@gnu.org>
parents:
diff changeset
2272 @cindex User style
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2273 @item
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2274 @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
2275 @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
2276 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
2277 @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
2278 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
2279 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
2280 (@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
2281 your new style and @code{user} style.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2282
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2283 @end itemize
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2284
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2285 @vindex c-default-style
Dave Love <fx@gnu.org>
parents:
diff changeset
2286 @vindex default-style (c-)
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2287 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
2288 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
2289 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
2290 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
2291 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
2292 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
2293 effect of these settings.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2294
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2295 @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
2296 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
2297 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
2298 mode. Here are the rules:
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2299
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2300 @vindex c-style-alist
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2301 @vindex style-alist (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2302 @vindex c-mode-common-hook
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2303 @vindex mode-common-hook (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2304 @enumerate
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2305 @item
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2306 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
2307 name as found in @code{c-style-alist}. This style is then used for all
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2308 modes @emph{except} @code{java-mode}, where the style @samp{java} is
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2309 used by default@footnote{This is for backwards compatibility reasons.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2310 The hard-coding of @code{java-mode} style is admittedly bogus!}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2311
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2312 @item
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2313 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
2314 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
2315 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
2316 style does not exist.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2317
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2318 @item
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2319 If @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
2320 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
2321 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
2322
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2323 @item
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2324 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
2325
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2326 @item
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2327 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
2328 @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
2329 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
2330 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
2331
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2332 @end enumerate
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2333
Dave Love <fx@gnu.org>
parents:
diff changeset
2334 @findex c-set-style
Dave Love <fx@gnu.org>
parents:
diff changeset
2335 @findex set-style (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
2336 @kindex C-c .
Dave Love <fx@gnu.org>
parents:
diff changeset
2337 If you'd like to experiment with these built-in styles you can simply
Dave Love <fx@gnu.org>
parents:
diff changeset
2338 type the following in a @ccmode{} buffer:
Dave Love <fx@gnu.org>
parents:
diff changeset
2339 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
2340 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
2341
Dave Love <fx@gnu.org>
parents:
diff changeset
2342 @kbd{C-c . @var{STYLE-NAME} RET}
Dave Love <fx@gnu.org>
parents:
diff changeset
2343
Dave Love <fx@gnu.org>
parents:
diff changeset
2344 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
2345 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
2346 @noindent
Dave Love <fx@gnu.org>
parents:
diff changeset
2347 @kbd{C-c .} runs the command @code{c-set-style}. Note that all style
Dave Love <fx@gnu.org>
parents:
diff changeset
2348 names are case insensitive, even the ones you define.
Dave Love <fx@gnu.org>
parents:
diff changeset
2349
Dave Love <fx@gnu.org>
parents:
diff changeset
2350 Setting a style in this way does @emph{not} automatically re-indent your
Dave Love <fx@gnu.org>
parents:
diff changeset
2351 file. For commands that you can use to view the effect of your changes,
Dave Love <fx@gnu.org>
parents:
diff changeset
2352 see @ref{Commands}.
Dave Love <fx@gnu.org>
parents:
diff changeset
2353
Dave Love <fx@gnu.org>
parents:
diff changeset
2354 @vindex c-indentation-style
Dave Love <fx@gnu.org>
parents:
diff changeset
2355 @vindex indentation-style (c-)
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2356 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
2357 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
2358 @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
2359 @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
2360 @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
2361 @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
2362 name, as a string.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2363
Dave Love <fx@gnu.org>
parents:
diff changeset
2364
Dave Love <fx@gnu.org>
parents:
diff changeset
2365 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2366 @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
2367 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2368 @subsection Adding Styles
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2369 @cindex adding styles
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2370 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
2371
Dave Love <fx@gnu.org>
parents:
diff changeset
2372 @vindex c-style-alist
Dave Love <fx@gnu.org>
parents:
diff changeset
2373 @vindex style-alist (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
2374 @findex c-add-style
Dave Love <fx@gnu.org>
parents:
diff changeset
2375 @findex add-style (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
2376 If none of the built-in styles is appropriate, you'll probably want to
Dave Love <fx@gnu.org>
parents:
diff changeset
2377 add a new @dfn{style definition}. Styles are kept in the
Dave Love <fx@gnu.org>
parents:
diff changeset
2378 @code{c-style-alist} variable, but you should never modify this variable
Dave Love <fx@gnu.org>
parents:
diff changeset
2379 directly. Instead, @ccmode{} provides the function
Dave Love <fx@gnu.org>
parents:
diff changeset
2380 @code{c-add-style} that you can use to easily add new styles or change
Dave Love <fx@gnu.org>
parents:
diff changeset
2381 existing styles. This function takes two arguments, a @var{stylename}
Dave Love <fx@gnu.org>
parents:
diff changeset
2382 string, and an association list @var{description} of style
Dave Love <fx@gnu.org>
parents:
diff changeset
2383 customizations. If @var{stylename} is not already in
Dave Love <fx@gnu.org>
parents:
diff changeset
2384 @code{c-style-alist}, the new style is added, otherwise the style is
Dave Love <fx@gnu.org>
parents:
diff changeset
2385 changed to the new @var{description}.
Dave Love <fx@gnu.org>
parents:
diff changeset
2386 This function also takes an optional third argument, which if
Dave Love <fx@gnu.org>
parents:
diff changeset
2387 non-@code{nil}, automatically applies the new style to the current
Dave Love <fx@gnu.org>
parents:
diff changeset
2388 buffer.
Dave Love <fx@gnu.org>
parents:
diff changeset
2389
Dave Love <fx@gnu.org>
parents:
diff changeset
2390 @comment TBD: The next paragraph is bogus. I really need to better
Dave Love <fx@gnu.org>
parents:
diff changeset
2391 @comment document adding styles, including setting up inherited styles.
Dave Love <fx@gnu.org>
parents:
diff changeset
2392
Dave Love <fx@gnu.org>
parents:
diff changeset
2393 The sample @file{.emacs} file provides a concrete example of how a new
Dave Love <fx@gnu.org>
parents:
diff changeset
2394 style can be added and automatically set. @xref{Sample .emacs File}.
Dave Love <fx@gnu.org>
parents:
diff changeset
2395
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2396
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2397 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2398 @node File Styles, , Adding Styles, Styles
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2399 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2400 @subsection File Styles
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2401 @cindex file styles
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2402 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
2403
Dave Love <fx@gnu.org>
parents:
diff changeset
2404 @cindex local variables
Dave Love <fx@gnu.org>
parents:
diff changeset
2405
Dave Love <fx@gnu.org>
parents:
diff changeset
2406 The Emacs manual describes how you can customize certain variables on a
Dave Love <fx@gnu.org>
parents:
diff changeset
2407 per-file basis by including a @dfn{Local Variable} block at the end of
Dave Love <fx@gnu.org>
parents:
diff changeset
2408 the file. So far, you've only seen a functional interface to @ccmode{}
Dave Love <fx@gnu.org>
parents:
diff changeset
2409 customization, which is highly inconvenient for use in a Local Variable
Dave Love <fx@gnu.org>
parents:
diff changeset
2410 block. @ccmode{} provides two variables that make it easier for you to
Dave Love <fx@gnu.org>
parents:
diff changeset
2411 customize your style on a per-file basis.
Dave Love <fx@gnu.org>
parents:
diff changeset
2412
Dave Love <fx@gnu.org>
parents:
diff changeset
2413 @vindex c-file-style
Dave Love <fx@gnu.org>
parents:
diff changeset
2414 @vindex file-style (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
2415 @vindex c-file-offsets
Dave Love <fx@gnu.org>
parents:
diff changeset
2416 @vindex file-offsets (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
2417
Dave Love <fx@gnu.org>
parents:
diff changeset
2418 The variable @code{c-file-style} can be set to a style name string.
Dave Love <fx@gnu.org>
parents:
diff changeset
2419 When the file is visited, @ccmode{} will automatically set the
Dave Love <fx@gnu.org>
parents:
diff changeset
2420 file's style to this style using @code{c-set-style}.
Dave Love <fx@gnu.org>
parents:
diff changeset
2421
Dave Love <fx@gnu.org>
parents:
diff changeset
2422 Another variable, @code{c-file-offsets}, takes an association list
Dave Love <fx@gnu.org>
parents:
diff changeset
2423 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
2424 visited, @ccmode{} will automatically institute these offsets using
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2425 @code{c-set-offset}.
Dave Love <fx@gnu.org>
parents:
diff changeset
2426
Dave Love <fx@gnu.org>
parents:
diff changeset
2427 Note that file style settings (i.e. @code{c-file-style}) are applied
Dave Love <fx@gnu.org>
parents:
diff changeset
2428 before file offset settings (i.e. @code{c-file-offsets}). Also, if
Dave Love <fx@gnu.org>
parents:
diff changeset
2429 either of these are set in a file's local variable section, all the
Dave Love <fx@gnu.org>
parents:
diff changeset
2430 style variable values are made local to that buffer.
Dave Love <fx@gnu.org>
parents:
diff changeset
2431
Dave Love <fx@gnu.org>
parents:
diff changeset
2432
Dave Love <fx@gnu.org>
parents:
diff changeset
2433 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2434 @node Advanced Customizations, , Styles, Customizing Indentation
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2435 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2436 @section Advanced Customizations
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2437 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
2438
Dave Love <fx@gnu.org>
parents:
diff changeset
2439 @vindex c-style-alist
Dave Love <fx@gnu.org>
parents:
diff changeset
2440 @vindex style-alist (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
2441 For most users, @ccmode{} will support their coding styles with
Dave Love <fx@gnu.org>
parents:
diff changeset
2442 very little need for more advanced customizations. Usually, one of the
Dave Love <fx@gnu.org>
parents:
diff changeset
2443 standard styles defined in @code{c-style-alist} will do the trick. At
Dave Love <fx@gnu.org>
parents:
diff changeset
2444 most, perhaps one of the syntactic symbol offsets will need to be
Dave Love <fx@gnu.org>
parents:
diff changeset
2445 tweaked slightly, or maybe @code{c-basic-offset} will need to be
Dave Love <fx@gnu.org>
parents:
diff changeset
2446 changed. However, some styles require a more flexible framework for
Dave Love <fx@gnu.org>
parents:
diff changeset
2447 customization, and one of the real strengths of @ccmode{} is that
Dave Love <fx@gnu.org>
parents:
diff changeset
2448 the syntactic analysis model provides just such a framework. This allows
Dave Love <fx@gnu.org>
parents:
diff changeset
2449 you to implement custom indentation calculations for situations not
Dave Love <fx@gnu.org>
parents:
diff changeset
2450 handled by the mode directly.
Dave Love <fx@gnu.org>
parents:
diff changeset
2451
Dave Love <fx@gnu.org>
parents:
diff changeset
2452 @menu
Dave Love <fx@gnu.org>
parents:
diff changeset
2453 * Custom Indentation Functions::
Dave Love <fx@gnu.org>
parents:
diff changeset
2454 * Custom Brace and Colon Hanging::
Dave Love <fx@gnu.org>
parents:
diff changeset
2455 * Customizing Semi-colons and Commas::
Dave Love <fx@gnu.org>
parents:
diff changeset
2456 * Other Special Indentations::
Dave Love <fx@gnu.org>
parents:
diff changeset
2457 @end menu
Dave Love <fx@gnu.org>
parents:
diff changeset
2458
Dave Love <fx@gnu.org>
parents:
diff changeset
2459 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2460 @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
2461 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2462 @subsection Custom Indentation Functions
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2463 @cindex custom indentation functions
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2464 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
2465
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2466 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
2467 indentation functions, and associating them with specific syntactic
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2468 symbols (@pxref{Syntactic Symbols}). @ccmode{} itself uses indentation
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2469 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
2470 lining up C++ stream operator blocks:
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2471 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
2472 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
2473
Dave Love <fx@gnu.org>
parents:
diff changeset
2474 1: void main(int argc, char**)
Dave Love <fx@gnu.org>
parents:
diff changeset
2475 2: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
2476 3: cout << "There were "
Dave Love <fx@gnu.org>
parents:
diff changeset
2477 4: << argc
Dave Love <fx@gnu.org>
parents:
diff changeset
2478 5: << "arguments passed to the program"
Dave Love <fx@gnu.org>
parents:
diff changeset
2479 6: << endl;
Dave Love <fx@gnu.org>
parents:
diff changeset
2480 7: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
2481
Dave Love <fx@gnu.org>
parents:
diff changeset
2482 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
2483 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
2484
Dave Love <fx@gnu.org>
parents:
diff changeset
2485 In this example, lines 4 through 6 are assigned the @code{stream-op}
Dave Love <fx@gnu.org>
parents:
diff changeset
2486 syntactic symbol. Here, @code{stream-op} has an offset of @code{+}, and
Dave Love <fx@gnu.org>
parents:
diff changeset
2487 with a @code{c-basic-offset} of 2, you can see that lines 4 through 6
Dave Love <fx@gnu.org>
parents:
diff changeset
2488 are simply indented two spaces to the right of line 3. But perhaps we'd
Dave Love <fx@gnu.org>
parents:
diff changeset
2489 like @ccmode{} to be a little more intelligent so that it aligns
Dave Love <fx@gnu.org>
parents:
diff changeset
2490 all the @samp{<<} symbols in lines 3 through 6. To do this, we have
Dave Love <fx@gnu.org>
parents:
diff changeset
2491 to write a custom indentation function which finds the column of first
Dave Love <fx@gnu.org>
parents:
diff changeset
2492 stream operator on the first line of the statement. Here is sample
Dave Love <fx@gnu.org>
parents:
diff changeset
2493 lisp code implementing this:
Dave Love <fx@gnu.org>
parents:
diff changeset
2494 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
2495 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
2496
Dave Love <fx@gnu.org>
parents:
diff changeset
2497 (defun c-lineup-streamop (langelem)
Dave Love <fx@gnu.org>
parents:
diff changeset
2498 ;; lineup stream operators
Dave Love <fx@gnu.org>
parents:
diff changeset
2499 (save-excursion
Dave Love <fx@gnu.org>
parents:
diff changeset
2500 (let* ((relpos (cdr langelem))
Dave Love <fx@gnu.org>
parents:
diff changeset
2501 (curcol (progn (goto-char relpos)
Dave Love <fx@gnu.org>
parents:
diff changeset
2502 (current-column))))
Dave Love <fx@gnu.org>
parents:
diff changeset
2503 (re-search-forward "<<\\|>>" (c-point 'eol) 'move)
Dave Love <fx@gnu.org>
parents:
diff changeset
2504 (goto-char (match-beginning 0))
Dave Love <fx@gnu.org>
parents:
diff changeset
2505 (- (current-column) curcol))))
Dave Love <fx@gnu.org>
parents:
diff changeset
2506
Dave Love <fx@gnu.org>
parents:
diff changeset
2507 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
2508 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
2509 @noindent
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2510 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
2511 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
2512 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
2513 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
2514 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
2515 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
2516 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
2517 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
2518 added in twice.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2519
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2520 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
2521 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
2522 expression (@pxref{Customizing Indentation}), that will cause @ccmode{}
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2523 to go on and check the next entry in the list.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2524
Dave Love <fx@gnu.org>
parents:
diff changeset
2525 @cindex stream-op syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
2526 @findex c-lineup-streamop
Dave Love <fx@gnu.org>
parents:
diff changeset
2527 @findex lineup-streamop (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
2528 Now, to associate the function @code{c-lineup-streamop} with the
Dave Love <fx@gnu.org>
parents:
diff changeset
2529 @code{stream-op} syntactic symbol, we can add something like the
Dave Love <fx@gnu.org>
parents:
diff changeset
2530 following to our @code{c++-mode-hook}@footnote{It probably makes more
Dave Love <fx@gnu.org>
parents:
diff changeset
2531 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
2532 since stream operators are only relevant for C++.}:
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2533 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
2534
Dave Love <fx@gnu.org>
parents:
diff changeset
2535 (c-set-offset 'stream-op 'c-lineup-streamop)
Dave Love <fx@gnu.org>
parents:
diff changeset
2536
Dave Love <fx@gnu.org>
parents:
diff changeset
2537 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
2538
Dave Love <fx@gnu.org>
parents:
diff changeset
2539 Now the function looks like this after re-indenting (using @kbd{C-c
Dave Love <fx@gnu.org>
parents:
diff changeset
2540 C-q}):
Dave Love <fx@gnu.org>
parents:
diff changeset
2541 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
2542 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
2543
Dave Love <fx@gnu.org>
parents:
diff changeset
2544 1: void main(int argc, char**)
Dave Love <fx@gnu.org>
parents:
diff changeset
2545 2: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
2546 3: cout << "There were "
Dave Love <fx@gnu.org>
parents:
diff changeset
2547 4: << argc
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2548 5: << " arguments passed to the program"
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2549 6: << endl;
Dave Love <fx@gnu.org>
parents:
diff changeset
2550 7: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
2551
Dave Love <fx@gnu.org>
parents:
diff changeset
2552 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
2553 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
2554
Dave Love <fx@gnu.org>
parents:
diff changeset
2555 Custom indentation functions can be as simple or as complex as you like,
Dave Love <fx@gnu.org>
parents:
diff changeset
2556 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
2557 a custom indentation function associated with it.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2558
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2559 @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
2560 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
2561 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
2562 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
2563 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
2564 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
2565
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2566
Dave Love <fx@gnu.org>
parents:
diff changeset
2567 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2568 @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
2569 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2570 @subsection Custom Brace and Colon Hanging
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2571 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
2572
Dave Love <fx@gnu.org>
parents:
diff changeset
2573 @vindex c-hanging-braces-alist
Dave Love <fx@gnu.org>
parents:
diff changeset
2574 @vindex hanging-braces-alist (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
2575 Syntactic symbols aren't the only place where you can customize
Dave Love <fx@gnu.org>
parents:
diff changeset
2576 @ccmode{} with the lisp equivalent of callback functions. Brace
Dave Love <fx@gnu.org>
parents:
diff changeset
2577 ``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
2578 syntactic symbols on the @code{c-hanging-braces-alist} style variable.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2579 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
2580 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
2581 (@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
2582 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
2583 is entered.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2584
Dave Love <fx@gnu.org>
parents:
diff changeset
2585 @cindex customizing brace hanging
Dave Love <fx@gnu.org>
parents:
diff changeset
2586 These @var{ACTION} functions are called with two arguments: the
Dave Love <fx@gnu.org>
parents:
diff changeset
2587 syntactic symbol for the brace, and the buffer position at which the
Dave Love <fx@gnu.org>
parents:
diff changeset
2588 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
2589 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
2590 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
2591 normal brace hanging semantics.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2592
Dave Love <fx@gnu.org>
parents:
diff changeset
2593 As an example, @ccmode{} itself uses this feature to dynamically
Dave Love <fx@gnu.org>
parents:
diff changeset
2594 determine the hanginess of braces which close ``do-while''
Dave Love <fx@gnu.org>
parents:
diff changeset
2595 constructs:
Dave Love <fx@gnu.org>
parents:
diff changeset
2596 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
2597 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
2598
Dave Love <fx@gnu.org>
parents:
diff changeset
2599 void do_list( int count, char** atleast_one_string )
Dave Love <fx@gnu.org>
parents:
diff changeset
2600 @{
Dave Love <fx@gnu.org>
parents:
diff changeset
2601 int i=0;
Dave Love <fx@gnu.org>
parents:
diff changeset
2602 do @{
Dave Love <fx@gnu.org>
parents:
diff changeset
2603 handle_string( atleast_one_string[i] );
Dave Love <fx@gnu.org>
parents:
diff changeset
2604 i++;
Dave Love <fx@gnu.org>
parents:
diff changeset
2605 @} while( i < count );
Dave Love <fx@gnu.org>
parents:
diff changeset
2606 @}
Dave Love <fx@gnu.org>
parents:
diff changeset
2607
Dave Love <fx@gnu.org>
parents:
diff changeset
2608 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
2609 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
2610
Dave Love <fx@gnu.org>
parents:
diff changeset
2611 @findex c-snug-do-while
Dave Love <fx@gnu.org>
parents:
diff changeset
2612 @findex snug-do-while (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
2613 @ccmode{} assigns the @code{block-close} syntactic symbol to the
Dave Love <fx@gnu.org>
parents:
diff changeset
2614 brace that closes the @code{do} construct, and normally we'd like the
Dave Love <fx@gnu.org>
parents:
diff changeset
2615 line that follows a @code{block-close} brace to begin on a separate
Dave Love <fx@gnu.org>
parents:
diff changeset
2616 line. However, with ``do-while'' constructs, we want the
Dave Love <fx@gnu.org>
parents:
diff changeset
2617 @code{while} clause to follow the closing brace. To do this, we
Dave Love <fx@gnu.org>
parents:
diff changeset
2618 associate the @code{block-close} symbol with the @var{ACTION} function
Dave Love <fx@gnu.org>
parents:
diff changeset
2619 @code{c-snug-do-while}:
Dave Love <fx@gnu.org>
parents:
diff changeset
2620 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
2621
Dave Love <fx@gnu.org>
parents:
diff changeset
2622 (defun c-snug-do-while (syntax pos)
Dave Love <fx@gnu.org>
parents:
diff changeset
2623 "Dynamically calculate brace hanginess for do-while statements.
Dave Love <fx@gnu.org>
parents:
diff changeset
2624 Using this function, `while' clauses that end a `do-while' block will
Dave Love <fx@gnu.org>
parents:
diff changeset
2625 remain on the same line as the brace that closes that block.
Dave Love <fx@gnu.org>
parents:
diff changeset
2626
Dave Love <fx@gnu.org>
parents:
diff changeset
2627 See `c-hanging-braces-alist' for how to utilize this function as an
Dave Love <fx@gnu.org>
parents:
diff changeset
2628 ACTION associated with `block-close' syntax."
Dave Love <fx@gnu.org>
parents:
diff changeset
2629 (save-excursion
Dave Love <fx@gnu.org>
parents:
diff changeset
2630 (let (langelem)
Dave Love <fx@gnu.org>
parents:
diff changeset
2631 (if (and (eq syntax 'block-close)
Dave Love <fx@gnu.org>
parents:
diff changeset
2632 (setq langelem (assq 'block-close c-syntactic-context))
Dave Love <fx@gnu.org>
parents:
diff changeset
2633 (progn (goto-char (cdr langelem))
Dave Love <fx@gnu.org>
parents:
diff changeset
2634 (if (= (following-char) ?@{)
Dave Love <fx@gnu.org>
parents:
diff changeset
2635 (forward-sexp -1))
Dave Love <fx@gnu.org>
parents:
diff changeset
2636 (looking-at "\\<do\\>[^_]")))
Dave Love <fx@gnu.org>
parents:
diff changeset
2637 '(before)
Dave Love <fx@gnu.org>
parents:
diff changeset
2638 '(before after)))))
Dave Love <fx@gnu.org>
parents:
diff changeset
2639
Dave Love <fx@gnu.org>
parents:
diff changeset
2640 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
2641
Dave Love <fx@gnu.org>
parents:
diff changeset
2642 This function simply looks to see if the brace closes a ``do-while''
Dave Love <fx@gnu.org>
parents:
diff changeset
2643 clause and if so, returns the list @samp{(before)} indicating
Dave Love <fx@gnu.org>
parents:
diff changeset
2644 that a newline should be inserted before the brace, but not after it.
Dave Love <fx@gnu.org>
parents:
diff changeset
2645 In all other cases, it returns the list @samp{(before after)} so
Dave Love <fx@gnu.org>
parents:
diff changeset
2646 that the brace appears on a line by itself.
Dave Love <fx@gnu.org>
parents:
diff changeset
2647
Dave Love <fx@gnu.org>
parents:
diff changeset
2648 @vindex c-syntactic-context
Dave Love <fx@gnu.org>
parents:
diff changeset
2649 @vindex syntactic-context (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
2650 During the call to the brace hanging @var{ACTION} function, the variable
Dave Love <fx@gnu.org>
parents:
diff changeset
2651 @code{c-syntactic-context} is bound to the full syntactic analysis list.
Dave Love <fx@gnu.org>
parents:
diff changeset
2652
Dave Love <fx@gnu.org>
parents:
diff changeset
2653 @cindex customizing colon hanging
Dave Love <fx@gnu.org>
parents:
diff changeset
2654 @vindex c-hanging-colon-alist
Dave Love <fx@gnu.org>
parents:
diff changeset
2655 @vindex hanging-colon-alist (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
2656 Note that for symmetry, colon hanginess should be customizable by
Dave Love <fx@gnu.org>
parents:
diff changeset
2657 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
2658 @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
2659 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
2660
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2661
Dave Love <fx@gnu.org>
parents:
diff changeset
2662 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2663 @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
2664 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2665 @subsection Customizing Semi-colons and Commas
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2666 @cindex customizing semi-colons and commas
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2667 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
2668
Dave Love <fx@gnu.org>
parents:
diff changeset
2669 @vindex c-hanging-semi&comma-criteria
Dave Love <fx@gnu.org>
parents:
diff changeset
2670 @vindex hanging-semi&comma-criteria (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
2671 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
2672 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
2673 Modes}). This is controlled by the style variable
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2674 @code{c-hanging-semi&comma-criteria}, which contains a list of functions
Dave Love <fx@gnu.org>
parents:
diff changeset
2675 that are called in the order they appear. Each function is called with
Dave Love <fx@gnu.org>
parents:
diff changeset
2676 zero arguments, and is expected to return one of the following values:
Dave Love <fx@gnu.org>
parents:
diff changeset
2677
Dave Love <fx@gnu.org>
parents:
diff changeset
2678 @itemize @bullet
Dave Love <fx@gnu.org>
parents:
diff changeset
2679 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
2680 non-@code{nil} --- A newline is inserted, and no more functions from the
Dave Love <fx@gnu.org>
parents:
diff changeset
2681 list are called.
Dave Love <fx@gnu.org>
parents:
diff changeset
2682
Dave Love <fx@gnu.org>
parents:
diff changeset
2683 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
2684 @code{stop} --- No more functions from the list are called, but no
Dave Love <fx@gnu.org>
parents:
diff changeset
2685 newline is inserted.
Dave Love <fx@gnu.org>
parents:
diff changeset
2686
Dave Love <fx@gnu.org>
parents:
diff changeset
2687 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
2688 @code{nil} --- No determination is made, and the next function in the
Dave Love <fx@gnu.org>
parents:
diff changeset
2689 list is called.
Dave Love <fx@gnu.org>
parents:
diff changeset
2690
Dave Love <fx@gnu.org>
parents:
diff changeset
2691 @end itemize
Dave Love <fx@gnu.org>
parents:
diff changeset
2692
Dave Love <fx@gnu.org>
parents:
diff changeset
2693 If every function in the list is called without a determination being
Dave Love <fx@gnu.org>
parents:
diff changeset
2694 made, then no newline is added. The default value for this variable is a
Dave Love <fx@gnu.org>
parents:
diff changeset
2695 list containing a single function which inserts newlines only after
Dave Love <fx@gnu.org>
parents:
diff changeset
2696 semi-colons which do not appear inside parenthesis lists (i.e. those
Dave Love <fx@gnu.org>
parents:
diff changeset
2697 that separate @code{for}-clause statements).
Dave Love <fx@gnu.org>
parents:
diff changeset
2698
Dave Love <fx@gnu.org>
parents:
diff changeset
2699 @findex c-semi&comma-no-newlines-before-nonblanks
Dave Love <fx@gnu.org>
parents:
diff changeset
2700 @findex semi&comma-no-newlines-before-nonblanks (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
2701 Here's an example of a criteria function, provided by @ccmode{}, that
Dave Love <fx@gnu.org>
parents:
diff changeset
2702 will prevent newlines from being inserted after semicolons when there is
Dave Love <fx@gnu.org>
parents:
diff changeset
2703 a non-blank following line. Otherwise, it makes no determination. To
Dave Love <fx@gnu.org>
parents:
diff changeset
2704 use, add this to the front of the @code{c-hanging-semi&comma-criteria}
Dave Love <fx@gnu.org>
parents:
diff changeset
2705 list.
Dave Love <fx@gnu.org>
parents:
diff changeset
2706
Dave Love <fx@gnu.org>
parents:
diff changeset
2707 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
2708 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
2709
Dave Love <fx@gnu.org>
parents:
diff changeset
2710 (defun c-semi&comma-no-newlines-before-nonblanks ()
Dave Love <fx@gnu.org>
parents:
diff changeset
2711 (save-excursion
Dave Love <fx@gnu.org>
parents:
diff changeset
2712 (if (and (eq last-command-char ?\;)
Dave Love <fx@gnu.org>
parents:
diff changeset
2713 (zerop (forward-line 1))
Dave Love <fx@gnu.org>
parents:
diff changeset
2714 (not (looking-at "^[ \t]*$")))
Dave Love <fx@gnu.org>
parents:
diff changeset
2715 'stop
Dave Love <fx@gnu.org>
parents:
diff changeset
2716 nil)))
Dave Love <fx@gnu.org>
parents:
diff changeset
2717
Dave Love <fx@gnu.org>
parents:
diff changeset
2718 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
2719 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
2720
Dave Love <fx@gnu.org>
parents:
diff changeset
2721 @findex c-semi&comma-inside-parenlist
Dave Love <fx@gnu.org>
parents:
diff changeset
2722 @findex c-semi&comma-no-newlines-for-oneline-inliners
Dave Love <fx@gnu.org>
parents:
diff changeset
2723 @findex semi&comma-inside-parenlist (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
2724 @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
2725 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
2726 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
2727 statements. In addition to
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2728 @code{c-semi&comma-no-newlines-before-nonblanks} described above,
Dave Love <fx@gnu.org>
parents:
diff changeset
2729 @ccmode{} also comes with the criteria function
Dave Love <fx@gnu.org>
parents:
diff changeset
2730 @code{c-semi&comma-no-newlines-for-oneline-inliners}, which suppresses
Dave Love <fx@gnu.org>
parents:
diff changeset
2731 newlines after semicolons inside one-line inline method definitions
Dave Love <fx@gnu.org>
parents:
diff changeset
2732 (i.e. in C++ or Java).
Dave Love <fx@gnu.org>
parents:
diff changeset
2733
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2734
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2735 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2736 @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
2737 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2738 @subsection Other Special Indentations
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2739 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
2740
Dave Love <fx@gnu.org>
parents:
diff changeset
2741 @vindex c-label-minimum-indentation
Dave Love <fx@gnu.org>
parents:
diff changeset
2742 @vindex label-minimum-indentation (c-)
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2743 In @samp{gnu} style (@pxref{Built-in Styles}), a minimum indentation
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2744 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
2745 indentation is controlled by the style variable
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2746 @code{c-label-minimum-indentation}. The default value for this variable
Dave Love <fx@gnu.org>
parents:
diff changeset
2747 is 1.
Dave Love <fx@gnu.org>
parents:
diff changeset
2748
Dave Love <fx@gnu.org>
parents:
diff changeset
2749 @vindex c-special-indent-hook
Dave Love <fx@gnu.org>
parents:
diff changeset
2750 @vindex special-indent-hook (c-)
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2751 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
2752 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
2753 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
2754 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
2755 dictates, such as adding extra indentation to constructors or destructor
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2756 declarations in a class definition, etc. Note however, that you should
Dave Love <fx@gnu.org>
parents:
diff changeset
2757 not change point or mark inside your @code{c-special-indent-hook}
Dave Love <fx@gnu.org>
parents:
diff changeset
2758 functions (i.e. you'll probably want to wrap your function in a
Dave Love <fx@gnu.org>
parents:
diff changeset
2759 @code{save-excursion}).
Dave Love <fx@gnu.org>
parents:
diff changeset
2760
Dave Love <fx@gnu.org>
parents:
diff changeset
2761 Setting @code{c-special-indent-hook} in your style definition is handled
Dave Love <fx@gnu.org>
parents:
diff changeset
2762 slightly differently than other variables. In your style definition,
Dave Love <fx@gnu.org>
parents:
diff changeset
2763 you should set the value for
Dave Love <fx@gnu.org>
parents:
diff changeset
2764 @code{c-special-indent-hook} to a function or list of functions, which
Dave Love <fx@gnu.org>
parents:
diff changeset
2765 will be appended to @code{c-special-indent-hook} using @code{add-hook}.
Dave Love <fx@gnu.org>
parents:
diff changeset
2766 That way, the current setting for the buffer local value of
Dave Love <fx@gnu.org>
parents:
diff changeset
2767 @code{c-special-indent-hook} won't be overridden.
Dave Love <fx@gnu.org>
parents:
diff changeset
2768
Dave Love <fx@gnu.org>
parents:
diff changeset
2769 @kindex M-;
Dave Love <fx@gnu.org>
parents:
diff changeset
2770 @findex indent-for-comment
Dave Love <fx@gnu.org>
parents:
diff changeset
2771 @vindex c-indent-comments-syntactically-p
Dave Love <fx@gnu.org>
parents:
diff changeset
2772 @vindex indent-comments-syntactically-p (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
2773 @vindex comment-column
Dave Love <fx@gnu.org>
parents:
diff changeset
2774 Normally, the standard Emacs command @kbd{M-;}
Dave Love <fx@gnu.org>
parents:
diff changeset
2775 (@code{indent-for-comment}) will indent comment only lines to
Dave Love <fx@gnu.org>
parents:
diff changeset
2776 @code{comment-column}. Some users however, prefer that @kbd{M-;} act
Dave Love <fx@gnu.org>
parents:
diff changeset
2777 just like @kbd{TAB} for purposes of indenting comment-only lines;
Dave Love <fx@gnu.org>
parents:
diff changeset
2778 i.e. they want the comments to always indent as they would for normal
Dave Love <fx@gnu.org>
parents:
diff changeset
2779 code, regardless of whether @kbd{TAB} or @kbd{M-;} were used. This
Dave Love <fx@gnu.org>
parents:
diff changeset
2780 behavior is controlled by the variable
Dave Love <fx@gnu.org>
parents:
diff changeset
2781 @code{c-indent-comments-syntactically-p}. When @code{nil} (the
Dave Love <fx@gnu.org>
parents:
diff changeset
2782 default), @kbd{M-;} indents comment-only lines to @code{comment-column},
Dave Love <fx@gnu.org>
parents:
diff changeset
2783 otherwise, they are indented just as they would be if @kbd{TAB} were
Dave Love <fx@gnu.org>
parents:
diff changeset
2784 typed.
Dave Love <fx@gnu.org>
parents:
diff changeset
2785
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2786 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
2787 @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
2788 start at @code{comment-column}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2789
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2790
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2791 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2792 @node Syntactic Symbols, Indentation Functions, Customizing Indentation, Top
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2793 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2794 @chapter Syntactic Symbols
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2795 @cindex syntactic symbols
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2796 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
2797
Dave Love <fx@gnu.org>
parents:
diff changeset
2798 @vindex c-offsets-alist
Dave Love <fx@gnu.org>
parents:
diff changeset
2799 @vindex offsets-alist (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
2800 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
2801 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
2802 description. More detailed descriptions follow.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2803
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2804 @table @code
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2805 @item string
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2806 Inside a multi-line string.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2807 @item c
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2808 Inside a multi-line C style block comment.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2809 @item defun-open
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2810 Brace that opens a top-level function definition.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2811 @item defun-close
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2812 Brace that closes a top-level function definition.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2813 @item defun-block-intro
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2814 The first line in a top-level defun.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2815 @item class-open
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2816 Brace that opens a class definition.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2817 @item class-close
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2818 Brace that closes a class definition.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2819 @item inline-open
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2820 Brace that opens an in-class inline method.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2821 @item inline-close
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2822 Brace that closes an in-class inline method.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2823 @item func-decl-cont
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2824 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
2825 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
2826 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
2827 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
2828 here.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2829 @item knr-argdecl-intro
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2830 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
2831 @item knr-argdecl
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2832 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
2833 @item topmost-intro
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2834 The first line in a ``topmost'' definition.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2835 @item topmost-intro-cont
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2836 Topmost definition continuation lines.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2837 @item member-init-intro
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2838 First line in a member initialization list.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2839 @item member-init-cont
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2840 Subsequent member initialization list lines.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2841 @item inher-intro
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2842 First line of a multiple inheritance list.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2843 @item inher-cont
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2844 Subsequent multiple inheritance lines.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2845 @item block-open
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2846 Statement block open brace.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2847 @item block-close
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2848 Statement block close brace.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2849 @item brace-list-open
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2850 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
2851 @item brace-list-close
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2852 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
2853 @item brace-list-intro
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2854 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
2855 @item brace-list-entry
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2856 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
2857 @item brace-entry-open
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2858 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
2859 with an open brace.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2860 @item statement
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2861 A statement.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2862 @item statement-cont
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2863 A continuation of a statement.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2864 @item statement-block-intro
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2865 The first line in a new statement block.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2866 @item statement-case-intro
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2867 The first line in a case block.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2868 @item statement-case-open
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2869 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
2870 @item substatement
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2871 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
2872 @item substatement-open
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2873 The brace that opens a substatement block.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2874 @item case-label
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2875 A @code{case} or @code{default} label.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2876 @item access-label
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2877 C++ access control label.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2878 @item label
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2879 Any non-special C label.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2880 @item do-while-closure
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2881 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
2882 @item else-clause
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2883 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
2884 @item catch-clause
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2885 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
2886 @code{try}-@code{catch} construct.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2887 @item comment-intro
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2888 A line containing only a comment introduction.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2889 @item arglist-intro
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2890 The first line in an argument list.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2891 @item arglist-cont
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2892 Subsequent argument list lines when no arguments follow on the same line
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2893 as the the arglist opening paren.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2894 @item arglist-cont-nonempty
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2895 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
2896 same line as the arglist opening paren.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2897 @item arglist-close
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2898 The solo close paren of an argument list.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2899 @item stream-op
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2900 Lines continuing a stream operator (C++ only).
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2901 @item inclass
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2902 The line is nested inside a class definition.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2903 @item cpp-macro
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2904 The start of a C preprocessor macro definition.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2905 @item cpp-macro-cont
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2906 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
2907 @item friend
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2908 A C++ friend declaration.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2909 @item objc-method-intro
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2910 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
2911 @item objc-method-args-cont
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2912 Lines continuing an Objective-C method. definition
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2913 @item objc-method-call-cont
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2914 Lines continuing an Objective-C method call.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2915 @item extern-lang-open
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2916 Brace that opens an external language block.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2917 @item extern-lang-close
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2918 Brace that closes an external language block.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2919 @item inextern-lang
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2920 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
2921 language blocks (e.g. @code{extern "C" @{}).
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2922 @item namespace-open
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2923 Brace that opens a C++ namespace block.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2924 @item namespace-close
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2925 Brace that closes a C++ namespace block.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2926 @item innamespace
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2927 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
2928 namespace blocks.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2929 @item template-args-cont
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2930 C++ template argument list continuations.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2931 @item inlambda
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2932 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
2933 (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
2934 @item lambda-intro-cont
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2935 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
2936 @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
2937 @item inexpr-statement
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2938 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
2939 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
2940 statement block as an argument in Pike.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2941 @item inexpr-class
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2942 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
2943 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
2944 Java.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
2945 @end table
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2946
Dave Love <fx@gnu.org>
parents:
diff changeset
2947 @cindex -open syntactic symbols
Dave Love <fx@gnu.org>
parents:
diff changeset
2948 @cindex -close syntactic symbols
Dave Love <fx@gnu.org>
parents:
diff changeset
2949 Most syntactic symbol names follow a general naming convention. When a
Dave Love <fx@gnu.org>
parents:
diff changeset
2950 line begins with an open or close brace, the syntactic symbol will
Dave Love <fx@gnu.org>
parents:
diff changeset
2951 contain the suffix @code{-open} or @code{-close} respectively.
Dave Love <fx@gnu.org>
parents:
diff changeset
2952
Dave Love <fx@gnu.org>
parents:
diff changeset
2953 @cindex -intro syntactic symbols
Dave Love <fx@gnu.org>
parents:
diff changeset
2954 @cindex -cont syntactic symbols
Dave Love <fx@gnu.org>
parents:
diff changeset
2955 @cindex -block-intro syntactic symbols
Dave Love <fx@gnu.org>
parents:
diff changeset
2956 Usually, a distinction is made between the first line that introduces a
Dave Love <fx@gnu.org>
parents:
diff changeset
2957 construct and lines that continue a construct, and the syntactic symbols
Dave Love <fx@gnu.org>
parents:
diff changeset
2958 that represent these lines will contain the suffix @code{-intro} or
Dave Love <fx@gnu.org>
parents:
diff changeset
2959 @code{-cont} respectively. As a sub-classification of this scheme, a
Dave Love <fx@gnu.org>
parents:
diff changeset
2960 line which is the first of a particular brace block construct will
Dave Love <fx@gnu.org>
parents:
diff changeset
2961 contain the suffix @code{-block-intro}.
Dave Love <fx@gnu.org>
parents:
diff changeset
2962
Dave Love <fx@gnu.org>
parents:
diff changeset
2963 Let's look at some examples to understand how this works. Remember that
Dave Love <fx@gnu.org>
parents:
diff changeset
2964 you can check the syntax of any line by using @kbd{C-c C-s}.
Dave Love <fx@gnu.org>
parents:
diff changeset
2965 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
2966 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
2967
Dave Love <fx@gnu.org>
parents:
diff changeset
2968 1: void
Dave Love <fx@gnu.org>
parents:
diff changeset
2969 2: swap( int& a, int& b )
Dave Love <fx@gnu.org>
parents:
diff changeset
2970 3: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
2971 4: int tmp = a;
Dave Love <fx@gnu.org>
parents:
diff changeset
2972 5: a = b;
Dave Love <fx@gnu.org>
parents:
diff changeset
2973 6: b = tmp;
Dave Love <fx@gnu.org>
parents:
diff changeset
2974 7: int ignored =
Dave Love <fx@gnu.org>
parents:
diff changeset
2975 8: a + b;
Dave Love <fx@gnu.org>
parents:
diff changeset
2976 9: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
2977
Dave Love <fx@gnu.org>
parents:
diff changeset
2978 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
2979 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
2980
Dave Love <fx@gnu.org>
parents:
diff changeset
2981 @cindex topmost-intro syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
2982 @cindex topmost-intro-cont syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
2983 @cindex defun-open syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
2984 @cindex defun-close syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
2985 @cindex defun-block-intro syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
2986 Line 1 shows a @code{topmost-intro} since it is the first line that
Dave Love <fx@gnu.org>
parents:
diff changeset
2987 introduces a top-level construct. Line 2 is a continuation of the
Dave Love <fx@gnu.org>
parents:
diff changeset
2988 top-level construct introduction so it has the syntax
Dave Love <fx@gnu.org>
parents:
diff changeset
2989 @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
2990 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
2991 corresponding
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
2992 @code{defun-close} since it contains the brace that closes the top-level
Dave Love <fx@gnu.org>
parents:
diff changeset
2993 function definition. Line 4 is a @code{defun-block-intro}, i.e. it is
Dave Love <fx@gnu.org>
parents:
diff changeset
2994 the first line of a brace-block, enclosed in a
Dave Love <fx@gnu.org>
parents:
diff changeset
2995 top-level function definition.
Dave Love <fx@gnu.org>
parents:
diff changeset
2996
Dave Love <fx@gnu.org>
parents:
diff changeset
2997 @cindex statement syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
2998 @cindex statement-cont syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
2999 Lines 5, 6, and 7 are all given @code{statement} syntax since there
Dave Love <fx@gnu.org>
parents:
diff changeset
3000 isn't much special about them. Note however that line 8 is given
Dave Love <fx@gnu.org>
parents:
diff changeset
3001 @code{statement-cont} syntax since it continues the statement begun
Dave Love <fx@gnu.org>
parents:
diff changeset
3002 on the previous line.
Dave Love <fx@gnu.org>
parents:
diff changeset
3003
Dave Love <fx@gnu.org>
parents:
diff changeset
3004 Here's another example, which illustrates some C++ class syntactic
Dave Love <fx@gnu.org>
parents:
diff changeset
3005 symbols:
Dave Love <fx@gnu.org>
parents:
diff changeset
3006 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
3007 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
3008
Dave Love <fx@gnu.org>
parents:
diff changeset
3009 1: class Bass
Dave Love <fx@gnu.org>
parents:
diff changeset
3010 2: : public Guitar,
Dave Love <fx@gnu.org>
parents:
diff changeset
3011 3: public Amplifiable
Dave Love <fx@gnu.org>
parents:
diff changeset
3012 4: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
3013 5: public:
Dave Love <fx@gnu.org>
parents:
diff changeset
3014 6: Bass()
Dave Love <fx@gnu.org>
parents:
diff changeset
3015 7: : eString( new BassString( 0.105 )),
Dave Love <fx@gnu.org>
parents:
diff changeset
3016 8: aString( new BassString( 0.085 )),
Dave Love <fx@gnu.org>
parents:
diff changeset
3017 9: dString( new BassString( 0.065 )),
Dave Love <fx@gnu.org>
parents:
diff changeset
3018 10: gString( new BassString( 0.045 ))
Dave Love <fx@gnu.org>
parents:
diff changeset
3019 11: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
3020 12: eString.tune( 'E' );
Dave Love <fx@gnu.org>
parents:
diff changeset
3021 13: aString.tune( 'A' );
Dave Love <fx@gnu.org>
parents:
diff changeset
3022 14: dString.tune( 'D' );
Dave Love <fx@gnu.org>
parents:
diff changeset
3023 15: gString.tune( 'G' );
Dave Love <fx@gnu.org>
parents:
diff changeset
3024 16: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
3025 17: friend class Luthier;
Dave Love <fx@gnu.org>
parents:
diff changeset
3026 18: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
3027
Dave Love <fx@gnu.org>
parents:
diff changeset
3028 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
3029 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
3030
Dave Love <fx@gnu.org>
parents:
diff changeset
3031 @cindex class-open syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3032 @cindex class-close syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3033 As in the previous example, line 1 has the @code{topmost-intro} syntax.
Dave Love <fx@gnu.org>
parents:
diff changeset
3034 Here however, the brace that opens a C++ class definition on line 4 is
Dave Love <fx@gnu.org>
parents:
diff changeset
3035 assigned the @code{class-open} syntax. Note that in C++, classes,
Dave Love <fx@gnu.org>
parents:
diff changeset
3036 structs, and unions are essentially equivalent syntactically (and are
Dave Love <fx@gnu.org>
parents:
diff changeset
3037 very similar semantically), so replacing the @code{class} keyword in the
Dave Love <fx@gnu.org>
parents:
diff changeset
3038 example above with @code{struct} or @code{union} would still result in a
Dave Love <fx@gnu.org>
parents:
diff changeset
3039 syntax of @code{class-open} for line 4 @footnote{This is the case even
Dave Love <fx@gnu.org>
parents:
diff changeset
3040 for C and Objective-C. For consistency, structs in all supported
Dave Love <fx@gnu.org>
parents:
diff changeset
3041 languages are syntactically equivalent to classes. Note however that
Dave Love <fx@gnu.org>
parents:
diff changeset
3042 the keyword @code{class} is meaningless in C and Objective-C.}.
Dave Love <fx@gnu.org>
parents:
diff changeset
3043 Similarly, line 18 is assigned @code{class-close} syntax.
Dave Love <fx@gnu.org>
parents:
diff changeset
3044
Dave Love <fx@gnu.org>
parents:
diff changeset
3045 @cindex inher-intro syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3046 @cindex inher-cont syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3047 Line 2 introduces the inheritance list for the class so it is assigned
Dave Love <fx@gnu.org>
parents:
diff changeset
3048 the @code{inher-intro} syntax, and line 3, which continues the
Dave Love <fx@gnu.org>
parents:
diff changeset
3049 inheritance list is given @code{inher-cont} syntax.
Dave Love <fx@gnu.org>
parents:
diff changeset
3050
Dave Love <fx@gnu.org>
parents:
diff changeset
3051 @cindex access-label syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3052 @cindex inclass syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3053 Hitting @kbd{C-c C-s} on line 5 shows the following analysis:
Dave Love <fx@gnu.org>
parents:
diff changeset
3054
Dave Love <fx@gnu.org>
parents:
diff changeset
3055 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
3056 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
3057
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3058 @code{((inclass . 58) (access-label . 67))}
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
3059
Dave Love <fx@gnu.org>
parents:
diff changeset
3060 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
3061 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
3062
Dave Love <fx@gnu.org>
parents:
diff changeset
3063 @noindent
Dave Love <fx@gnu.org>
parents:
diff changeset
3064 The primary syntactic symbol for this line is @code{access-label} as
Dave Love <fx@gnu.org>
parents:
diff changeset
3065 this a label keyword that specifies access protection in C++. However,
Dave Love <fx@gnu.org>
parents:
diff changeset
3066 because this line is also a top-level construct inside a class
Dave Love <fx@gnu.org>
parents:
diff changeset
3067 definition, the analysis actually shows two syntactic symbols. The
Dave Love <fx@gnu.org>
parents:
diff changeset
3068 other syntactic symbol assigned to this line is @code{inclass}.
Dave Love <fx@gnu.org>
parents:
diff changeset
3069 Similarly, line 6 is given both @code{inclass} and @code{topmost-intro}
Dave Love <fx@gnu.org>
parents:
diff changeset
3070 syntax:
Dave Love <fx@gnu.org>
parents:
diff changeset
3071
Dave Love <fx@gnu.org>
parents:
diff changeset
3072 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
3073 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
3074
Dave Love <fx@gnu.org>
parents:
diff changeset
3075 @code{((inclass . 58) (topmost-intro . 60))}
Dave Love <fx@gnu.org>
parents:
diff changeset
3076
Dave Love <fx@gnu.org>
parents:
diff changeset
3077 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
3078 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
3079
Dave Love <fx@gnu.org>
parents:
diff changeset
3080 @cindex member-init-intro syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3081 @cindex member-init-cont syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3082 Line 7 introduces a C++ member initialization list and as such is given
Dave Love <fx@gnu.org>
parents:
diff changeset
3083 @code{member-init-intro} syntax. Note that in this case it is
Dave Love <fx@gnu.org>
parents:
diff changeset
3084 @emph{not} assigned @code{inclass} since this is not considered a
Dave Love <fx@gnu.org>
parents:
diff changeset
3085 top-level construct. Lines 8 through 10 are all assigned
Dave Love <fx@gnu.org>
parents:
diff changeset
3086 @code{member-init-cont} since they continue the member initialization
Dave Love <fx@gnu.org>
parents:
diff changeset
3087 list started on line 7.
Dave Love <fx@gnu.org>
parents:
diff changeset
3088
Dave Love <fx@gnu.org>
parents:
diff changeset
3089 @cindex in-class inline methods
Dave Love <fx@gnu.org>
parents:
diff changeset
3090 @cindex inline-open syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3091 @cindex inline-close syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3092 Line 11's analysis is a bit more complicated:
Dave Love <fx@gnu.org>
parents:
diff changeset
3093
Dave Love <fx@gnu.org>
parents:
diff changeset
3094 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
3095 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
3096
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3097 @code{((inclass . 58) (inline-open))}
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
3098
Dave Love <fx@gnu.org>
parents:
diff changeset
3099 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
3100 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
3101
Dave Love <fx@gnu.org>
parents:
diff changeset
3102 This line is assigned a syntax of both @code{inline-open} and
Dave Love <fx@gnu.org>
parents:
diff changeset
3103 @code{inclass} because it opens an @dfn{in-class} C++ inline method
Dave Love <fx@gnu.org>
parents:
diff changeset
3104 definition. This is distinct from, but related to, the C++ notion of an
Dave Love <fx@gnu.org>
parents:
diff changeset
3105 inline function in that its definition occurs inside an enclosing class
Dave Love <fx@gnu.org>
parents:
diff changeset
3106 definition, which in C++ implies that the function should be inlined.
Dave Love <fx@gnu.org>
parents:
diff changeset
3107 If though, the definition of the @code{Bass} constructor appeared
Dave Love <fx@gnu.org>
parents:
diff changeset
3108 outside the class definition, the construct would be given the
Dave Love <fx@gnu.org>
parents:
diff changeset
3109 @code{defun-open} syntax, even if the keyword @code{inline} appeared
Dave Love <fx@gnu.org>
parents:
diff changeset
3110 before the method name, as in:
Dave Love <fx@gnu.org>
parents:
diff changeset
3111 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
3112 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
3113
Dave Love <fx@gnu.org>
parents:
diff changeset
3114 class Bass
Dave Love <fx@gnu.org>
parents:
diff changeset
3115 : public Guitar,
Dave Love <fx@gnu.org>
parents:
diff changeset
3116 public Amplifiable
Dave Love <fx@gnu.org>
parents:
diff changeset
3117 @{
Dave Love <fx@gnu.org>
parents:
diff changeset
3118 public:
Dave Love <fx@gnu.org>
parents:
diff changeset
3119 Bass();
Dave Love <fx@gnu.org>
parents:
diff changeset
3120 @}
Dave Love <fx@gnu.org>
parents:
diff changeset
3121
Dave Love <fx@gnu.org>
parents:
diff changeset
3122 inline
Dave Love <fx@gnu.org>
parents:
diff changeset
3123 Bass::Bass()
Dave Love <fx@gnu.org>
parents:
diff changeset
3124 : eString( new BassString( 0.105 )),
Dave Love <fx@gnu.org>
parents:
diff changeset
3125 aString( new BassString( 0.085 )),
Dave Love <fx@gnu.org>
parents:
diff changeset
3126 dString( new BassString( 0.065 )),
Dave Love <fx@gnu.org>
parents:
diff changeset
3127 gString( new BassString( 0.045 ))
Dave Love <fx@gnu.org>
parents:
diff changeset
3128 @{
Dave Love <fx@gnu.org>
parents:
diff changeset
3129 eString.tune( 'E' );
Dave Love <fx@gnu.org>
parents:
diff changeset
3130 aString.tune( 'A' );
Dave Love <fx@gnu.org>
parents:
diff changeset
3131 dString.tune( 'D' );
Dave Love <fx@gnu.org>
parents:
diff changeset
3132 gString.tune( 'G' );
Dave Love <fx@gnu.org>
parents:
diff changeset
3133 @}
Dave Love <fx@gnu.org>
parents:
diff changeset
3134
Dave Love <fx@gnu.org>
parents:
diff changeset
3135 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
3136 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
3137
Dave Love <fx@gnu.org>
parents:
diff changeset
3138 @cindex friend syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3139 Returning to the previous example, line 16 is given @code{inline-close}
Dave Love <fx@gnu.org>
parents:
diff changeset
3140 syntax, while line 12 is given @code{defun-block-open} syntax, and lines
Dave Love <fx@gnu.org>
parents:
diff changeset
3141 13 through 15 are all given @code{statement} syntax. Line 17 is
Dave Love <fx@gnu.org>
parents:
diff changeset
3142 interesting in that its syntactic analysis list contains three
Dave Love <fx@gnu.org>
parents:
diff changeset
3143 elements:
Dave Love <fx@gnu.org>
parents:
diff changeset
3144
Dave Love <fx@gnu.org>
parents:
diff changeset
3145 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
3146
Dave Love <fx@gnu.org>
parents:
diff changeset
3147 @code{((friend) (inclass . 58) (topmost-intro . 380))}
Dave Love <fx@gnu.org>
parents:
diff changeset
3148
Dave Love <fx@gnu.org>
parents:
diff changeset
3149 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
3150
Dave Love <fx@gnu.org>
parents:
diff changeset
3151 The @code{friend} syntactic symbol is a modifier that typically does not
Dave Love <fx@gnu.org>
parents:
diff changeset
3152 have a relative buffer position.
Dave Love <fx@gnu.org>
parents:
diff changeset
3153
Dave Love <fx@gnu.org>
parents:
diff changeset
3154 Template definitions introduce yet another syntactic symbol:
Dave Love <fx@gnu.org>
parents:
diff changeset
3155
Dave Love <fx@gnu.org>
parents:
diff changeset
3156 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
3157 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
3158
Dave Love <fx@gnu.org>
parents:
diff changeset
3159 1: ThingManager <int,
Dave Love <fx@gnu.org>
parents:
diff changeset
3160 2: Framework::Callback *,
Dave Love <fx@gnu.org>
parents:
diff changeset
3161 3: Mutex> framework_callbacks;
Dave Love <fx@gnu.org>
parents:
diff changeset
3162
Dave Love <fx@gnu.org>
parents:
diff changeset
3163 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
3164 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
3165
Dave Love <fx@gnu.org>
parents:
diff changeset
3166 Here, line 1 is analyzed as a @code{topmost-intro}, but lines 2 and 3
Dave Love <fx@gnu.org>
parents:
diff changeset
3167 are both analyzed as @code{template-args-cont} lines.
Dave Love <fx@gnu.org>
parents:
diff changeset
3168
Dave Love <fx@gnu.org>
parents:
diff changeset
3169 Here is another (totally contrived) example which illustrates how syntax
Dave Love <fx@gnu.org>
parents:
diff changeset
3170 is assigned to various conditional constructs:
Dave Love <fx@gnu.org>
parents:
diff changeset
3171 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
3172 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
3173
Dave Love <fx@gnu.org>
parents:
diff changeset
3174 1: void spam( int index )
Dave Love <fx@gnu.org>
parents:
diff changeset
3175 2: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
3176 3: for( int i=0; i<index; i++ )
Dave Love <fx@gnu.org>
parents:
diff changeset
3177 4: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
3178 5: if( i == 10 )
Dave Love <fx@gnu.org>
parents:
diff changeset
3179 6: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
3180 7: do_something_special();
Dave Love <fx@gnu.org>
parents:
diff changeset
3181 8: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
3182 9: else
Dave Love <fx@gnu.org>
parents:
diff changeset
3183 10: do_something( i );
Dave Love <fx@gnu.org>
parents:
diff changeset
3184 11: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
3185 12: do @{
Dave Love <fx@gnu.org>
parents:
diff changeset
3186 13: another_thing( i-- );
Dave Love <fx@gnu.org>
parents:
diff changeset
3187 14: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
3188 15: while( i > 0 );
Dave Love <fx@gnu.org>
parents:
diff changeset
3189 16: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
3190
Dave Love <fx@gnu.org>
parents:
diff changeset
3191
Dave Love <fx@gnu.org>
parents:
diff changeset
3192 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
3193 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
3194
Dave Love <fx@gnu.org>
parents:
diff changeset
3195 @noindent
Dave Love <fx@gnu.org>
parents:
diff changeset
3196 Only the lines that illustrate new syntactic symbols will be discussed.
Dave Love <fx@gnu.org>
parents:
diff changeset
3197
Dave Love <fx@gnu.org>
parents:
diff changeset
3198 @cindex substatement-open syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3199 @cindex substatement-block-intro syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3200 @cindex block-close syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3201 Line 4 has a brace which opens a conditional's substatement block. It
Dave Love <fx@gnu.org>
parents:
diff changeset
3202 is thus assigned @code{substatement-open} syntax, and since line 5 is
Dave Love <fx@gnu.org>
parents:
diff changeset
3203 the first line in the substatement block, it is assigned
Dave Love <fx@gnu.org>
parents:
diff changeset
3204 @code{substatement-block-intro} syntax. Lines 6 and 7 are assigned
Dave Love <fx@gnu.org>
parents:
diff changeset
3205 similar syntax. Line 8 contains the brace that closes the inner
Dave Love <fx@gnu.org>
parents:
diff changeset
3206 substatement block. It is given the syntax @code{block-close},
Dave Love <fx@gnu.org>
parents:
diff changeset
3207 as are lines 11 and 14.
Dave Love <fx@gnu.org>
parents:
diff changeset
3208
Dave Love <fx@gnu.org>
parents:
diff changeset
3209 @cindex else-clause syntactic symbol
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3210 @cindex catch-clause syntactic symbol
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
3211 Line 9 is a little different --- since it contains the keyword
Dave Love <fx@gnu.org>
parents:
diff changeset
3212 @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
3213 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
3214 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
3215 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
3216 marked with @code{catch-clause}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3217
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3218 @cindex substatement syntactic symbol
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3219 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
3220 conditional introducing keyword @footnote{The list of conditional
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3221 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
3222 @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
3223 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
3224 @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
3225 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
3226 line 10 is assigned the @code{substatement} syntax.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
3227
Dave Love <fx@gnu.org>
parents:
diff changeset
3228 @cindex do-while-closure syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3229 One other difference is seen on line 15. The @code{while} construct
Dave Love <fx@gnu.org>
parents:
diff changeset
3230 that closes a @code{do} conditional is given the special syntax
Dave Love <fx@gnu.org>
parents:
diff changeset
3231 @code{do-while-closure} if it appears on a line by itself. Note that if
Dave Love <fx@gnu.org>
parents:
diff changeset
3232 the @code{while} appeared on the same line as the preceding close brace,
Dave Love <fx@gnu.org>
parents:
diff changeset
3233 that line would have been assigned @code{block-close} syntax instead.
Dave Love <fx@gnu.org>
parents:
diff changeset
3234
Dave Love <fx@gnu.org>
parents:
diff changeset
3235 Switch statements have their own set of syntactic symbols. Here's an
Dave Love <fx@gnu.org>
parents:
diff changeset
3236 example:
Dave Love <fx@gnu.org>
parents:
diff changeset
3237 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
3238 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
3239
Dave Love <fx@gnu.org>
parents:
diff changeset
3240 1: void spam( enum Ingredient i )
Dave Love <fx@gnu.org>
parents:
diff changeset
3241 2: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
3242 3: switch( i ) @{
Dave Love <fx@gnu.org>
parents:
diff changeset
3243 4: case Ham:
Dave Love <fx@gnu.org>
parents:
diff changeset
3244 5: be_a_pig();
Dave Love <fx@gnu.org>
parents:
diff changeset
3245 6: break;
Dave Love <fx@gnu.org>
parents:
diff changeset
3246 7: case Salt:
Dave Love <fx@gnu.org>
parents:
diff changeset
3247 8: drink_some_water();
Dave Love <fx@gnu.org>
parents:
diff changeset
3248 9: break;
Dave Love <fx@gnu.org>
parents:
diff changeset
3249 10: default:
Dave Love <fx@gnu.org>
parents:
diff changeset
3250 11: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
3251 12: what_is_it();
Dave Love <fx@gnu.org>
parents:
diff changeset
3252 13: break;
Dave Love <fx@gnu.org>
parents:
diff changeset
3253 14: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
3254 15: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
3255 14: @}
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 @cindex case-label syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3261 @cindex statement-case-intro syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3262 @cindex statement-case-open syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3263 Here, lines 4, 7, and 10 are all assigned @code{case-label} syntax,
Dave Love <fx@gnu.org>
parents:
diff changeset
3264 while lines 5 and 8 are assigned @code{statement-case-intro}. Line 11
Dave Love <fx@gnu.org>
parents:
diff changeset
3265 is treated slightly differently since it contains a brace that opens a
Dave Love <fx@gnu.org>
parents:
diff changeset
3266 block --- it is given @code{statement-case-open} syntax.
Dave Love <fx@gnu.org>
parents:
diff changeset
3267
Dave Love <fx@gnu.org>
parents:
diff changeset
3268 @cindex brace lists
Dave Love <fx@gnu.org>
parents:
diff changeset
3269 There are a set of syntactic symbols that are used to recognize
Dave Love <fx@gnu.org>
parents:
diff changeset
3270 constructs inside of brace lists. A brace list is defined as an
Dave Love <fx@gnu.org>
parents:
diff changeset
3271 @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
3272 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
3273 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
3274 brace lists too. An example:
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
3275 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
3276 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
3277
Dave Love <fx@gnu.org>
parents:
diff changeset
3278 1: static char* ingredients[] =
Dave Love <fx@gnu.org>
parents:
diff changeset
3279 2: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
3280 3: "Ham",
Dave Love <fx@gnu.org>
parents:
diff changeset
3281 4: "Salt",
Dave Love <fx@gnu.org>
parents:
diff changeset
3282 5: NULL
Dave Love <fx@gnu.org>
parents:
diff changeset
3283 6: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
3284
Dave Love <fx@gnu.org>
parents:
diff changeset
3285 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
3286 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
3287
Dave Love <fx@gnu.org>
parents:
diff changeset
3288 @cindex brace-list-open syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3289 @cindex brace-list-intro syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3290 @cindex brace-list-close syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3291 @cindex brace-list-entry syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3292 Following convention, line 2 in this example is assigned
Dave Love <fx@gnu.org>
parents:
diff changeset
3293 @code{brace-list-open} syntax, and line 3 is assigned
Dave Love <fx@gnu.org>
parents:
diff changeset
3294 @code{brace-list-intro} syntax. Likewise, line 6 is assigned
Dave Love <fx@gnu.org>
parents:
diff changeset
3295 @code{brace-list-close} syntax. Lines 4 and 5 however, are assigned
Dave Love <fx@gnu.org>
parents:
diff changeset
3296 @code{brace-list-entry} syntax, as would all subsequent lines in this
Dave Love <fx@gnu.org>
parents:
diff changeset
3297 initializer list.
Dave Love <fx@gnu.org>
parents:
diff changeset
3298
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3299 @cindex brace-entry-open syntactic symbol
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3300 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
3301 example:
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3302 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3303 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3304
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3305 1: struct intpairs[] =
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3306 2: @{
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3307 3: @{ 1, 2 @},
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3308 4: @{
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3309 5: 3,
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3310 6: 4
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3311 7: @}
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3312 8: @{ 1,
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3313 9: 2 @},
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3314 10: @{ 3, 4 @}
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3315 11: @}
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3316
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3317 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3318 @end example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3319
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3320 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
3321 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
3322 @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
3323 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
3324 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
3325 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
3326 line 10.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3327
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
3328 External language definition blocks also have their own syntactic
Dave Love <fx@gnu.org>
parents:
diff changeset
3329 symbols. In this example:
Dave Love <fx@gnu.org>
parents:
diff changeset
3330 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
3331 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
3332
Dave Love <fx@gnu.org>
parents:
diff changeset
3333 1: extern "C"
Dave Love <fx@gnu.org>
parents:
diff changeset
3334 2: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
3335 3: int thing_one( int );
Dave Love <fx@gnu.org>
parents:
diff changeset
3336 4: int thing_two( double );
Dave Love <fx@gnu.org>
parents:
diff changeset
3337 5: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
3338
Dave Love <fx@gnu.org>
parents:
diff changeset
3339 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
3340 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
3341
Dave Love <fx@gnu.org>
parents:
diff changeset
3342 @cindex extern-lang-open syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3343 @cindex extern-lang-close syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3344 @cindex inextern-lang syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3345 @cindex inclass syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3346 @noindent
Dave Love <fx@gnu.org>
parents:
diff changeset
3347 line 2 is given the @code{extern-lang-open} syntax, while line 5 is given
Dave Love <fx@gnu.org>
parents:
diff changeset
3348 the @code{extern-lang-close} syntax. The analysis for line 3 yields:
Dave Love <fx@gnu.org>
parents:
diff changeset
3349 @code{((inextern-lang) (topmost-intro . 14))}, where
Dave Love <fx@gnu.org>
parents:
diff changeset
3350 @code{inextern-lang} is a modifier similar in purpose to @code{inclass}.
Dave Love <fx@gnu.org>
parents:
diff changeset
3351
Dave Love <fx@gnu.org>
parents:
diff changeset
3352 Similarly, C++ namespace constructs have their own associated syntactic
Dave Love <fx@gnu.org>
parents:
diff changeset
3353 symbols. In this example:
Dave Love <fx@gnu.org>
parents:
diff changeset
3354 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
3355 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
3356
Dave Love <fx@gnu.org>
parents:
diff changeset
3357 1: namespace foo
Dave Love <fx@gnu.org>
parents:
diff changeset
3358 2: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
3359 3: void xxx() @{@}
Dave Love <fx@gnu.org>
parents:
diff changeset
3360 4: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
3361
Dave Love <fx@gnu.org>
parents:
diff changeset
3362 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
3363 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
3364
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3365 @cindex namespace-open syntactic symbol
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3366 @cindex namespace-close syntactic symbol
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3367 @cindex innamespace syntactic symbol
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
3368 @noindent
Dave Love <fx@gnu.org>
parents:
diff changeset
3369 line 2 is given the @code{namespace-open} syntax, while line 4 is given
Dave Love <fx@gnu.org>
parents:
diff changeset
3370 the @code{namespace-close} syntax. The analysis for line 3 yields:
Dave Love <fx@gnu.org>
parents:
diff changeset
3371 @code{((innamespace) (topmost-intro . 17))}, where @code{innamespace} is
Dave Love <fx@gnu.org>
parents:
diff changeset
3372 a modifier similar in purpose to @code{inextern-lang} and @code{inclass}.
Dave Love <fx@gnu.org>
parents:
diff changeset
3373
Dave Love <fx@gnu.org>
parents:
diff changeset
3374 A number of syntactic symbols are associated with parenthesis lists,
Dave Love <fx@gnu.org>
parents:
diff changeset
3375 a.k.a argument lists, as found in function declarations and function
Dave Love <fx@gnu.org>
parents:
diff changeset
3376 calls. This example illustrates these:
Dave Love <fx@gnu.org>
parents:
diff changeset
3377 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
3378 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
3379
Dave Love <fx@gnu.org>
parents:
diff changeset
3380 1: void a_function( int line1,
Dave Love <fx@gnu.org>
parents:
diff changeset
3381 2: int line2 );
Dave Love <fx@gnu.org>
parents:
diff changeset
3382 3:
Dave Love <fx@gnu.org>
parents:
diff changeset
3383 4: void a_longer_function(
Dave Love <fx@gnu.org>
parents:
diff changeset
3384 5: int line1,
Dave Love <fx@gnu.org>
parents:
diff changeset
3385 6: int line2
Dave Love <fx@gnu.org>
parents:
diff changeset
3386 7: );
Dave Love <fx@gnu.org>
parents:
diff changeset
3387 8:
Dave Love <fx@gnu.org>
parents:
diff changeset
3388 9: void call_them( int line1, int line2 )
Dave Love <fx@gnu.org>
parents:
diff changeset
3389 10: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
3390 11: a_function(
Dave Love <fx@gnu.org>
parents:
diff changeset
3391 12: line1,
Dave Love <fx@gnu.org>
parents:
diff changeset
3392 13: line2
Dave Love <fx@gnu.org>
parents:
diff changeset
3393 14: );
Dave Love <fx@gnu.org>
parents:
diff changeset
3394 15:
Dave Love <fx@gnu.org>
parents:
diff changeset
3395 16: a_longer_function( line1,
Dave Love <fx@gnu.org>
parents:
diff changeset
3396 17: line2 );
Dave Love <fx@gnu.org>
parents:
diff changeset
3397 18: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
3398
Dave Love <fx@gnu.org>
parents:
diff changeset
3399 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
3400 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
3401
Dave Love <fx@gnu.org>
parents:
diff changeset
3402 @cindex arglist-intro syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3403 @cindex arglist-close syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3404 Lines 5 and 12 are assigned @code{arglist-intro} syntax since they are
Dave Love <fx@gnu.org>
parents:
diff changeset
3405 the first line following the open parenthesis, and lines 7 and 14 are
Dave Love <fx@gnu.org>
parents:
diff changeset
3406 assigned @code{arglist-close} syntax since they contain the parenthesis
Dave Love <fx@gnu.org>
parents:
diff changeset
3407 that closes the argument list.
Dave Love <fx@gnu.org>
parents:
diff changeset
3408
Dave Love <fx@gnu.org>
parents:
diff changeset
3409 @cindex arglist-cont-nonempty syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3410 @cindex arglist-cont syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3411 Lines that continue argument lists can be assigned one of two syntactic
Dave Love <fx@gnu.org>
parents:
diff changeset
3412 symbols. For example, Lines 2 and 17
Dave Love <fx@gnu.org>
parents:
diff changeset
3413 are assigned @code{arglist-cont-nonempty} syntax. What this means
Dave Love <fx@gnu.org>
parents:
diff changeset
3414 is that they continue an argument list, but that the line containing the
Dave Love <fx@gnu.org>
parents:
diff changeset
3415 parenthesis that opens the list is @emph{not empty} following the open
Dave Love <fx@gnu.org>
parents:
diff changeset
3416 parenthesis. Contrast this against lines 6 and 13 which are assigned
Dave Love <fx@gnu.org>
parents:
diff changeset
3417 @code{arglist-cont} syntax. This is because the parenthesis that opens
Dave Love <fx@gnu.org>
parents:
diff changeset
3418 their argument lists is the last character on that line.
Dave Love <fx@gnu.org>
parents:
diff changeset
3419
Dave Love <fx@gnu.org>
parents:
diff changeset
3420 Note that there is no @code{arglist-open} syntax. This is because any
Dave Love <fx@gnu.org>
parents:
diff changeset
3421 parenthesis that opens an argument list, appearing on a separate line,
Dave Love <fx@gnu.org>
parents:
diff changeset
3422 is assigned the @code{statement-cont} syntax instead.
Dave Love <fx@gnu.org>
parents:
diff changeset
3423
Dave Love <fx@gnu.org>
parents:
diff changeset
3424 A few miscellaneous syntactic symbols that haven't been previously
Dave Love <fx@gnu.org>
parents:
diff changeset
3425 covered are illustrated by this C++ example:
Dave Love <fx@gnu.org>
parents:
diff changeset
3426 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
3427 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
3428
Dave Love <fx@gnu.org>
parents:
diff changeset
3429 1: void Bass::play( int volume )
Dave Love <fx@gnu.org>
parents:
diff changeset
3430 2: const
Dave Love <fx@gnu.org>
parents:
diff changeset
3431 3: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
3432 4: /* this line starts a multi-line
Dave Love <fx@gnu.org>
parents:
diff changeset
3433 5: * comment. This line should get `c' syntax */
Dave Love <fx@gnu.org>
parents:
diff changeset
3434 6:
Dave Love <fx@gnu.org>
parents:
diff changeset
3435 7: char* a_multiline_string = "This line starts a multi-line \
Dave Love <fx@gnu.org>
parents:
diff changeset
3436 8: string. This line should get `string' syntax.";
Dave Love <fx@gnu.org>
parents:
diff changeset
3437 9:
Dave Love <fx@gnu.org>
parents:
diff changeset
3438 10: note:
Dave Love <fx@gnu.org>
parents:
diff changeset
3439 11: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
3440 12: #ifdef LOCK
Dave Love <fx@gnu.org>
parents:
diff changeset
3441 13: Lock acquire();
Dave Love <fx@gnu.org>
parents:
diff changeset
3442 14: #endif // LOCK
Dave Love <fx@gnu.org>
parents:
diff changeset
3443 15: slap_pop();
Dave Love <fx@gnu.org>
parents:
diff changeset
3444 16: cout << "I played "
Dave Love <fx@gnu.org>
parents:
diff changeset
3445 17: << "a note\n";
Dave Love <fx@gnu.org>
parents:
diff changeset
3446 18: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
3447 19: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
3448
Dave Love <fx@gnu.org>
parents:
diff changeset
3449 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
3450 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
3451
Dave Love <fx@gnu.org>
parents:
diff changeset
3452 The lines to note in this example include:
Dave Love <fx@gnu.org>
parents:
diff changeset
3453
Dave Love <fx@gnu.org>
parents:
diff changeset
3454 @itemize @bullet
Dave Love <fx@gnu.org>
parents:
diff changeset
3455
Dave Love <fx@gnu.org>
parents:
diff changeset
3456 @cindex func-decl-cont syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3457 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
3458 line 2, assigned the @code{func-decl-cont} syntax;
Dave Love <fx@gnu.org>
parents:
diff changeset
3459
Dave Love <fx@gnu.org>
parents:
diff changeset
3460 @cindex comment-intro syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3461 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
3462 line 4, assigned both @code{defun-block-intro} @emph{and}
Dave Love <fx@gnu.org>
parents:
diff changeset
3463 @code{comment-intro} syntax;
Dave Love <fx@gnu.org>
parents:
diff changeset
3464
Dave Love <fx@gnu.org>
parents:
diff changeset
3465 @cindex c syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3466 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
3467 line 5, assigned @code{c} syntax;
Dave Love <fx@gnu.org>
parents:
diff changeset
3468
Dave Love <fx@gnu.org>
parents:
diff changeset
3469 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
3470 @cindex syntactic whitespace
Dave Love <fx@gnu.org>
parents:
diff changeset
3471 line 6 which, even though it contains nothing but whitespace, is
Dave Love <fx@gnu.org>
parents:
diff changeset
3472 assigned @code{defun-block-intro}. Note that the appearance of the
Dave Love <fx@gnu.org>
parents:
diff changeset
3473 comment on lines 4 and 5 do not cause line 6 to be assigned
Dave Love <fx@gnu.org>
parents:
diff changeset
3474 @code{statement} syntax because comments are considered to be
Dave Love <fx@gnu.org>
parents:
diff changeset
3475 @dfn{syntactic whitespace}, which are ignored when analyzing
Dave Love <fx@gnu.org>
parents:
diff changeset
3476 code;
Dave Love <fx@gnu.org>
parents:
diff changeset
3477
Dave Love <fx@gnu.org>
parents:
diff changeset
3478 @cindex string syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3479 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
3480 line 8, assigned @code{string} syntax;
Dave Love <fx@gnu.org>
parents:
diff changeset
3481
Dave Love <fx@gnu.org>
parents:
diff changeset
3482 @cindex label syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3483 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
3484 line 10, assigned @code{label} syntax;
Dave Love <fx@gnu.org>
parents:
diff changeset
3485
Dave Love <fx@gnu.org>
parents:
diff changeset
3486 @cindex block-open syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3487 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
3488 line 11, assigned @code{block-open} syntax;
Dave Love <fx@gnu.org>
parents:
diff changeset
3489
Dave Love <fx@gnu.org>
parents:
diff changeset
3490 @cindex cpp-macro syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3491 @cindex cpp-macro-cont syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3492 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
3493 lines 12 and 14, assigned @code{cpp-macro} syntax.
Dave Love <fx@gnu.org>
parents:
diff changeset
3494
Dave Love <fx@gnu.org>
parents:
diff changeset
3495 @cindex stream-op syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3496 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
3497 line 17, assigned @code{stream-op} syntax.
Dave Love <fx@gnu.org>
parents:
diff changeset
3498
Dave Love <fx@gnu.org>
parents:
diff changeset
3499 @end itemize
Dave Love <fx@gnu.org>
parents:
diff changeset
3500
Dave Love <fx@gnu.org>
parents:
diff changeset
3501 @cindex multi-line macros
Dave Love <fx@gnu.org>
parents:
diff changeset
3502 @cindex syntactic whitespace
Dave Love <fx@gnu.org>
parents:
diff changeset
3503 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
3504 @ccmode{} now recognizes the fact that it is inside a multi-line macro,
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
3505 and it properly skips such macros as syntactic whitespace. In this
Dave Love <fx@gnu.org>
parents:
diff changeset
3506 example:
Dave Love <fx@gnu.org>
parents:
diff changeset
3507 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
3508 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
3509
Dave Love <fx@gnu.org>
parents:
diff changeset
3510 1: #define LIST_LOOP(cons, listp) \
Dave Love <fx@gnu.org>
parents:
diff changeset
3511 2: for (cons = listp; !NILP (cons); cons = XCDR (cons)) \
Dave Love <fx@gnu.org>
parents:
diff changeset
3512 3: if (!CONSP (cons)) \
Dave Love <fx@gnu.org>
parents:
diff changeset
3513 4: signal_error ("Invalid list format", listp); \
Dave Love <fx@gnu.org>
parents:
diff changeset
3514 5: else
Dave Love <fx@gnu.org>
parents:
diff changeset
3515
Dave Love <fx@gnu.org>
parents:
diff changeset
3516 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
3517 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
3518 @noindent
Dave Love <fx@gnu.org>
parents:
diff changeset
3519 line 1 is given the syntactic symbol @code{cpp-macro}. This first line
Dave Love <fx@gnu.org>
parents:
diff changeset
3520 of a macro is always given this symbol. The second and subsequent lines
Dave Love <fx@gnu.org>
parents:
diff changeset
3521 (e.g. lines 2 through 5) are given the @code{cpp-macro-cont} syntactic
Dave Love <fx@gnu.org>
parents:
diff changeset
3522 symbol, with a relative buffer position pointing to the @code{#} which
Dave Love <fx@gnu.org>
parents:
diff changeset
3523 starts the macro definition.
Dave Love <fx@gnu.org>
parents:
diff changeset
3524
Dave Love <fx@gnu.org>
parents:
diff changeset
3525 In Objective-C buffers, there are three additional syntactic symbols
Dave Love <fx@gnu.org>
parents:
diff changeset
3526 assigned to various message calling constructs. Here's an example
Dave Love <fx@gnu.org>
parents:
diff changeset
3527 illustrating these:
Dave Love <fx@gnu.org>
parents:
diff changeset
3528 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
3529 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
3530
Dave Love <fx@gnu.org>
parents:
diff changeset
3531 1: - (void)setDelegate:anObject
Dave Love <fx@gnu.org>
parents:
diff changeset
3532 2: withStuff:stuff
Dave Love <fx@gnu.org>
parents:
diff changeset
3533 3: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
3534 4: [delegate masterWillRebind:self
Dave Love <fx@gnu.org>
parents:
diff changeset
3535 5: toDelegate:anObject
Dave Love <fx@gnu.org>
parents:
diff changeset
3536 6: withExtraStuff:stuff];
Dave Love <fx@gnu.org>
parents:
diff changeset
3537 7: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
3538
Dave Love <fx@gnu.org>
parents:
diff changeset
3539 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
3540 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
3541
Dave Love <fx@gnu.org>
parents:
diff changeset
3542 @cindex objc-method-intro syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3543 @cindex objc-method-args-cont syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3544 @cindex objc-method-call-cont syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3545 Here, line 1 is assigned @code{objc-method-intro} syntax, and line 2 is
Dave Love <fx@gnu.org>
parents:
diff changeset
3546 assigned @code{objc-method-args-cont} syntax. Lines 5 and 6 are both
Dave Love <fx@gnu.org>
parents:
diff changeset
3547 assigned @code{objc-method-call-cont} syntax.
Dave Love <fx@gnu.org>
parents:
diff changeset
3548
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3549 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
3550 this:
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3551 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3552 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3553
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3554 1: public void watch(Observable o) @{
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3555 2: o.addObserver(new Observer() @{
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3556 3: public void update(Observable o, Object arg) @{
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3557 4: history.addElement(arg);
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3558 5: @}
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3559 6: @});
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3560 7: @}
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3561
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3562 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3563 @end example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3564
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3565 @cindex inexpr-class syntactic symbol
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3566 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
3567 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
3568 @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
3569 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
3570 @code{inexpr-class}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3571
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3572 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
3573 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
3574 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3575 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3576
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3577 1: int res = (@{
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3578 2: int y = foo (); int z;
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3579 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
3580 4: z;
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3581 5: @});
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3582
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3583 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3584 @end example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3585
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3586 @cindex inexpr-statement syntactic symbol
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3587 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
3588 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
3589 @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
3590 indentation.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3591
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3592 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
3593 statements, as illustrated here:
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3594 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3595 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3596
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3597 1: array itgob()
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3598 2: @{
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3599 3: string s = map (backtrace()[-2][3..],
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3600 4: lambda
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3601 5: (mixed arg)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3602 6: @{
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3603 7: return sprintf ("%t", arg);
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3604 8: @}) * ", " + "\n";
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3605 9: return catch @{
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3606 10: write (s + "\n");
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3607 11: @};
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3608 12: @}
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3609
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3610 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3611 @end example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3612
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3613 @cindex inlambda syntactic symbol
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3614 @cindex lambda-intro-cont syntactic symbol
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3615 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
3616 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
3617 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
3618 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
3619 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
3620 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
3621 @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
3622 @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
3623 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
3624 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
3625 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
3626
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3627 @cindex inexpr-statement syntactic symbol
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3628 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
3629 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
3630 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
3631 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
3632 handled like this too.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3633
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
3634 @cindex knr-argdecl-intro syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3635 @cindex knr-argdecl syntactic symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
3636 Two other syntactic symbols can appear in old style, non-prototyped C
Dave Love <fx@gnu.org>
parents:
diff changeset
3637 code @footnote{a.k.a. K&R C, or Kernighan & Ritchie C}:
Dave Love <fx@gnu.org>
parents:
diff changeset
3638 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
3639 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
3640
Dave Love <fx@gnu.org>
parents:
diff changeset
3641 1: int add_three_integers(a, b, c)
Dave Love <fx@gnu.org>
parents:
diff changeset
3642 2: int a;
Dave Love <fx@gnu.org>
parents:
diff changeset
3643 3: int b;
Dave Love <fx@gnu.org>
parents:
diff changeset
3644 4: int c;
Dave Love <fx@gnu.org>
parents:
diff changeset
3645 5: @{
Dave Love <fx@gnu.org>
parents:
diff changeset
3646 6: return a + b + c;
Dave Love <fx@gnu.org>
parents:
diff changeset
3647 7: @}
Dave Love <fx@gnu.org>
parents:
diff changeset
3648
Dave Love <fx@gnu.org>
parents:
diff changeset
3649 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
3650 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
3651
Dave Love <fx@gnu.org>
parents:
diff changeset
3652 Here, line 2 is the first line in an argument declaration list and so is
Dave Love <fx@gnu.org>
parents:
diff changeset
3653 given the @code{knr-argdecl-intro} syntactic symbol. Subsequent lines
Dave Love <fx@gnu.org>
parents:
diff changeset
3654 (i.e. lines 3 and 4 in this example), are given @code{knr-argdecl}
Dave Love <fx@gnu.org>
parents:
diff changeset
3655 syntax.
Dave Love <fx@gnu.org>
parents:
diff changeset
3656
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3657
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
3658 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3659 @node Indentation Functions, Performance Issues, Syntactic Symbols, Top
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3660 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3661 @chapter Indentation Functions
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3662 @cindex indentation functions
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3663 @cindex line-up functions
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3664 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3665
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3666 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
3667 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
3668 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
3669 for a syntactic symbol.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3670
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3671 @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
3672 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
3673 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
3674 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
3675 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
3676
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3677 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
3678 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
3679
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3680 @macro workswith
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3681 @emph{Works with:}
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3682 @end macro
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3683 @ifinfo
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3684 @unmacro workswith
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3685 @macro workswith
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3686 Works with:
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3687 @end macro
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3688 @end ifinfo
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3689
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3690 @table @code
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3691
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3692 @findex c-lineup-arglist
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3693 @findex lineup-arglist (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3694 @item c-lineup-arglist
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3695 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
3696
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3697 @workswith @code{arglist-cont-nonempty}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3698
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3699 @findex c-lineup-arglist-intro-after-paren
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3700 @findex lineup-arglist-intro-after-paren (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3701 @item c-lineup-arglist-intro-after-paren
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3702 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
3703 brace block.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3704
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3705 @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
3706 @code{statement-block-intro}, @code{statement-case-intro},
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3707 @code{arglist-intro}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3708
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3709 @findex c-lineup-arglist-close-under-paren
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3710 @findex lineup-arglist-close-under-paren (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3711 @item c-lineup-arglist-close-under-paren
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3712 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
3713 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
3714 under the parenthesis that opened the argument list.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3715
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3716 @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
3717 @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
3718 @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
3719 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
3720
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3721 @findex c-lineup-close-paren
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3722 @findex lineup-close-paren (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3723 @item c-lineup-close-paren
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3724 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
3725 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
3726 indentation is added. E.g:
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3727 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3728 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3729
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3730 main (int,
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3731 char **
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3732 ) // c-lineup-close-paren
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3733
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3734 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3735 @end example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3736 @noindent
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3737 and
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3738 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3739 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3740
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3741 main (
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3742 int, char **
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3743 ) // c-lineup-close-paren
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3744
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3745 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3746 @end example
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 @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
3749 @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
3750 @code{extern-lang-close}, @code{namespace-close}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3751
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3752 @findex c-lineup-streamop
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3753 @findex lineup-streamop (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3754 @item c-lineup-streamop
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3755 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
3756
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3757 @workswith @code{stream-op}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3758
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3759 @findex c-lineup-multi-inher
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3760 @findex lineup-multi-inher (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3761 @item c-lineup-multi-inher
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3762 Line up the classes in C++ multiple inheritance clauses under each
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3763 other.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3764
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3765 @workswith @code{inher-cont}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3766
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3767 @findex c-lineup-java-inher
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3768 @findex lineup-java-inher (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3769 @item c-lineup-java-inher
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3770 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
3771 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
3772 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
3773 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
3774 E.g:
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3775 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3776 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3777
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3778 class Foo
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3779 extends
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3780 Bar // c-lineup-java-inher
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3781
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3782 <--> c-basic-offset
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3783
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3784 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3785 @end example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3786 @noindent
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3787 and
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3788 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3789 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3790
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3791 class Foo
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3792 extends Cyphr,
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3793 Bar // c-lineup-java-inher
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3794
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3795 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3796 @end example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3797
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3798 @workswith @code{inher-cont}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3799
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3800 @findex c-lineup-java-throws
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3801 @findex lineup-java-throws (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3802 @item c-lineup-java-throws
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3803 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
3804 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
3805 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
3806 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
3807 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
3808 start if it doesn't hang. E.g:
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 int foo()
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3813 throws // c-lineup-java-throws
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3814 Bar // c-lineup-java-throws
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 <--><--> c-basic-offset
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3817
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3818 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3819 @end example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3820 @noindent
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3821 and
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3822 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3823 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3824
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3825 int foo() throws Cyphr,
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3826 Bar, // c-lineup-java-throws
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3827 Vlod // c-lineup-java-throws
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3828
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3829 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3830 @end example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3831
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3832 @workswith @code{func-decl-cont}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3833
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3834 @findex c-indent-one-line-block
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3835 @findex indent-one-line-block (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3836 @item c-indent-one-line-block
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3837 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
3838 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3839 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3840
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3841 if (n > 0)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3842 @{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
3843
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3844 <--> c-basic-offset
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3845
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3846 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3847 @end example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3848 @noindent
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3849 and
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3850 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3851 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3852
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3853 if (n > 0)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3854 @{ // c-indent-one-line-block
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3855 m+=n; n=0;
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3856 @}
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3857
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3858 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3859 @end example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3860
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3861 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
3862 @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
3863 which makes the function usable in list expressions.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3864
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3865 @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
3866 @code{-open} symbols.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3867
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3868 @findex c-indent-multi-line-block
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3869 @findex indent-multi-line-block (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3870 @item c-indent-multi-line-block
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3871 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
3872 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3873 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3874
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3875 int *foo[] = @{
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3876 NULL,
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3877 @{17@}, // c-indent-multi-line-block
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3878
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3879 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3880 @end example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3881 @noindent
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3882 and
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3883 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3884 @group
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 int *foo[] = @{
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3887 NULL,
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3888 @{ // c-indent-multi-line-block
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3889 17
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3890 @},
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3891
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3892 <--> c-basic-offset
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3893
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3894 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3895 @end example
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 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
3898 @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
3899 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
3900
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3901 @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
3902 @code{-open} symbols.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3903
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3904 @findex c-lineup-C-comments
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3905 @findex lineup-C-comments (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3906 @item c-lineup-C-comments
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3907 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
3908 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
3909 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3910
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3911 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3912 /* /** /*
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3913 * text * text text
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3914 */ */ */
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3915 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3916
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3917 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3918 /* text /* /**
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3919 text ** text ** text
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3920 */ */ */
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3921 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3922
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3923 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3924 /**************************************************
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3925 * text
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3926 *************************************************/
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3927 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3928
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3929 @vindex comment-start-skip
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3930 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3931 /**************************************************
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3932 Free form text comments:
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3933 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
3934 start, the indentation is kept unchanged for lines
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3935 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
3936 delimiter line is whatever matches the
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3937 @code{comment-start-skip} regexp.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3938 **************************************************/
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3939 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3940
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3941 @end example
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 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
3944 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
3945 line inside a comment.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3946
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3947 @workswith The @code{c} syntactic symbol.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3948
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3949 @findex c-lineup-comment
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3950 @findex lineup-comment (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3951 @item c-lineup-comment
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3952 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
3953 @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
3954 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
3955
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3956 @vindex c-comment-only-line-offset
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3957 @vindex comment-only-line-offset (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3958 @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
3959 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
3960 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3961
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3962 (@r{<non-anchored-offset>} . @r{<anchored-offset>})
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3963
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3964 @end example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3965
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3966 @noindent
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3967 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
3968 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
3969 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
3970 is equivalent to @code{(@r{<value>} . -1000)}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3971
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3972 @workswith @code{comment-intro}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3973
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3974 @findex c-lineup-runin-statements
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3975 @findex lineup-runin-statements (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3976 @item c-lineup-runin-statements
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3977 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
3978 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
3979 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
3980 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
3981 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3982 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3983
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3984 int main()
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3985 @{ puts (\"Hello world!\");
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3986 return 0; // c-lineup-runin-statements
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
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3989 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3990 @end example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3991
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3992 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
3993 @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
3994 expressions.
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 @workswith The @code{statement} syntactic symbol.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3997
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3998 @findex c-lineup-math
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
3999 @findex lineup-math (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4000 @item c-lineup-math
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4001 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
4002 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
4003 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
4004 first one.
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 @workswith @code{statement-cont}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4007
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4008 @findex c-lineup-template-args
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4009 @findex lineup-template-args (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4010 @item c-lineup-template-args
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4011 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
4012 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
4013 opening @samp{<}.
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 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
4016 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
4017
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4018 @workswith @code{template-args-cont}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4019
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4020 @findex c-lineup-ObjC-method-call
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4021 @findex lineup-ObjC-method-call (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4022 @item c-lineup-ObjC-method-call
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4023 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
4024 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
4025 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
4026 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
4027 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
4028 lineup the current line with it.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4029
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4030 @workswith @code{objc-method-call-cont}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4031
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4032 @findex c-lineup-ObjC-method-args
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4033 @findex lineup-ObjC-method-args (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4034 @item c-lineup-ObjC-method-args
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4035 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
4036 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
4037
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4038 @workswith @code{objc-method-args-cont}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4039
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4040 @findex c-lineup-ObjC-method-args-2
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4041 @findex lineup-ObjC-method-args-2 (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4042 @item c-lineup-ObjC-method-args-2
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4043 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
4044 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
4045
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4046 @workswith @code{objc-method-args-cont}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4047
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4048 @findex c-lineup-inexpr-block
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4049 @findex lineup-inexpr-block (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4050 @item c-lineup-inexpr-block
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4051 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
4052 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
4053 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
4054 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
4055 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
4056 construct.
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 @workswith @code{inlambda}, @code{inexpr-statement},
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4059 @code{inexpr-class}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4060
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4061 @findex c-lineup-whitesmith-in-block
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4062 @findex lineup-whitesmith-in-block (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4063 @item c-lineup-whitesmith-in-block
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4064 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
4065 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
4066 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4067 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4068
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4069 something
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4070 @{
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4071 foo; // c-lineup-whitesmith-in-block
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4072 @}
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4073
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4074 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4075 @end example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4076 @noindent
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4077 and
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4078 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4079 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4080
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4081 something @{
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4082 foo; // c-lineup-whitesmith-in-block
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4083 @}
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4084
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4085 <--> c-basic-offset
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4086
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4087 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4088 @end example
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 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
4091 @code{c-basic-offset} is added.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4092
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4093 @workswith @code{defun-close}, @code{defun-block-intro},
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4094 @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
4095 @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
4096 @code{innamespace}.
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 @findex c-lineup-dont-change
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4099 @findex lineup-dont-change (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4100 @item c-lineup-dont-change
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4101 This lineup function returns the indentation of the current line. Think
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4102 of it as an identity function for lineups; it is used for
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4103 @code{cpp-macro-cont} lines.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4104
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4105 @workswith Any syntactic symbol.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4106
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4107 @end table
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4108
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 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4111 @node Performance Issues, Frequently Asked Questions, Indentation Functions, Top
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4112 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4113 @chapter Performance Issues
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4114 @cindex performance issues
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4115 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
4116
Dave Love <fx@gnu.org>
parents:
diff changeset
4117 C and its derivative languages are highly complex creatures. Often,
Dave Love <fx@gnu.org>
parents:
diff changeset
4118 ambiguous code situations arise that require @ccmode{} to scan
Dave Love <fx@gnu.org>
parents:
diff changeset
4119 large portions of the buffer to determine syntactic context. Such
Dave Love <fx@gnu.org>
parents:
diff changeset
4120 pathological code@footnote{such as the output of @code{lex(1)}!}
Dave Love <fx@gnu.org>
parents:
diff changeset
4121 can cause @ccmode{} to perform fairly badly.
Dave Love <fx@gnu.org>
parents:
diff changeset
4122 This section identifies some of the coding styles to watch out for, and
Dave Love <fx@gnu.org>
parents:
diff changeset
4123 suggests some workarounds that you can use to improve performance.
Dave Love <fx@gnu.org>
parents:
diff changeset
4124
Dave Love <fx@gnu.org>
parents:
diff changeset
4125 Because @ccmode{} has to scan the buffer backwards from the current
Dave Love <fx@gnu.org>
parents:
diff changeset
4126 insertion point, and because C's syntax is fairly difficult to parse in
Dave Love <fx@gnu.org>
parents:
diff changeset
4127 the backwards direction, @ccmode{} often tries to find the nearest
Dave Love <fx@gnu.org>
parents:
diff changeset
4128 position higher up in the buffer from which to begin a forward scan.
Dave Love <fx@gnu.org>
parents:
diff changeset
4129 The farther this position is from the current insertion point, the
Dave Love <fx@gnu.org>
parents:
diff changeset
4130 slower the mode gets. Some coding styles can even force @ccmode{}
Dave Love <fx@gnu.org>
parents:
diff changeset
4131 to scan from the beginning of the buffer for every line of code!
Dave Love <fx@gnu.org>
parents:
diff changeset
4132
Dave Love <fx@gnu.org>
parents:
diff changeset
4133 @findex beginning-of-defun
Dave Love <fx@gnu.org>
parents:
diff changeset
4134 @findex defun-prompt-regexp
Dave Love <fx@gnu.org>
parents:
diff changeset
4135 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
4136 any brace that opens a top-level construct@footnote{E.g. a function in
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4137 C, or outermost class definition in C++ or Java.} always appears in the
Dave Love <fx@gnu.org>
parents:
diff changeset
4138 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
4139 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
4140 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
4141 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
4142 to something reasonable, however that ``something reasonable'' is
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4143 difficult to define, so @ccmode{} doesn't do it for you.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4144
Dave Love <fx@gnu.org>
parents:
diff changeset
4145 @vindex c-Java-defun-prompt-regexp
Dave Love <fx@gnu.org>
parents:
diff changeset
4146 @vindex Java-defun-prompt-regexp (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
4147 A special note about @code{defun-prompt-regexp} in Java mode: while much
Dave Love <fx@gnu.org>
parents:
diff changeset
4148 of the early sample Java code seems to encourage a style where the brace
Dave Love <fx@gnu.org>
parents:
diff changeset
4149 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
4150 good style to pursue in Emacs. @ccmode{} comes with a variable
Dave Love <fx@gnu.org>
parents:
diff changeset
4151 @code{c-Java-defun-prompt-regexp} which tries to define a regular
Dave Love <fx@gnu.org>
parents:
diff changeset
4152 expression usable for this style, but there are problems with it. In
Dave Love <fx@gnu.org>
parents:
diff changeset
4153 some cases it can cause @code{beginning-of-defun} to hang@footnote{This
Dave Love <fx@gnu.org>
parents:
diff changeset
4154 has been observed in Emacs 19.34 and XEmacs 19.15.}. For this reason,
Dave Love <fx@gnu.org>
parents:
diff changeset
4155 it is not used by default, but if you feel adventurous, you can set
Dave Love <fx@gnu.org>
parents:
diff changeset
4156 @code{defun-prompt-regexp} to it in your mode hook. In any event,
Dave Love <fx@gnu.org>
parents:
diff changeset
4157 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
4158 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
4159 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
4160
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4161 @vindex c-enable-xemacs-performance-kludge-p
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4162 @vindex enable-xemacs-performance-kludge-p (c-)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4163 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
4164 @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
4165 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
4166 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
4167 @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
4168 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
4169 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
4170 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
4171 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
4172 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
4173 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
4174 should be more common (and
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4175 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
4176 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
4177 this writing 27-Apr-1998).
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4178
Dave Love <fx@gnu.org>
parents:
diff changeset
4179 You will probably notice pathological behavior from @ccmode{} when
Dave Love <fx@gnu.org>
parents:
diff changeset
4180 working in files containing large amounts of C preprocessor macros.
Dave Love <fx@gnu.org>
parents:
diff changeset
4181 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
4182 as it can comments.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4183
Dave Love <fx@gnu.org>
parents:
diff changeset
4184 @vindex c-recognize-knr-p
Dave Love <fx@gnu.org>
parents:
diff changeset
4185 @vindex recognize-knr-p (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
4186 Previous versions of @ccmode{} had potential performance problems
Dave Love <fx@gnu.org>
parents:
diff changeset
4187 when recognizing K&R style function argument declarations. This was
Dave Love <fx@gnu.org>
parents:
diff changeset
4188 because there are ambiguities in the C syntax when K&R style argument
Dave Love <fx@gnu.org>
parents:
diff changeset
4189 lists are used@footnote{It is hard to distinguish them from top-level
Dave Love <fx@gnu.org>
parents:
diff changeset
4190 declarations.}. @ccmode{} has adopted BOCM's convention for
Dave Love <fx@gnu.org>
parents:
diff changeset
4191 limiting the search: it assumes that argdecls are indented at least one
Dave Love <fx@gnu.org>
parents:
diff changeset
4192 space, and that the function headers are not indented at all. With
Dave Love <fx@gnu.org>
parents:
diff changeset
4193 current versions of @ccmode{}, user customization of
Dave Love <fx@gnu.org>
parents:
diff changeset
4194 @code{c-recognize-knr-p} is deprecated. Just don't put argdecls in
Dave Love <fx@gnu.org>
parents:
diff changeset
4195 column zero!
Dave Love <fx@gnu.org>
parents:
diff changeset
4196
Dave Love <fx@gnu.org>
parents:
diff changeset
4197 @cindex @file{cc-lobotomy.el} file
Dave Love <fx@gnu.org>
parents:
diff changeset
4198 @vindex cc-lobotomy-pith-list
Dave Love <fx@gnu.org>
parents:
diff changeset
4199 You might want to investigate the speed-ups contained in the
Dave Love <fx@gnu.org>
parents:
diff changeset
4200 file @file{cc-lobotomy.el}, which comes as part of the @ccmode{}
Dave Love <fx@gnu.org>
parents:
diff changeset
4201 distribution, but is completely unsupported.
Dave Love <fx@gnu.org>
parents:
diff changeset
4202 As mentioned previous, @ccmode{} always trades speed for accuracy,
Dave Love <fx@gnu.org>
parents:
diff changeset
4203 however it is recognized that sometimes you need speed and can sacrifice
Dave Love <fx@gnu.org>
parents:
diff changeset
4204 some accuracy in indentation. The file @file{cc-lobotomy.el} contains
Dave Love <fx@gnu.org>
parents:
diff changeset
4205 hacks that will ``dumb down'' @ccmode{} in some specific ways, making
Dave Love <fx@gnu.org>
parents:
diff changeset
4206 that trade-off of accurancy for speed. I won't go into details of its
Dave Love <fx@gnu.org>
parents:
diff changeset
4207 use here; you should read the comments at the top of the file, and look
Dave Love <fx@gnu.org>
parents:
diff changeset
4208 at the variable @code{cc-lobotomy-pith-list} for details.
Dave Love <fx@gnu.org>
parents:
diff changeset
4209
Dave Love <fx@gnu.org>
parents:
diff changeset
4210
Dave Love <fx@gnu.org>
parents:
diff changeset
4211 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4212 @node Frequently Asked Questions, Getting the Latest CC Mode Release, Performance Issues, Top
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4213 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4214 @chapter Frequently Asked Questions
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4215 @cindex frequently asked questions
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4216 @cindex FAQ
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 @kindex C-x h
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4220 @kindex C-M-\
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4221 @kindex C-M-x
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4222 @kindex C-M-q
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4223 @kindex C-M-u
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4224 @kindex RET
Dave Love <fx@gnu.org>
parents:
diff changeset
4225 @kindex C-j
Dave Love <fx@gnu.org>
parents:
diff changeset
4226 @quotation
Dave Love <fx@gnu.org>
parents:
diff changeset
4227
Dave Love <fx@gnu.org>
parents:
diff changeset
4228 @strong{Q.} @emph{How do I re-indent the whole file?}
Dave Love <fx@gnu.org>
parents:
diff changeset
4229
Dave Love <fx@gnu.org>
parents:
diff changeset
4230 @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
4231 buffer. Then hit @kbd{C-M-\}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4232
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4233 @sp 1
Dave Love <fx@gnu.org>
parents:
diff changeset
4234 @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
4235 @kbd{C-M-x} doesn't work.}
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4236
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4237 @strong{A.} @kbd{C-M-x} is reserved for future Emacs use.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4238 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
4239
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4240 @sp 1
Dave Love <fx@gnu.org>
parents:
diff changeset
4241 @strong{Q.} @emph{How do I re-indent the current block?}
Dave Love <fx@gnu.org>
parents:
diff changeset
4242
Dave Love <fx@gnu.org>
parents:
diff changeset
4243 @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
4244 @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
4245 @kbd{C-M-q}.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4246
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4247 @sp 1
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4248 @strong{Q.} @emph{Why doesn't the @kbd{RET} key indent the new line?}
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4249
Dave Love <fx@gnu.org>
parents:
diff changeset
4250 @strong{A.} Emacs' convention is that @kbd{RET} just adds a newline,
Dave Love <fx@gnu.org>
parents:
diff changeset
4251 and that @kbd{C-j} adds a newline and indents it. You can make
Dave Love <fx@gnu.org>
parents:
diff changeset
4252 @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
4253 @code{c-mode-common-hook}:
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4254 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
4255
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4256 (define-key c-mode-base-map "\C-m" 'c-context-line-break)
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4257
Dave Love <fx@gnu.org>
parents:
diff changeset
4258 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
4259
Dave Love <fx@gnu.org>
parents:
diff changeset
4260 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
4261 behavior, don't lobby me, lobby RMS! @t{:-)}
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4262
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4263 @sp 1
Dave Love <fx@gnu.org>
parents:
diff changeset
4264 @strong{Q.} @emph{I put @code{(c-set-offset 'substatement-open 0)}
Dave Love <fx@gnu.org>
parents:
diff changeset
4265 in my @file{.emacs} file but I get an error saying that
Dave Love <fx@gnu.org>
parents:
diff changeset
4266 @code{c-set-offset}'s function definition is void.}
Dave Love <fx@gnu.org>
parents:
diff changeset
4267
Dave Love <fx@gnu.org>
parents:
diff changeset
4268 @strong{A.} This means that @ccmode{} wasn't loaded into your
Dave Love <fx@gnu.org>
parents:
diff changeset
4269 Emacs session by the time the @code{c-set-offset} call was reached,
Dave Love <fx@gnu.org>
parents:
diff changeset
4270 mostly likely because @ccmode{} is being autoloaded. Instead
Dave Love <fx@gnu.org>
parents:
diff changeset
4271 of putting the @code{c-set-offset} line in your top-level
Dave Love <fx@gnu.org>
parents:
diff changeset
4272 @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
4273 simply modify @code{c-offsets-alist} directly:
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4274 @example
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4275 @group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4276
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4277 (setq c-offsets-alist (cons '(substatement-open . 0)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4278 c-offsets-alist))
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4279 @end group
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4280 @end example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4281
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4282 @sp 1
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4283 @strong{Q.} @emph{My style settings works in all the @ccmode{} language
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4284 modes except for Java, where I still get e.g. 4 column indentation.}
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4285
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4286 @strong{A.} Java mode switches to the @samp{java} style by default for
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4287 historical reasons. You can override it by putting an association list
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4288 on @code{c-default-style}:
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4289 @example
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4290
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4291 (setq c-default-style '((other . "my-style")))
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4292
Dave Love <fx@gnu.org>
parents:
diff changeset
4293 @end example
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4294 @noindent
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4295 The @samp{other} symbol says that @ccmode{} should use "my-style" in all
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4296 modes not explicitly listed. Since there's nothing else on the list
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4297 this causes "my-style" to be used in every mode.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4298
Dave Love <fx@gnu.org>
parents:
diff changeset
4299 @sp 1
Dave Love <fx@gnu.org>
parents:
diff changeset
4300 @strong{Q.} @emph{How do I make strings, comments, keywords, and other
Dave Love <fx@gnu.org>
parents:
diff changeset
4301 constructs appear in different colors, or in bold face, etc.?}
Dave Love <fx@gnu.org>
parents:
diff changeset
4302
Dave Love <fx@gnu.org>
parents:
diff changeset
4303 @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
4304 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
4305 font-lock definitions for any of its supported languages.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4306
Dave Love <fx@gnu.org>
parents:
diff changeset
4307 @sp 1
Dave Love <fx@gnu.org>
parents:
diff changeset
4308 @strong{Q.} @emph{@kbd{M-a} and @kbd{M-e} used to move over entire
Dave Love <fx@gnu.org>
parents:
diff changeset
4309 balanced brace lists, but now they move into blocks. How do I get the
Dave Love <fx@gnu.org>
parents:
diff changeset
4310 old behavior back?}
Dave Love <fx@gnu.org>
parents:
diff changeset
4311
Dave Love <fx@gnu.org>
parents:
diff changeset
4312 @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
4313 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
4314 also move into blocks.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4315
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4316 @sp 1
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4317 @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
4318 ``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
4319 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
4320 gives?}
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4321
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4322 @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
4323 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
4324 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
4325 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
4326 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
4327 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
4328 @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
4329 in the @file{README} file.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4330
Dave Love <fx@gnu.org>
parents:
diff changeset
4331 @end quotation
Dave Love <fx@gnu.org>
parents:
diff changeset
4332
Dave Love <fx@gnu.org>
parents:
diff changeset
4333
Dave Love <fx@gnu.org>
parents:
diff changeset
4334 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4335 @node Getting the Latest CC Mode Release, Sample .emacs File, Frequently Asked Questions, Top
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4336 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4337 @chapter Getting the Latest CC Mode Release
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4338 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
4339
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4340 @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
4341 XEmacs since 19.16.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4342
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4343 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
4344 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
4345 @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
4346 compatibility, etc. are all available via the Web at:
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4347
Dave Love <fx@gnu.org>
parents:
diff changeset
4348 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
4349 @group
Dave Love <fx@gnu.org>
parents:
diff changeset
4350
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4351 @uref{http://www.python.org/emacs/cc-mode/}
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4352
Dave Love <fx@gnu.org>
parents:
diff changeset
4353 @end group
Dave Love <fx@gnu.org>
parents:
diff changeset
4354 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
4355
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4356 @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
4357
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4358 There are many files under these directories; you can pick up the entire
Dave Love <fx@gnu.org>
parents:
diff changeset
4359 distribution (named @code{cc-mode.tar.gz}; a gzip'd tar file), or any of
Dave Love <fx@gnu.org>
parents:
diff changeset
4360 the individual files, including PostScript documentation.
Dave Love <fx@gnu.org>
parents:
diff changeset
4361
Dave Love <fx@gnu.org>
parents:
diff changeset
4362
Dave Love <fx@gnu.org>
parents:
diff changeset
4363 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4364 @node Sample .emacs File, Limitations and Known Bugs, Getting the Latest CC Mode Release, Top
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4365 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4366 @chapter Sample .emacs file
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4367 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
4368
Dave Love <fx@gnu.org>
parents:
diff changeset
4369 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
4370 ;; Here's a sample .emacs file that might help you along the way. Just
Dave Love <fx@gnu.org>
parents:
diff changeset
4371 ;; copy this region and paste it into your .emacs file. You may want to
Dave Love <fx@gnu.org>
parents:
diff changeset
4372 ;; change some of the actual values.
Dave Love <fx@gnu.org>
parents:
diff changeset
4373
Dave Love <fx@gnu.org>
parents:
diff changeset
4374 (defconst my-c-style
Dave Love <fx@gnu.org>
parents:
diff changeset
4375 '((c-tab-always-indent . t)
Dave Love <fx@gnu.org>
parents:
diff changeset
4376 (c-comment-only-line-offset . 4)
Dave Love <fx@gnu.org>
parents:
diff changeset
4377 (c-hanging-braces-alist . ((substatement-open after)
Dave Love <fx@gnu.org>
parents:
diff changeset
4378 (brace-list-open)))
Dave Love <fx@gnu.org>
parents:
diff changeset
4379 (c-hanging-colons-alist . ((member-init-intro before)
Dave Love <fx@gnu.org>
parents:
diff changeset
4380 (inher-intro)
Dave Love <fx@gnu.org>
parents:
diff changeset
4381 (case-label after)
Dave Love <fx@gnu.org>
parents:
diff changeset
4382 (label after)
Dave Love <fx@gnu.org>
parents:
diff changeset
4383 (access-label after)))
Dave Love <fx@gnu.org>
parents:
diff changeset
4384 (c-cleanup-list . (scope-operator
Dave Love <fx@gnu.org>
parents:
diff changeset
4385 empty-defun-braces
Dave Love <fx@gnu.org>
parents:
diff changeset
4386 defun-close-semi))
Dave Love <fx@gnu.org>
parents:
diff changeset
4387 (c-offsets-alist . ((arglist-close . c-lineup-arglist)
Dave Love <fx@gnu.org>
parents:
diff changeset
4388 (substatement-open . 0)
Dave Love <fx@gnu.org>
parents:
diff changeset
4389 (case-label . 4)
Dave Love <fx@gnu.org>
parents:
diff changeset
4390 (block-open . 0)
Dave Love <fx@gnu.org>
parents:
diff changeset
4391 (knr-argdecl-intro . -)))
Dave Love <fx@gnu.org>
parents:
diff changeset
4392 (c-echo-syntactic-information-p . t)
Dave Love <fx@gnu.org>
parents:
diff changeset
4393 )
Dave Love <fx@gnu.org>
parents:
diff changeset
4394 "My C Programming Style")
Dave Love <fx@gnu.org>
parents:
diff changeset
4395
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4396 ;; offset customizations not in my-c-style
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4397 (setq c-offsets-alist (cons '(member-init-intro . ++)
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4398 c-offsets-alist))
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4399
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4400 ;; Customizations for all modes in CC Mode.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4401 (defun my-c-mode-common-hook ()
Dave Love <fx@gnu.org>
parents:
diff changeset
4402 ;; add my personal style and set it for the current buffer
Dave Love <fx@gnu.org>
parents:
diff changeset
4403 (c-add-style "PERSONAL" my-c-style t)
Dave Love <fx@gnu.org>
parents:
diff changeset
4404 ;; other customizations
Dave Love <fx@gnu.org>
parents:
diff changeset
4405 (setq tab-width 8
Dave Love <fx@gnu.org>
parents:
diff changeset
4406 ;; this will make sure spaces are used instead of tabs
Dave Love <fx@gnu.org>
parents:
diff changeset
4407 indent-tabs-mode nil)
Dave Love <fx@gnu.org>
parents:
diff changeset
4408 ;; we like auto-newline and hungry-delete
Dave Love <fx@gnu.org>
parents:
diff changeset
4409 (c-toggle-auto-hungry-state 1)
Dave Love <fx@gnu.org>
parents:
diff changeset
4410 ;; keybindings for all supported languages. We can put these in
Dave Love <fx@gnu.org>
parents:
diff changeset
4411 ;; 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
4412 ;; 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
4413 (define-key c-mode-base-map "\C-m" 'c-context-line-break)
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4414 )
Dave Love <fx@gnu.org>
parents:
diff changeset
4415
Dave Love <fx@gnu.org>
parents:
diff changeset
4416 (add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
Dave Love <fx@gnu.org>
parents:
diff changeset
4417 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
4418
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4419
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4420 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4421 @node Limitations and Known Bugs, Mailing Lists and Submitting Bug Reports, Sample .emacs File, Top
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4422 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4423 @chapter Limitations and Known Bugs
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4424 @cindex limitations
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4425 @cindex bugs
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4426 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dave Love <fx@gnu.org>
parents:
diff changeset
4427
Dave Love <fx@gnu.org>
parents:
diff changeset
4428 @itemize @bullet
Dave Love <fx@gnu.org>
parents:
diff changeset
4429 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
4430 Re-indenting large regions or expressions can be slow.
Dave Love <fx@gnu.org>
parents:
diff changeset
4431
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4432 @findex c-indent-exp
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4433 @findex indent-exp (c-)
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4434 @item
Dave Love <fx@gnu.org>
parents:
diff changeset
4435 @code{c-indent-exp} has not been fully optimized. It essentially
Dave Love <fx@gnu.org>
parents:
diff changeset
4436 equivalent to hitting @kbd{TAB} (@code{c-indent-command}) on every
Dave Love <fx@gnu.org>
parents:
diff changeset
4437 line. Some information is cached from line to line, but such caching
Dave Love <fx@gnu.org>
parents:
diff changeset
4438 invariable causes inaccuracies in analysis in some bizarre situations.
Dave Love <fx@gnu.org>
parents:
diff changeset
4439
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4440 @vindex signal-error-on-buffer-boundary
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4441 @item
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4442 XEmacs versions from 19.15 until (as of this writing 12-Mar-1998) 20.4
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4443 contain a variable called @code{signal-error-on-buffer-boundary}. This
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4444 was intended as a solution to user interface problems associated with
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4445 buffer movement and the @code{zmacs-region} deactivation on errors.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4446 However, setting this variable to a non-default value had the
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4447 deleterious side effect of breaking many built-in primitive functions.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4448 Most users will not be affected since they never change the value of
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4449 this variable. @strong{Do not set this variable to @code{nil}}; you
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4450 will cause serious problems in @ccmode{} and probably other XEmacs
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4451 packages! As of at least XEmacs 20.4, the effects this variable tried
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4452 to correct have been fixed in other, better ways.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4453
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4454 @end itemize
Dave Love <fx@gnu.org>
parents:
diff changeset
4455
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4456
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4457 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4458 @node Mailing Lists and Submitting Bug Reports, Concept Index, Limitations and Known Bugs, Top
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4459 @comment node-name, next, previous, up
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4460 @chapter Mailing Lists and Submitting Bug Reports
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4461 @cindex mailing lists
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4462 @cindex reporting bugs
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4463 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4464
Dave Love <fx@gnu.org>
parents:
diff changeset
4465 @kindex C-c C-b
Dave Love <fx@gnu.org>
parents:
diff changeset
4466 @findex c-submit-bug-report
Dave Love <fx@gnu.org>
parents:
diff changeset
4467 @findex submit-bug-report (c-)
Dave Love <fx@gnu.org>
parents:
diff changeset
4468 To report bugs, use the @kbd{C-c C-b} (@code{c-submit-bug-report})
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4469 command. This provides vital information we need to reproduce your
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4470 problem. Make sure you include a concise, but complete code example.
Dave Love <fx@gnu.org>
parents:
diff changeset
4471 Please try to boil your example down to just the essential code needed
Dave Love <fx@gnu.org>
parents:
diff changeset
4472 to reproduce the problem, and include an exact recipe of steps needed to
Dave Love <fx@gnu.org>
parents:
diff changeset
4473 expose the bug. Be especially sure to include any code that appears
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4474 @emph{before} your bug example, if you think it might affect our ability
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4475 to reproduce it.
Dave Love <fx@gnu.org>
parents:
diff changeset
4476
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4477 Please try to produce the problem in an Emacs instance without any
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4478 customizations loaded (i.e. start it with the @code{-q -no-site-file}
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4479 arguments). If it works correctly there, the problem might be caused by
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4480 faulty customizations in either your own or your site configuration. In
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4481 that case, we'd appreciate if you isolate the Emacs Lisp code that trigs
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4482 the bug and include it in your report.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4483
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4484 Bug reports are now sent to the following email addresses:
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4485 @email{bug-cc-mode@@gnu.org} and @email{bug-gnu-emacs@@gnu.org}; the
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4486 latter is mirrored on the Usenet newsgroup @code{gnu.emacs.bug}. You
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4487 can send other questions and suggestions (kudos? @t{;-)} to
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4488 @email{bug-cc-mode@@gnu.org}, or @email{help-gnu-emacs@@gnu.org} which is
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4489 mirrored on newsgroup @code{gnu.emacs.help}. The old contact address
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4490 @email{cc-mode-help@@python.org} is still active, but its use is
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4491 discouraged.
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4492
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4493 @cindex beta testers mailing list
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4494 @cindex announcement mailing list
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4495 If you want to get announcements of new @ccmode{} releases, send the word
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4496 @emph{subscribe} in the body of a message to
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4497 @email{cc-mode-announce-request@@python.org}. Announcements will also
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4498 be posted to the Usenet newsgroups @code{gnu.emacs.sources},
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4499 @code{comp.emacs}, @code{comp.emacs.xemacs}, and possibly some of the
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4500 language oriented newsgroups. Note that the
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4501 @code{cc-mode-victims@@python.org} mailing list has been
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4502 decommissioned.
Dave Love <fx@gnu.org>
parents:
diff changeset
4503
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4504
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4505 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4506 @node Concept Index, Command Index, Mailing Lists and Submitting Bug Reports, Top
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4507 @comment node-name, next, previous, up
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4508 @unnumbered Concept Index
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4509 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4510
Dave Love <fx@gnu.org>
parents:
diff changeset
4511 @printindex cp
Dave Love <fx@gnu.org>
parents:
diff changeset
4512
Dave Love <fx@gnu.org>
parents:
diff changeset
4513
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4514 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4515 @node Command Index, Key Index, Concept Index, Top
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4516 @comment node-name, next, previous, up
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4517 @unnumbered Command Index
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4518 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4519
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4520 Since most @ccmode{} commands are prepended with the string
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4521 @samp{c-}, each appears under its @code{c-@var{<thing>}} name and its
Dave Love <fx@gnu.org>
parents:
diff changeset
4522 @code{@var{<thing>} (c-)} name.
Dave Love <fx@gnu.org>
parents:
diff changeset
4523 @iftex
Dave Love <fx@gnu.org>
parents:
diff changeset
4524 @sp 2
Dave Love <fx@gnu.org>
parents:
diff changeset
4525 @end iftex
Dave Love <fx@gnu.org>
parents:
diff changeset
4526 @printindex fn
Dave Love <fx@gnu.org>
parents:
diff changeset
4527
Dave Love <fx@gnu.org>
parents:
diff changeset
4528
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4529 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4530 @node Key Index, Variable Index, Command Index, Top
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4531 @comment node-name, next, previous, up
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4532 @unnumbered Key Index
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4533 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4534
Dave Love <fx@gnu.org>
parents:
diff changeset
4535 @printindex ky
Dave Love <fx@gnu.org>
parents:
diff changeset
4536
Dave Love <fx@gnu.org>
parents:
diff changeset
4537
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4538 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4539 @node Variable Index, , Key Index, Top
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4540 @comment node-name, next, previous, up
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4541 @unnumbered Variable Index
26819
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4542 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4543
a19be798eaea Installed cc-mode version 5.26.
Gerd Moellmann <gerd@gnu.org>
parents: 26490
diff changeset
4544 Since most @ccmode{} variables are prepended with the string
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4545 @samp{c-}, each appears under its @code{c-@var{<thing>}} name and its
Dave Love <fx@gnu.org>
parents:
diff changeset
4546 @code{@var{<thing>} (c-)} name.
Dave Love <fx@gnu.org>
parents:
diff changeset
4547 @iftex
Dave Love <fx@gnu.org>
parents:
diff changeset
4548 @sp 2
Dave Love <fx@gnu.org>
parents:
diff changeset
4549 @end iftex
Dave Love <fx@gnu.org>
parents:
diff changeset
4550 @printindex vr
Dave Love <fx@gnu.org>
parents:
diff changeset
4551 @page
Dave Love <fx@gnu.org>
parents:
diff changeset
4552 @summarycontents
Dave Love <fx@gnu.org>
parents:
diff changeset
4553 @contents
Dave Love <fx@gnu.org>
parents:
diff changeset
4554 @bye