annotate man/cc-mode.texi @ 179:9ad43877534d r20-3b16

Import from CVS: tag r20-3b16
author cvs
date Mon, 13 Aug 2007 09:52:19 +0200
parents 6075d714658b
children bfd6434d15b3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1 \input texinfo
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 @comment %**start of header (This is for running Texinfo on a region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 2
diff changeset
7 @setfilename cc-mode.info
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
8 @settitle CC MODE Version 5 Documentation
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 @footnotestyle end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 @comment @setchapternewpage odd !! we don't want blank pages !!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 @comment %**end of header (This is for running Texinfo on a region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 @comment
171
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 165
diff changeset
19 @comment Texinfo manual for CC Mode
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
20 @comment Generated from the original README file by Krishna Padmasola
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 @comment <krishna@earth-gw.njit.edu>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 @comment
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
23 @comment Maintained by Barry A. Warsaw <cc-mode-help@python.org>
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 @comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 @comment The following line inserts the copyright notice
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 @comment into the Info file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 @ifinfo
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
34 Copyright @copyright{} 1995, 1996 Free Software Foundation, Inc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 @end ifinfo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 @comment !!!The titlepage section does not appear in the Info file.!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 @titlepage
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 @sp 10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 @comment The title is printed in a large font.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
49 @center @titlefont{CC Mode 5.14}
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 @sp 2
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
51 @center @subtitlefont{A GNU Emacs mode for editing C and C-like languages}
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 @sp 2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 @center Barry A. Warsaw
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 @comment The following two commands start the copyright page
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 @comment for the printed manual. This will not appear in the Info file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 @page
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 @vskip 0pt plus 1filll
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 Copyright @copyright{} 1995 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 @end titlepage
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 @comment The Top node contains the master menu for the Info file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 @comment This appears only in the Info file, not the printed manual.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 @node Top, Introduction, (dir), (dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 @comment node-name, next, previous, up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 * Introduction::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 * Getting Connected::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 * New Indentation Engine::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 * Minor Modes::
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
84 * Commands::
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 * Customizing Indentation::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 * Syntactic Symbols::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 * Performance Issues::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 * Frequently Asked Questions::
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
89 * Getting the latest CC Mode release::
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 * Sample .emacs File::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 * Limitations and Known Bugs::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 * Mailing Lists and Submitting Bug Reports::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 * Concept Index::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 * Command Index:: Command Index
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 * Key Index:: Key Index
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 * Variable Index:: Variable Index
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 @node Introduction, Getting Connected, Top, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 @comment node-name, next, previous, up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 @chapter Introduction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 @cindex Introduction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
107 @macro ccmode
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
108 CC Mode
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
109 @end macro
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
110
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 @cindex BOCM
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
112
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
113 Welcome to @ccmode{}. This is a GNU Emacs mode for editing files
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
114 containing C, C++, Objective-C, Java, and IDL code. This incarnation of
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
115 the mode is descendant from @file{c-mode.el} (also called "Boring Old C
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
116 Mode" or BOCM @code{:-)}, and @file{c++-mode.el} version 2, which I have
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
117 been maintaining since 1992. @ccmode{} represents a significant
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
118 milestone in the mode's life. It has been fully merged back with Emacs
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
119 19's @file{c-mode.el}. Also a new, more intuitive and flexible mechanism
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
120 for controlling indentation has been developed.
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
121
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
122 @ccmode{} supports the editing of K&R and ANSI C, @dfn{ARM}
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
123 @footnote{``The Annotated C++ Reference Manual'', by Ellis and
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
124 Stroustrup.} C++, Objective-C, Java and IDL@footnote{CORBA's Interface
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
125 Definition Language} files. In this way, you can
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
126 easily set up consistent coding styles for use in editing all C, C++,
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
127 Objective-C, Java and IDL programs. @ccmode{} does @emph{not} handle
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
128 font-locking (a.k.a. syntax coloring, keyword highlighting) or anything
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
129 of that nature, for any of these modes. Font-locking is handled by other
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
130 Emacs packages.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 This manual will describe the following:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 @itemize @bullet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 @item
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
136 How to get started using @ccmode{}.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 How the new indentation engine works.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 How to customize the new indentation engine.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 @end itemize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
146 @findex c-mode
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
147 @findex c++-mode
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
148 @findex objc-mode
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
149 @findex java-mode
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
150 @findex idl-mode
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
151 Note that the name of this package is ``@ccmode{}'', but there is no top
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
152 level @code{cc-mode} entry point. All of the variables, commands, and
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
153 functions in @ccmode{} are prefixed with @code{c-@var{<thing>}}, and
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
154 @code{c-mode}, @code{c++-mode}, @code{objc-mode}, @code{java-mode}, and
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
155 @code{idl-mode} entry points are provided. This file is intended to be
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
156 a replacement for @file{c-mode.el} and @file{c++-mode.el}.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 @cindex @file{cc-compat.el} file
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
159 This distribution also contains a file
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
160 called @file{cc-compat.el} which should ease your transition from BOCM
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
161 to @ccmode{}. If you have a BOCM configuration you are really happy
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
162 with, and want to postpone learning how to configure @ccmode{}, take a
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
163 look at that file. It maps BOCM configuration variables to @ccmode{}'s
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
164 new indentation model. It is not actively supported so for the long
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
165 run, you should learn how to customize @ccmode{} to support your coding
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
166 style.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 A special word of thanks goes to Krishna Padmasola for his work in
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
169 converting the original @file{README} file to Texinfo format. I'd also
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
170 like to thank all the @ccmode{} victims who help enormously during the
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
171 early beta stages of @ccmode{}'s development.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 @node Getting Connected, New Indentation Engine, Introduction, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 @comment node-name, next, previous, up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 @chapter Getting Connected
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 @cindex Getting Connected
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
183 If you got this version of @ccmode{} with Emacs, it should work just
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
184 fine right out of the box, and you can safely skip to the next chapter.
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
185 Note however that you may not have the latest @ccmode{} release and may
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
186 want to upgrade your copy. See the @file{README} file, or the @ccmode{}
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
187 Web pages latest information on Emacs version compatibility,
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
188 @ref{Getting the latest CC Mode release}.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 @cindex @file{cc-mode-18.el} file
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
191 @emph{@ccmode{} no longer works with Emacs 18!} The
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
192 @file{cc-mode-18.el} file is no longer distributed with @ccmode{}. If
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
193 you haven't upgraded from Emacs 18 by now, you are out of luck. The
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
194 rest of these installation instructions assume you are using one of the
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
195 new Emacs or XEmacs releases, that already come with @ccmode{}. These
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
196 instructions explain how to upgrade to use the latest @ccmode{}
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
197 release.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
199 @cindex .emacs file
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
200
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
201 The first thing you will want to do is put the @ccmode{} source files in
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
202 a subdirectory somewhere on your @code{load-path} so Emacs can find it.
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
203 The distribution tarball unpacks into its own subdirectory,
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
204 e.g. @file{cc-mode/}. Assuming you unpacked the distribution in your
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
205 home directory, you should add the following to your @file{.emacs} file
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
206 in order to pick up the latest version of @ccmode{} over the one
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
207 distributed with your Emacs:
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
208
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 @example
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
210
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
211 (setq load-path (cons "~/cc-mode" load-path))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 @cindex byte compile
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
216
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
217 Next you want to @dfn{byte compile} all the @ccmode{} source files.
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
218 @ccmode{} uses a lot of macros so if you don't byte compile it,
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
219 things will be unbearably slow. @emph{You can ignore all byte-compiler
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
220 warnings!} They are the result of the supporting different versions of
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
221 Emacs, and none of the warnings have any effect on operation. Let me say
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
222 this again: @strong{You really can ignore all byte-compiler warnings!}
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
223
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
224 To byte-compile the source files, first @code{cd} to the directory you
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
225 unpacked the tarball into. Then run the following command at your shell
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
226 prompt:
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
227
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
230 % $EMACS -batch -no-site-file -q -l cc-make.el cc-*.el
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
234 @noindent
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
235 where $EMACS is either @code{emacs} or @code{xemacs} depending on the
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
236 version you use.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
238 Next time you start up Emacs you should be using the latest @ccmode{}.
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
239 You can test this by visiting a C file and hitting @kbd{M-x c-version
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
240 RET}; you should see this message in the echo area:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 @example
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
242
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
243 Using CC Mode version 5.XX
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 @node New Indentation Engine, Minor Modes, Getting Connected, Top
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
249 @comment node-name, next, previous, up
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 @chapter New Indentation Engine
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 @cindex New Indentation Engine
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
255 @ccmode{} has a new indentation engine, providing a simplified, yet
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
256 flexible and general mechanism for customizing indentation. It separates
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
257 indentation calculation into two steps: first, @ccmode{} analyzes the
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
258 line of code being indented to determine the kind of language construct
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
259 it's looking at, then it applies user defined offsets to the current
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
260 line based on this analysis.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 This section will briefly cover how indentation is calculated in
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
263 @ccmode{}. It is important to understand the indentation model
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
264 being used so that you will know how to customize @ccmode{} for
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 your personal coding style.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 * Syntactic Analysis::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 * Indentation Calculation::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 @end menu
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
271
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 @node Syntactic Analysis, Indentation Calculation, , New Indentation Engine
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 @section Syntactic Analysis
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 @cindex Syntactic Analysis
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 @vindex c-offsets-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 @vindex offsets-alist (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 @cindex relative buffer position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 @cindex syntactic symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 @cindex syntactic component
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 @cindex syntactic component list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 @cindex relative buffer position
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
287 The first thing @ccmode{} does when indenting a line of code, is to
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 analyze the line, determining the @dfn{syntactic component list} of the
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
289 construct on that line. A syntactic component consists of a pair
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 of information (in lisp parlance, a @emph{cons cell}), where the first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 part is a @dfn{syntactic symbol}, and the second part is a @dfn{relative
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 buffer position}. Syntactic symbols describe elements of C code
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
293 @footnote{or C++, Objective-C, Java or IDL code. In general, for the rest
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 of this manual I'll use the term ``C code'' to refer to all the C-like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 dialects, unless otherwise noted.}, e.g. @code{statement},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 @code{substatement}, @code{class-open}, @code{class-close}, etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 @xref{Syntactic Symbols}, for a complete list of currently recognized
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 syntactic symbols and their semantics. The variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 @code{c-offsets-alist} also contains the list of currently supported
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 syntactic symbols.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 Conceptually, a line of C code is always indented relative to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 indentation of some line higher up in the buffer. This is represented
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 by the relative buffer position in the syntactic component.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
306 Here is an example. Suppose we had the following code as the only thing
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
307 in a @code{c++-mode} buffer @footnote{The line numbers in this and
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
308 future examples don't actually appear in the buffer, of course!}:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 1: void swap( int& a, int& b )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 2: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 3: int tmp = a;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 4: a = b;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 5: b = tmp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 6: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 @kindex C-c C-s
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 @findex c-show-syntactic-information
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 @findex show-syntactic-information (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 We can use the command @kbd{C-c C-s}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (@code{c-show-syntactic-information}) to simply report what the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 syntactic analysis is for the current line. Running this command on
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
328 line 4 of this example, we'd see in the echo area@footnote{With a universal
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
329 argument (i.e. @kbd{C-u C-c C-s}) the analysis is inserted into the
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
330 buffer as a comment
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
331 on the current line.}:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 ((statement . 35))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 This tells us that the line is a statement and it is indented relative
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 to buffer position 35, which happens to be the @samp{i} in @code{int} on
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
340 line 3. If you were to move point to line 3 and hit @kbd{C-c C-s}, you
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 would see:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 ((defun-block-intro . 29))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 This indicates that the @samp{int} line is the first statement in a top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 level function block, and is indented relative to buffer position 29,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 which is the brace just after the function header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 Here's another example:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 1: int add( int val, int incr, int doit )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 2: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 3: if( doit )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 4: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 5: return( val + incr );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 6: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 7: return( val );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 8: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 Hitting @kbd{C-c C-s} on line 4 gives us:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 ((substatement-open . 46))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 @cindex substatement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 @cindex substatment block
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 which tells us that this is a brace that @emph{opens} a substatement
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
380 block. @footnote{A @dfn{substatement} indicates the line after a
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
381 conditional statement, such as @code{if}, @code{else}, @code{while},
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
382 @code{do}, @code{switch}, or @code{for} in C. A @dfn{substatement
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
383 block} is a brace block following one of those conditionals.}
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 @cindex comment only line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 Syntactic component lists can contain more than one component, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 individual syntactic components need not have relative buffer positions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 The most common example of this is a line that contains a @dfn{comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 only line}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 1: void draw_list( List<Drawables>& drawables )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 2: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 3: // call the virtual draw() method on each element in list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 4: for( int i=0; i < drawables.count(), ++i )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 5: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 6: drawables[i].draw();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 7: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 8: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 @noindent
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
406 Hitting @kbd{C-c C-s} on line 3 of this example gives:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 ((comment-intro) (defun-block-intro . 46))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 @noindent
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
414 and you can see that the syntactic component list contains two syntactic
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 components. Also notice that the first component,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 @samp{(comment-intro)} has no relative buffer position.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 @node Indentation Calculation, , Syntactic Analysis, New Indentation Engine
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 @section Indentation Calculation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 @cindex Indentation Calculation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 @vindex c-offsets-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 @vindex offsets-alist (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 Indentation for the current line is calculated using the syntactic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 component list derived in step 1 above (see @ref{Syntactic Analysis}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 Each component contributes to the final total indentation of the line in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 two ways.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 First, the syntactic symbols are looked up in the @code{c-offsets-alist}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 variable, which is an association list of syntactic symbols and the
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
435 offsets to apply for those symbols. These offsets are added to a
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 running total.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
438 Second, if the component has a relative buffer position, @ccmode{}
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 adds the column number of that position to the running total. By adding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 up the offsets and columns for every syntactic component on the list,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 the final total indentation for the current line is computed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 Let's use our two code examples above to see how this works. Here is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 our first example again:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 1: void swap( int& a, int& b )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 2: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 3: int tmp = a;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 4: a = b;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 5: b = tmp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 6: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 @kindex TAB
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
459 Let's say point is on line 3 and we hit the @key{TAB} key to re-indent
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 the line. Remember that the syntactic component list for that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 line is:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 ((defun-block-intro . 29))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 @noindent
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
469 @ccmode{} looks up @code{defun-block-intro} in the
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 @code{c-offsets-alist} variable. Let's say it finds the value @samp{4};
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 it adds this to the running total (initialized to zero), yielding a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 running total indentation of 4 spaces.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
474 Next @ccmode{} goes to buffer position 29 and asks for the current
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
475 column. This brace is in column zero, so @ccmode{}
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 adds @samp{0} to the running total. Since there is only one syntactic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 component on the list for this line, indentation calculation is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 complete, and the total indentation for the line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 is 4 spaces.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 Here's another example:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 1: int add( int val, int incr, int doit )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 2: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 3: if( doit )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 4: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 5: return( val + incr );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 6: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 7: return( val );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 8: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 If we were to hit @kbd{TAB} on line 4 in the above example, the same
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 basic process is performed, despite the differences in the syntactic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 component list. Remember that the list for this line is:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 ((substatement-open . 46))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
506 Here, @ccmode{} first looks up the @code{substatement-open} symbol
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 in @code{c-offsets-alist}. Let's say it finds the value @samp{4}. This
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
508 yields a running total of 4. @ccmode{} then goes to
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 buffer position 46, which is the @samp{i} in @code{if} on line 3. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 character is in the fourth column on that line so adding this to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 running total yields an indentation for the line of 8 spaces.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 Simple, huh?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 Actually, the mode usually just does The Right Thing without you having
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 to think about it in this much detail. But when customizing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 indentation, it's helpful to understand the general indentation model
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 being used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 @vindex c-echo-syntactic-information-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 @vindex echo-syntactic-information-p (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 @cindex TAB
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
523 As you configure @ccmode{}, you might want to set the variable
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 @code{c-echo-syntactic-information-p} to non-@code{nil} so that the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 syntactic component list and calculated offset will always be echoed in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 the minibuffer when you hit @kbd{TAB}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
530 @node Minor Modes, Commands, New Indentation Engine, Top
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 @chapter Minor Modes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 @cindex Minor Modes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
537 @ccmode{} contains two minor-mode-like features that you should
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 find useful while you enter new C code. The first is called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 @dfn{auto-newline} mode, and the second is called @dfn{hungry-delete}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 mode. These minor modes can be toggled on and off independently, and
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
541 @ccmode{} can be configured so that it starts up with any
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 combination of these minor modes. By default, both of these minor modes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 are turned off.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 The state of the minor modes is always reflected in the minor mode list
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
546 on the modeline of the @ccmode{} buffer. When auto-newline mode is
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 enabled, you will see @samp{C/a} on the mode line @footnote{Remember
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
548 that the @samp{C} could be replaced with @samp{C++}, @samp{ObjC},
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
549 @samp{Java} or @samp{IDL}.}. When hungry delete mode is enabled you
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
550 would see @samp{C/h} and when both modes are enabled, you'd see
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
551 @samp{C/ah}.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 @kindex C-c C-a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 @kindex C-c C-d
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 @kindex C-c C-t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 @findex c-toggle-hungry-state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 @findex c-toggle-auto-state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 @findex c-toggle-auto-hungry-state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 @findex toggle-hungry-state (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 @findex toggle-auto-state (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 @findex toggle-auto-hungry-state (c-)
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
562 @ccmode{} provides keybindings which allow you to toggle the minor
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
563 modes on the fly while editing code. To toggle just the auto-newline
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 state, hit @kbd{C-c C-a} (@code{c-toggle-auto-state}). When you do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 this, you should see the @samp{a} indicator either appear or disappear
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 on the modeline. Similarly, to toggle just the hungry-delete state, use
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
567 @kbd{C-c C-d} (@code{c-toggle-hungry-state}), and to toggle both states,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
568 use @kbd{C-c C-t} (@code{c-toggle-auto-hungry-state}).
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 To set up the auto-newline and hungry-delete states to your preferred
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 values, you would need to add some lisp to your @file{.emacs} file that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 called one of the @code{c-toggle-*-state} functions directly. When
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 called programmatically, each function takes a numeric value, where
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 a positive number enables the minor mode, a negative number disables the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 mode, and zero toggles the current state of the mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 So for example, if you wanted to enable both auto-newline and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 hungry-delete for all your C file editing, you could add the following
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 to your @file{.emacs} file:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
582 (add-hook 'c-mode-common-hook
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
583 '(lambda () (c-toggle-auto-hungry-state 1)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 @cindex electric characters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 * Auto-newline insertion::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 * Hungry-deletion of whitespace::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 @node Auto-newline insertion, Hungry-deletion of whitespace, , Minor Modes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 @section Auto-newline insertion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 @cindex Auto-newline insertion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 @cindex electric commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 Auto-newline minor mode works by enabling certain @dfn{electric
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 commands}. Electric commands are typically bound to special characters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 such as the left and right braces, colons, semi-colons, etc., which when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 typed, perform some magic formatting in addition to inserting the typed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 character. As a general rule, electric commands are only electric when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 the following conditions apply:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 @itemize @bullet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 Auto-newline minor mode is enabled, as evidenced by a @samp{C/a} or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 @samp{C/ah} indicator on the modeline.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 @cindex literal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 @cindex syntactic whitespace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 The character was not typed inside of a literal @footnote{A
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
620 @dfn{literal} is defined as any comment, string, or cpp macro
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
621 definition. These constructs are also known as @dfn{syntactic
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
622 whitespace} since they are usually ignored when scanning C code.}.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 @kindex C-u
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 No numeric argument was supplied to the command (i.e. it was typed as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 normal, with no @kbd{C-u} prefix).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 @end itemize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
631 @findex c-enable-//-in-c-mode
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
632 @findex enable-//-in-c-mode (c-)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
633 Some characters are electric in some languages, and not in others. For
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 example, the second slash (@kbd{/}) of a C++ style line comment is
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
635 electric in @code{c++-mode}, @code{objc-mode}, @code{java-mode}, and
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
636 @code{idl-mode}, but not in @code{c-mode}@footnote{Ordinarily, @samp{//}
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
637 does not introduce a comment in @code{c-mode}. However, if you call the
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
638 function @code{c-enable-//-in-c-mode}, @code{c-mode} will recognize C++
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
639 style line comments. Note however that this is a global change which
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
640 will affect all your @code{c-mode} buffers.}.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 * Hanging Braces::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 * Hanging Colons::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 * Hanging Semi-colons and commas::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 * Other electric commands::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 * Clean-ups::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 @node Hanging Braces, Hanging Colons, , Auto-newline insertion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 @subsection Hanging Braces
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 @cindex Hanging Braces
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 @findex c-electric-brace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 @findex electric-brace (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 @vindex c-hanging-braces-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 @vindex hanging-braces-alist (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 @vindex c-offsets-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 @vindex offsets-alist (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 When you type either an open or close brace (i.e. @kbd{@{} or @kbd{@}}),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 the electric command @code{c-electric-brace} gets run. This command has
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 two electric formatting behaviors. First, it will perform some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 re-indentation of the line the brace was typed on, and second, it will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 add various newlines before and/or after the typed brace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 Re-indentation occurs automatically whenever the electric behavior is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 enabled. If the brace ends up on a line other than the one it was typed
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
672 on, then that line is also indented according to
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 @code{c-offsets-alist}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 @cindex class-open syntactic symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 @cindex class-close syntactic symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 @cindex defun-open syntactic symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 @cindex defun-close syntactic symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 @cindex inline-open syntactic symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 @cindex inline-close syntactic symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 @cindex brace-list-open syntactic symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 @cindex brace-list-close syntactic symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 @cindex brace-list-intro syntactic symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 @cindex brace-list-entry syntactic symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 @cindex block-open syntactic symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 @cindex block-close syntactic symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 @cindex substatement-open syntactic symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 @cindex statement-case-open syntactic symbol
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
689 @cindex extern-lang-open syntactic symbol
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
690 @cindex extern-lang-close syntactic symbol
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 The insertion of newlines is controlled by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 @code{c-hanging-braces-alist} variable. This variable contains a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 mapping between syntactic symbols related to braces, and a list of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 places to insert a newline. The syntactic symbols that are useful for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 this list are: @code{class-open}, @code{class-close}, @code{defun-open},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 @code{defun-close}, @code{inline-open}, @code{inline-close},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 @code{brace-list-open}, @code{brace-list-close},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 @code{brace-list-intro}, @code{brace-list-entry}, @code{block-open},
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
700 @code{block-close}, @code{substatement-open},
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
701 @code{statement-case-open},
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
702 @code{extern-lang-open}, and @code{extern-lang-close}.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
703 @xref{Syntactic Symbols} for a more
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 detailed description of these syntactic symbols.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 @cindex custom indentation function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 The value associated with each syntactic symbol in this association list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 is called an @var{ACTION} which can be either a function or a list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 @xref{Custom Brace and Colon Hanging} for a more detailed discussion of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 using a function as a brace hanging @var{ACTION}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
712 When the @var{ACTION} is a list, it can contain any combination of the
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
713 symbols @code{before} and @code{after}, directing @ccmode{} where to
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 put newlines in relationship to the brace being inserted. Thus, if the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 list contains only the symbol @code{after}, then the brace is said to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 @dfn{hang} on the right side of the line, as in:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 // here, open braces always `hang'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 void spam( int i ) @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 if( i == 7 ) @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 dosomething(i);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 When the list contains both @code{after} and @code{before}, the braces
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 will appear on a line by themselves, as shown by the close braces in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 above example. The list can also be empty, in which case no newlines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 are added either before or after the brace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 For example, the default value of @code{c-hanging-braces-alist} is:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 (defvar c-hanging-braces-alist '((brace-list-open)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 (substatement-open after)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
742 (block-close . c-snug-do-while)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
743 (extern-lang-open after)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 which says that @code{brace-list-open} braces should both hang on the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 right side, and allow subsequent text to follow on the same line as the
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
751 brace. Also, @code{substatement-open} and @code{extern-lang-open}
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
752 braces should hang on the right side, but subsequent text should follow
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
753 on the next line. Here, in the @code{block-close} entry, you also see
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
754 an example of using a function as an @var{ACTION}.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
756 A word of caution: it is not a good idea to hang top-level construct
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
757 introducing braces, such as @code{class-open} or @code{defun-open}.
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
758 Emacs makes an assumption that such braces will always appear in column
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
759 zero, hanging such braces can introduce performance problems.
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
760 @xref{Performance Issues} for more information.
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
761
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 @node Hanging Colons, Hanging Semi-colons and commas, Hanging Braces, Auto-newline insertion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 @subsection Hanging Colons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 @cindex Hanging Colons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 @vindex hanging-colons-alist (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 @vindex c-hanging-colons-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 Using a mechanism similar to brace hanging (see @ref{Hanging Braces}),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 colons can also be made to hang using the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 @code{c-hanging-colons-alist}. The syntactic symbols appropriate for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 this assocation list are: @code{case-label}, @code{label},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 @code{access-label}, @code{member-init-intro}, and @code{inher-intro}.
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
778 Note however that for @code{c-hanging-colons-alist}, @var{ACTION}s as
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
779 functions are not supported. See also @ref{Custom Brace and Colon
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
780 Hanging} for details.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 @cindex clean-ups
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 In C++, double-colons are used as a scope operator but because these
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 colons always appear right next to each other, newlines before and after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 them are controlled by a different mechanism, called @dfn{clean-ups} in
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
786 @ccmode{}. @xref{Clean-ups} for details.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 @node Hanging Semi-colons and commas, Other electric commands, Hanging Colons, Auto-newline insertion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 @subsection Hanging Semi-colons and commas
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 @cindex Hanging Semi-colons and commas
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
797 Semicolons and commas are also electric in @ccmode{}, but since
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 these characters do not correspond directly to syntactic symbols, a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 different mechanism is used to determine whether newlines should be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 automatically inserted after these characters. @xref{Customizing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 Semi-colons and Commas} for details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 @node Other electric commands, Clean-ups, Hanging Semi-colons and commas, Auto-newline insertion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 @subsection Other electric commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 @cindex Other electric commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 @kindex #
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 @findex c-electric-pound
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 @vindex c-electric-pound-behavior
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 @findex electric-pound (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 @vindex electric-pound-behavior (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 @vindex c-offsets-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 @vindex offsets-alist (c-)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
819 A few other keys also provide electric behavior. For example
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
820 @kbd{#} (@code{c-electric-pound}) is electric when typed as
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 the first non-whitespace character on a line. In this case, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 variable @code{c-electric-pound-behavior} is consulted for the electric
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 behavior. This variable takes a list value, although the only element
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 currently defined is @code{alignleft}, which tells this command to force
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 the @samp{#} character into column zero. This is useful for entering
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 cpp macro definitions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 @findex c-electric-star
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 @findex c-electric-slash
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 @findex electric-star (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 @findex electric-slash (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 @cindex comment-only line
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
833 Stars and slashes (i.e. @kbd{*} and @kbd{/}, @code{c-electric-star} and
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
834 @code{c-electric-slash} respectively) are also electric under
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 certain circumstances. If a star is inserted as the second character of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 a C style block comment on a @dfn{comment-only} line, then the comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 delimiter is indented as defined by @code{c-offsets-alist}. A
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 comment-only line is defined as a line which contains only a comment, as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 in:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 void spam( int i )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 // this is a comment-only line...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 if( i == 7 ) // but this is not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 dosomething(i);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 Likewise, if a slash is inserted as the second slash in a C++ style line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 comment (also only on a comment-only line), then the line is indented as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 defined by @code{c-offsets-alist}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
859 @findex c-electric-lt-gt
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
860 @findex electric-lt-gt (c-)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
861 @kindex <
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
862 @kindex >
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
863 Less-than and greater-than signs (@code{c-electric-lt-gt}) are also
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
864 electric, but only in C++ mode. Hitting the second of two @kbd{<} or
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
865 @kbd{>} keys re-indents the line if it is a C++ style stream operator.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
866
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 @node Clean-ups, , Other electric commands, Auto-newline insertion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 @subsection Clean-ups
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 @cindex Clean-ups
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 @dfn{Clean-ups} are a mechanism complementary to colon and brace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 hanging. On the surface, it would seem that clean-ups overlap the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 functionality provided by the @code{c-hanging-*-alist} variables, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 similarly, clean-ups are only enabled when auto-newline minor mode is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 enabled. Clean-ups are used however to adjust code ``after-the-fact'',
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
881 i.e. to eliminate some whitespace that is inserted by electric
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 commands, or whitespace that contains intervening constructs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 @cindex literal
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
885 You can configure @ccmode{}'s clean-ups by setting the variable
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 @code{c-cleanup-list}, which is a list of clean-up symbols. By default,
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
887 @ccmode{} cleans up only the @code{scope-operator} construct, which
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 is necessary for proper C++ support. Note that clean-ups are only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 performed when the construct does not occur within a literal (see
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 @ref{Auto-newline insertion}), and when there is nothing but whitespace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 appearing between the individual components of the construct.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 @vindex c-cleanup-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 @vindex cleanup-list (c-)
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
895 There are currently only five specific constructs that @ccmode{}
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 can clean up, as indicated by these symbols:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 @itemize @bullet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 @item
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
900 @code{brace-else-brace} --- cleans up @samp{@} else @{} constructs by
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 placing the entire construct on a single line. Clean-up occurs when the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 open brace after the @samp{else} is typed. So for example, this:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 void spam(int i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 if( i==7 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 dosomething();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 appears like this after the open brace is typed:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 void spam(int i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 if( i==7 ) @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 dosomething();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 @} else @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 @item
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
932 @code{brace-elseif-brace} --- similar to the @code{brace-else-brace}
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
933 clean-up, but cleans up @samp{@} else if (...)@{} constructs. For
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
934 example:
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
935 @example
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
936 @group
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
937
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
938 void spam(int i)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
939 @{
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
940 if( i==7 )
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
941 @{
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
942 dosomething();
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
943 @}
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
944 else if( i==3 ) @{
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
945
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
946 @end group
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
947 @end example
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
948 @noindent
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
949 appears like this after the open brace is typed:
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
950 @example
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
951 @group
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
952
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
953 void spam(int i)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
954 @{
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
955 if( i==7 ) @{
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
956 dosomething();
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
957 @} else if( i==3 ) @{
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
958
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
959 @end group
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
960 @end example
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
961
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
962 @item
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
963 @code{empty-defun-braces} --- cleans up braces following a top-level
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 function or class definition that contains no body. Clean up occurs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 when the closing brace is typed. Thus the following:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 class Spam
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 is transformed into this when the close brace is typed:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 class Spam
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 @{@}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 @item
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
987 @code{defun-close-semi} --- cleans up the terminating semi-colon on
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 top-level function or class definitions when they follow a close
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 brace. Clean up occurs when the semi-colon is typed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 So for example, the following:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 class Spam
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 is transformed into this when the semi-colon is typed:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 class Spam
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 @};
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 @item
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1015 @code{list-close-comma} --- cleans up commas following braces in array
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 and aggregate initializers. Clean up occurs when the comma is typed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 @item
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1019 @code{scope-operator} --- cleans up double colons which may designate a
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 C++ scope operator split across multiple lines@footnote{Certain C++
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 constructs introduce ambiguous situations, so @code{scope-operator}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 clean-ups may not always be correct. This usually only occurs when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 scoped identifiers appear in switch label tags.}. Clean up occurs when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 the second colon is typed. You will always want @code{scope-operator}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 in the @code{c-cleanup-list} when you are editing C++ code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 @end itemize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 @node Hungry-deletion of whitespace, , Auto-newline insertion, Minor Modes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 @section Hungry-deletion of whitespace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 @cindex Hungry-deletion of whitespace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 Hungry deletion of whitespace, or as it more commonly called,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 @dfn{hungry-delete mode}, is a simple feature that some people find
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 extremely useful. In fact, you might find yourself wanting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 hungry-delete in @strong{all} your editing modes!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 @kindex DEL
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1044 @kindex Backspace
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1045 In a nutshell, when hungry-delete mode is enabled, hitting the
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1046 @kbd{Backspace} key@footnote{I say ``hit the @kbd{Backspace} key'' but
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1047 what I really mean is ``when Emacs receives the @code{BackSpace} keysym
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1048 event''. The difference usually isn't significant to most users, but
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1049 advanced users will realize that under window systems such as X, any
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1050 physical key (keycap) on the keyboard can be configured to generate any
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1051 keysym. Also, the use of Emacs on TTYs will affect which keycap
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1052 generates which keysym. From a pedantic point of view, here we are only
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1053 concerned with the keysym event that Emacs receives.} will consume all
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1054 preceding whitespace, including newlines and tabs. This can really cut
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1055 down on the number of @kbd{Backspace}'s you have to type if, for example
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1056 you made a mistake on the preceding line.
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1057
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1058 @findex c-electric-backspace
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1059 @findex electric-backspace (c-)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1060 @vindex c-backspace-function
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1061 @vindex backspace-function (c-)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 @findex c-electric-delete
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064 @findex electric-delete (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 @vindex c-delete-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 @vindex delete-function (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 @cindex literal
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1068
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1069 @findex backward-delete-char-untabify
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1070
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1071 By default, when you hit the @kbd{Backspace} key
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1072 @ccmode{} runs the command @code{c-electric-backspace}, which deletes
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1073 text in the backwards direction. When deleting a single character, or
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1074 when @kbd{Backspace} is hit in a literal
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1075 (see @ref{Auto-newline insertion}),
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1076 or when hungry-delete mode is disabled, the function
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1077 contained in the @code{c-backspace-function} variable is called with one
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1078 argument (the number of characters to delete). This variable is set to
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1079 @code{backward-delete-char-untabify} by default.
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1080
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1081 @vindex delete-key-deletes-forward
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1082 @findex delete-char
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1083
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1084 Similarly, hitting the @kbd{DEL} key runs the command
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1085 @code{c-electric-delete}. Some versions of Emacs@footnote{As of this
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1086 writing, 20-Jun-1997, only XEmacs 20.3 supports this.} support separation
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1087 of the @kbd{Backspace} and @kbd{DEL} keys, so that @kbd{DEL} will delete
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1088 in the forward direction when @code{delete-key-deletes-forward} is
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1089 non-@code{nil}. If your Emacs supports this, and
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1090 @code{delete-key-deletes-forward} is non-@code{nil}, and hungry-delete
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1091 mode is enabled, then @kbd{DEL} will consume all whitespace following
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1092 point. When deleting a single character, or when @kbd{DEL} is hit in a
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1093 literal, or when hungry-delete mode is disabled, the function contained
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1094 in the @code{c-delete-function} variable is called with one argument
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1095 (the number of characters to delete). This variable is set to
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1096 @code{delete-char} by default.
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1097
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1098 However, if @code{delete-key-deletes-forward} is @code{nil}, or your
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1099 Emacs does not support separation of @kbd{Backspace} and @kbd{DEL}, then
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1100 @code{c-electric-delete} simply calls @code{c-electric-backspace}.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1104 @node Commands, Customizing Indentation, Minor Modes, Top
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1107 @chapter Commands
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1108 @cindex Commands
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1109 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1110
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1111 @menu
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1112 * Indentation Commands::
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1113 * Other Commands::
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1114 @end menu
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1115
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1116 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1117 @node Indentation Commands, Other Commands, , Commands
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1118 @comment node-name, next, previous,up
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1119
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1120 @section Indentation Commands
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121 @cindex Indentation Commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 Various commands are provided which allow you to conveniently re-indent
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1125 C constructs. There are several things to
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126 note about these indentation commands. First, when you
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1127 change your programming style, either interactively or through some
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128 other means, your file does @emph{not} automatically get re-indented.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 When you change style parameters, you will typically need to reformat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 the line, expression, or buffer to see the effects of your changes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 @cindex c-hanging- functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 @findex c-hanging-braces-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 @findex hanging-braces-alist (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 Second, changing some variables have no effect on existing code, even
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1136 when you do re-indent. For example, the @code{c-hanging-*} variables
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1137 and @code{c-cleanup-list} only affect new code as it is typed in
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1138 on-the-fly, so changing @code{c-hanging-braces-alist} and re-indenting
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1139 the buffer will not adjust placement of braces already in the file.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 @vindex c-progress-interval
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142 @vindex progress-interval (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 Third, re-indenting large portions of code is currently rather
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 inefficient. Improvements have been made since previous releases of
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1145 @ccmode{}, and much more radical improvements are planned, but for now
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1146 you need to be aware of this @footnote{In particular, I have had people
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1147 complain about the speed with which @code{lex(1)} output is re-indented.
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1148 Lex, yacc, and other code generators usually output some pretty
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1149 perversely formatted code. @emph{Don't} try to indent this stuff!}.
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1150 Some provision has been made to at least inform you as to the progress
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1151 of the re-indentation. The variable @code{c-progress-interval} controls
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1152 how often a progress message is displayed. Set this variable to
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1153 @code{nil} to inhibit progress messages.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 Also, except as noted below, re-indentation is always driven by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 same mechanisms that control on-the-fly indentation of code. @xref{New
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 Indentation Engine} for details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 @findex c-indent-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 @findex indent-command (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 @vindex c-tab-always-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 @vindex tab-always-indent (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 @kindex TAB
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164 @cindex literal
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1165 @vindex indent-tabs-mode
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1166 @vindex c-insert-tab-function
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1167 @vindex insert-tab-function (c-)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1168 @findex tab-to-tab-stop
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 To indent a single line of code, use @kbd{TAB}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 (@code{c-indent-command}). The behavior of this command is controlled
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 by the variable @code{c-tab-always-indent}. When this variable is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172 @code{t}, @kbd{TAB} always just indents the current line. When
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1173 @code{nil}, the line is indented only if point is at the left margin, or
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1174 on or before the first non-whitespace character on the line, otherwise
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1175 @emph{something else happens}@footnote{Actually what happens is that the
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1176 function stored in @code{c-insert-tab-function} is called.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1177 Normally this just inserts a real tab character, or the equivalent
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1178 number of spaces, depending on the setting of the variable
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1179 @code{indent-tabs-mode}. If you preferred, you could set
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1180 @code{c-insert-tab-function} to @code{tab-to-tab-stop} for example.}.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1181 If the value of @code{c-tab-always-indent} is something other than
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1182 @code{t} or @code{nil} (e.g. @code{'other}), then a real tab
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1183 character@footnote{The caveat about @code{indent-tabs-mode} in the
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1184 previous footnote also applies here.} is inserted only when point is
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1185 inside a literal (see @ref{Auto-newline insertion}), otherwise the line
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1186 is indented.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188 @kindex M-C-q
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 @findex c-indent-exp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 @findex indent-exp (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 To indent an entire balanced brace or parenthesis expression, use
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1192 @kbd{M-C-q} (@code{c-indent-exp}). Note that point should be on
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 the opening brace or parenthesis of the expression you want to indent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 @kindex C-c C-q
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196 @findex c-indent-defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 @findex indent-defun (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198 Another very convenient keystroke is @kbd{C-c C-q}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199 (@code{c-indent-defun}) when re-indents the entire top-level function or
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1200 class definition that encompasses point. It leaves point at the
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201 same position within the buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203 @kindex M-C-\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204 @findex indent-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 To indent any arbitrary region of code, use @kbd{M-C-\}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206 (@code{indent-region}). This is a standard Emacs command, specially
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1207 tailored for C code in a @ccmode{} buffer. Note that of course,
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1208 point and mark must delineate the region you
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209 want to indent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211 @kindex M-C-h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212 @findex c-mark-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213 @findex mark-function (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 While not strictly an indentation function, @kbd{M-C-h}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215 (@code{c-mark-function}) is useful for marking the current top-level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 function or class definition as the current region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1218 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1219 @node Other Commands, , Indentation Commands, Commands
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1220 @comment node-name, next, previous,up
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1221
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1222 @section Other Commands
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1223 @cindex Other Commands
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1224 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1225
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1226 @ccmode{} contains other useful command for moving around in C
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1227 code.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1228
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1229 @table @code
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1230 @item C-c C-u (c-up-conditional)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1231 @kindex C-c C-u
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1232 @findex c-up-conditional
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1233 @findex up-conditional (c-)
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1234 Move point back to the containing preprocessor conditional, leaving the
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1235 mark behind. A prefix argument acts as a repeat count. With a negative
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1236 argument, move point forward to the end of the containing
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1237 preprocessor conditional. When going backwards, @code{#elif} is treated
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1238 like @code{#else} followed by @code{#if}. When going forwards,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1239 @code{#elif} is ignored.@refill
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1240
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1241 @item C-c C-p (c-backward-conditional)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1242 @kindex C-c C-p
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1243 @findex c-backward-conditional
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1244 @findex backward-conditional (c-)
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1245 Move point back over a preprocessor conditional, leaving the mark
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1246 behind. A prefix argument acts as a repeat count. With a negative
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1247 argument, move forward.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1248
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1249 @item C-c C-n (c-forward-conditional)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1250 @kindex C-c C-n
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1251 @findex c-forward-conditional
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1252 @findex forward-conditional (c-)
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1253 Move point forward across a preprocessor conditional, leaving the mark
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1254 behind. A prefix argument acts as a repeat count. With a negative
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1255 argument, move backward.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1256
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1257 @item M-a (c-beginning-of-statement)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1258 @kindex ESC a
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1259 @findex c-beginning-of-statement
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1260 @findex beginning-of-statement (c-)
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1261 Move point to the beginning of the innermost C statement. If point is
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1262 already at the beginning of a statement, it moves to the beginning of
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1263 the preceding statement. With prefix argument @var{n}, move back
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1264 @var{n} @minus{} 1 statements.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1265
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1266 If point is within a string or comment, or at the end of a comment, this
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1267 command moves by sentences instead of statements.
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1268
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1269 When called from a program, this function takes three optional
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1270 arguments: the numeric prefix argument, a buffer position limit (don't
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1271 move back before that place), and a flag to indicate whether movement
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1272 should be by statements (if @code{t}) or sentence (if non-@code{nil}).
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1273
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1274 @item M-e (c-end-of-statement)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1275 @kindex ESC e
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1276 @findex c-end-of-statement
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1277 @findex end-of-statement (c-)
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1278 Move point to the end of the innermost C statement. If point is at the
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1279 end of a statement, move to the end of the next statement. With prefix
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1280 argument @var{n}, move forward @var{n} @minus{} 1 statements.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1281
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1282 If point is within a string or comment, or at the end of a comment, this
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1283 command moves by sentences instead of statements.
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1284
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1285 When called from a program, this function takes three optional
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1286 arguments: the numeric prefix argument, a buffer position limit (don't
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1287 move back before that place), and a flag to indicate whether movement
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1288 should be by statements (if @code{t}) or sentence (if non-@code{nil}).
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1289
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1290 @item M-x c-forward-into-nomenclature
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1291 @findex c-forward-into-nomenclature
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1292 @findex forward-into-nomenclature (c-)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1293 A popular programming style, especially for object-oriented languages
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1294 such as C++ is to write symbols in a mixed case format, where the first
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1295 letter of each word is capitalized, and not separated by underscores.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1296 E.g. @samp{SymbolsWithMixedCaseAndNoUnderlines}.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1297
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1298 This command moves point forward to next capitalized word. With prefix
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1299 argument @var{n}, move @var{n} times.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1300
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1301 @item M-x c-backward-into-nomenclature
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1302 @findex c-backward-into-nomenclature
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1303 @findex backward-into-nomenclature (c-)
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1304 Move point backward to beginning of the next capitalized
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1305 word. With prefix argument @var{n}, move @var{n} times. If
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1306 @var{n} is negative, move forward.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1307
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1308 @kindex C-c :
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1309 @findex c-scope-operator
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1310 @findex scope-operator (c-)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1311 @item C-c : (c-scope-operator)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1312 In C++, it is also sometimes desirable to insert the double-colon scope
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1313 operator without performing the electric behavior of colon insertion.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1314 @kbd{C-c :} does just this.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1315
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1316 @item M-q (fill-paragraph)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1317 @kindex ESC q
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1318 @findex fill-paragraph
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1319 @vindex c-hanging-comment-starter-p
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1320 @vindex c-hanging-comment-ender-p
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1321 @vindex hanging-comment-starter-p (c-)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1322 @vindex hanging-comment-ender-p (c-)
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1323
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1324 The command is used to fill a block style (C) or line style (C++)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1325 comment, in much the same way that text in the various text modes can be
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1326 filled@footnote{You should not use specialized filling packages such as
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1327 @code{filladapt} with CC Mode. They don't work as well for filling as
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1328 @code{c-fill-paragraph}}. You should never attempt to fill non-comment
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1329 code sections; you'll end up with garbage! Two variables control how C
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1330 style block comments are filled, specifically how the comment start and
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1331 end delimiters are handled.
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1332
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1333 The variable @code{c-hanging-comment-starter-p} controls whether comment
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1334 start delimiters which appear on a line by themselves, end up on a line
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1335 by themselves after the fill. When the value is @code{nil}, the comment
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1336 starter will remain on its own line@footnote{It will not be placed on a
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1337 separate line if it is not already on a separate line.}. Otherwise,
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1338 text on the next line will be put on the same line as the comment
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1339 starter. This is called @dfn{hanging} because the following text hangs
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1340 on the line with the comment starter@footnote{This variable is @code{t}
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1341 by default, except in @code{java-mode}. Hanging comment starters mess
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1342 up Javadoc style comments.}
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1343
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1344 The variable @code{c-hanging-comment-ender-p} controls the analogous
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1345 behavior for the block comment end delimiter. When the value is
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1346 @code{nil}, the comment ender will remain on its own line after the
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1347 file@footnote{The same caveat as above holds true.}. Otherwise, the
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1348 comment end delimiter will be placed at the end of the previous line.
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1349
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1350 @end table
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1351
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1352 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1353 @node Customizing Indentation, Syntactic Symbols, Commands, Top
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1354 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1355
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1356 @chapter Customizing Indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1357 @cindex Customizing Indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1358 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1359
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1360 @vindex c-offsets-alist
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1361 @vindex offsets-alist (c-)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1362 @cindex c-set-offset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1363 @cindex set-offset (c-)
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1364 The variable @code{c-offsets-alist} contains the mappings between
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1365 syntactic symbols and the offsets to apply for those symbols. You
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1366 should never modify this variable directly though. Use the function
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1367 @code{c-set-offset} instead (see below for details).
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1368
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1369 The @code{c-offsets-alist} variable is where you customize all your
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1370 indentations. You simply need to decide what additional offset you want
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1371 to add for every syntactic symbol. You can use the command @kbd{C-c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1372 C-o} (@code{c-set-offset}) as the way to set offsets, both interactively
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1373 and from your mode hook. Also, you can set up @emph{styles} of
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1374 indentatio. Most likely, you'll
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1375 find one of the pre-defined styles will suit your needs, but if not,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1376 this section will describe how to set up basic editing configurations.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1377 @xref{Styles} for an explanation of how to set up named styles.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1378
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1379 @cindex c-basic-offset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1380 @cindex basic-offset (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1381 As mentioned previously, the variable @code{c-offsets-alist} is an
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1382 association list of syntactic symbols and the offsets to be applied for
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1383 those symbols. In fact, these offset values can be any of an integer, a
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1384 function or lambda expression, a variable name, or one of the following
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1385 symbols: @code{+}, @code{-}, @code{++}, @code{--}, @code{*}, or
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1386 @code{/}. These symbols describe offset in multiples of the value of
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1387 the variable @code{c-basic-offset}. By defining a style's indentation
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1388 in terms of this fundamental variable, you can change the amount of
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1389 whitespace given to an indentation level while leaving the same
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1390 relationship between levels. Here are the values that the special
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1391 symbols correspond to:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1392
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1393 @table @code
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1394
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1395 @item +
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1396 @code{c-basic-offset} times 1
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1397 @item -
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1398 @code{c-basic-offset} times -1
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1399 @item ++
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1400 @code{c-basic-offset} times 2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1401 @item --
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1402 @code{c-basic-offset} times -2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1403 @item *
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1404 @code{c-basic-offset} times 0.5
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1405 @item /
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1406 @code{c-basic-offset} times -0.5
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1407
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1408 @end table
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1409
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1410 @vindex c-style-variables-are-local-p
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1411 @vindex style-variables-are-local-p (c-)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1412 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1413 So, for example, because most of the default offsets are defined in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1414 terms of @code{+}, @code{-}, and @code{0}, if you like the general
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1415 indentation style, but you use 4 spaces instead of 2 spaces per level,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1416 you can probably achieve your style just by changing
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1417 @code{c-basic-offset} like so (in your @file{.emacs} file):
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1418 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1419
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1420 (setq c-basic-offset 4)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1421
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1422 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1423
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1424 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1425 This would change
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1426 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1427 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1428
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1429 int add( int val, int incr, int doit )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1430 @{
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1431 if( doit )
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1432 @{
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1433 return( val + incr );
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1434 @}
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1435 return( val );
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1436 @}
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1437
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1438 @end group
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1439 @end example
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1440 @noindent
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1441 to
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1442 @example
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1443 @group
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1444
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1445 int add( int val, int incr, int doit )
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1446 @{
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1447 if( doit )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1448 @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1449 return( val + incr );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1450 @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1451 return( val );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1452 @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1453
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1454 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1455 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1456
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1457
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1458 To change indentation styles more radically, you will want to change the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1459 value associated with the syntactic symbols in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1460 @code{c-offsets-alist} variable. First, I'll show you how to do that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1461 interactively, then I'll describe how to make changes to your
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1462 @file{.emacs} file so that your changes are more permanent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1463
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1464 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1465 * Interactive Customization::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1466 * Permanent Customization::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1467 * Styles::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1468 * Advanced Customizations::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1469 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1470
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1471 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1472 @node Interactive Customization, Permanent Customization, , Customizing Indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1473 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1474
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1475 @section Interactive Customization
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1476 @cindex Interactive Customization
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1477 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1478
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1479 As an example of how to customize indentation, let's change the
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1480 style of this example@footnote{In this an subsequent examples, the
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1481 original code is formatted using the @samp{gnu} style unless otherwise
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1482 indicated. @xref{Styles}.}:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1483 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1484 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1485
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1486 1: int add( int val, int incr, int doit )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1487 2: @{
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1488 3: if( doit )
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1489 4: @{
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1490 5: return( val + incr );
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1491 6: @}
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1492 7: return( val );
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1493 8: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1494
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1495 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1496 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1497 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1498 to:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1499 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1500 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1501
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1502 1: int add( int val, int incr, int doit )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1503 2: @{
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1504 3: if( doit )
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1505 4: @{
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1506 5: return( val + incr );
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1507 6: @}
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1508 7: return( val );
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1509 8: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1510
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1511 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1512 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1513
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1514 In other words, we want to change the indentation of braces that open a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1515 block following a condition so that the braces line up under the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1516 conditional, instead of being indented. Notice that the construct we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1517 want to change starts on line 4. To change the indentation of a line,
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1518 we need to see which syntactic components affect the offset calculations
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1519 for that line. Hitting @kbd{C-c C-s} on line 4 yields:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1520 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1521
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1522 ((substatement-open . 44))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1523
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1524 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1525
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1526 @findex c-set-offset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1527 @findex set-offset (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1528 @kindex C-c C-o
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1529 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1530 so we know that to change the offset of the open brace, we need to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1531 change the indentation for the @code{substatement-open} syntactic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1532 symbol. To do this interactively, just hit @kbd{C-c C-o}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1533 (@code{c-set-offset}). This prompts you for the syntactic symbol to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1534 change, providing a reasonable default. In this case, the default is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1535 @code{substatement-open}, which is just the syntactic symbol we want to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1536 change!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1537
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1538 After you hit return, @ccmode{} will then prompt you for the new
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1539 offset value, with the old value as the default. The default in this
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1540 case is @samp{+}, but we want no extra indentation so enter
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1541 @samp{0} and @kbd{RET}. This will associate the offset 0 with the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1542 syntactic symbol @code{substatement-open} in the @code{c-offsets-alist}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1543 variable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1544
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1545 @findex c-indent-defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1546 @findex indent-defun (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1547 @kindex C-c C-q
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1548 To check your changes quickly, just hit @kbd{C-c C-q}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1549 (@code{c-indent-defun}) to reindent the entire function. The example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1550 should now look like:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1551 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1552 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1553
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1554 1: int add( int val, int incr, int doit )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1555 2: @{
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1556 3: if( doit )
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1557 4: @{
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1558 5: return( val + incr );
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1559 6: @}
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1560 7: return( val );
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1561 8: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1562
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1563 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1564 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1565
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1566 Notice how just changing the open brace offset on line 4 is all we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1567 needed to do. Since the other affected lines are indented relative to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1568 line 4, they are automatically indented the way you'd expect. For more
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1569 complicated examples, this may not always work. The general approach to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1570 take is to always start adjusting offsets for lines higher up in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1571 file, then re-indent and see if any following lines need further
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1572 adjustments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1573
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1574 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1575 @node Permanent Customization, Styles, Interactive Customization, Customizing Indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1576 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1577
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1578 @section Permanent Customization
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1579 @cindex Permanent Customization
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1580 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1581
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1582 @vindex c-mode-common-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1583 @vindex c-mode-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1584 @vindex c++-mode-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1585 @vindex objc-mode-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1586 @vindex java-mode-hook
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1587 @vindex idl-mode-hook
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1588 @vindex c-initialization-hook
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1589 @vindex initialization-hook (c-)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1590 @cindex hooks
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1591 To make your changes permanent, you need to add some lisp code to your
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1592 @file{.emacs} file, but first you need to decide whether your styles
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1593 should be global in every buffer, or local to each specific buffer.
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1594
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1595 If you edit primarily one style of code, you may want to make the
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1596 @ccmode{} style variables have global values so that every buffer will
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1597 share the style settings. This will allow you to set the @ccmode{}
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1598 variables at the top level of your @file{.emacs} file, and is the
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1599 way @ccmode{} works by default.
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1600
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1601 @vindex c-mode-common-hook
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1602 @vindex mode-common-hook (c-)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1603 @vindex c-style-variables-are-local-p
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1604 @vindex style-variables-are-local-p (c-)
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1605 If you edit many different styles of code at
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1606 the same time, you might want to make the @ccmode{} style variables
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1607 have buffer local values. If you do this, then you will need to set any
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1608 @ccmode{} style variables in a hook function (e.g. off of
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1609 @code{c-mode-common-hook} instead of at the top level of your
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1610 @file{.emacs} file. The recommended way to do this is to set the
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1611 variable @code{c-style-variables-are-local-p} to @code{t}
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1612 @strong{before} @ccmode{} is loaded into your Emacs session.
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1613
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1614 @ccmode{} provides several hooks that you can
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1615 use to customize the mode according to your coding style. Each language
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1616 mode has its own hook, adhering to standard Emacs major mode
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1617 conventions. There is also one general hook and one package
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1618 initialization hook:
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1619
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1620 @itemize @bullet
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1621
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1622 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1623 @code{c-mode-hook} --- for C buffers only
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1624 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1625 @code{c++-mode-hook} --- for C++ buffers only
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1626 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1627 @code{objc-mode-hook} --- for Objective-C buffers only
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1628 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1629 @code{java-mode-hook} --- for Java buffers only
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1630 @item
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1631 @code{idl-mode-hook} --- for IDL buffers only
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1632 @item
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1633 @code{c-mode-common-hook} --- common across all languages
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1634 @item
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1635 @code{c-initialization-hook} --- hook run only once per Emacs session,
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1636 when @ccmode{} is initialized.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1637
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1638 @end itemize
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1639
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1640 The language hooks get run as the last thing when you enter that
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1641 language mode. The @code{c-mode-common-hook} is run by all
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1642 supported modes @emph{before} the language specific hook, and thus can
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1643 contain customizations that are common across all languages. Most of
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1644 the examples in this section will assume you are using the common
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1645 hook@footnote{The interaction between @code{java-mode} and the hook
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1646 variables is slightly different than for the other modes.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1647 @code{java-mode} sets the style (see @ref{Styles}) of the buffer to
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1648 @samp{java} @emph{before} running the @code{c-mode-common-hook} or
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1649 @code{java-mode-hook}. You need to be aware of this so that style
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1650 settings in @code{c-mode-common-hook} don't clobber your Java style.}.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1651
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1652 Here's a simplified example of what you can add to your @file{.emacs}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1653 file to make the changes described in the previous section
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1654 (@ref{Interactive Customization}) more permanent. See the Emacs manuals
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1655 for more information on customizing Emacs via hooks. @xref{Sample
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1656 .emacs File} for a more complete sample @file{.emacs} file.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1657 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1658 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1659
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1660 (defun my-c-mode-common-hook ()
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1661 ;; my customizations for all of c-mode and related modes
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1662 (c-set-offset 'substatement-open 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1663 ;; other customizations can go here
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1664 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1665 (add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1666
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1667 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1668 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1669
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1670 For complex customizations, you will probably want to set up a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1671 @emph{style} that groups all your customizations under a single
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1672 name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1673
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1674 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1675 @node Styles, Advanced Customizations, Permanent Customization, Customizing Indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1676 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1677
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1678 @section Styles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1679 @cindex Styles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1680 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1681
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1682 Most people only need to edit code formatted in just a few well-defined
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1683 and consistent styles. For example, their organization might impose a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1684 ``blessed'' style that all its programmers must conform to. Similarly,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1685 people who work on GNU software will have to use the GNU coding style on
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1686 C code. Some shops are more lenient, allowing a variety of coding
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1687 styles, and as programmers come and go, there could be a number of
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1688 styles in use. For this reason, @ccmode{} makes it convenient for
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1689 you to set up logical groupings of customizations called @dfn{styles},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1690 associate a single name for any particular style, and pretty easily
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1691 start editing new or existing code using these styles. This section
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1692 describes how to set up styles and how to edit your C code using styles.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1693
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1694 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1695 * Built-in Styles::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1696 * Adding Styles::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1697 * File Styles::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1698 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1699
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1700
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1701 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1702 @node Built-in Styles, Adding Styles, , Styles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1703 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1704
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1705 @subsection Built-in Styles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1706 @cindex Built-in Styles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1707 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1708
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1709 If you're lucky, one of @ccmode{}'s built-in styles might be just
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1710 what you're looking for. These include:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1711
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1712 @itemize @bullet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1713 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1714 @cindex GNU style
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1715 @code{gnu} --- coding style blessed by the Free Software Foundation
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1716 for C code in GNU programs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1717
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1718 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1719 @cindex K&R style
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1720 @code{k&r} --- The classic Kernighan and Ritchie style for C code.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1721
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1722 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1723 @cindex BSD style
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1724 @code{bsd} --- Also known as ``Allman style'' after Eric Allman.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1725
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1726 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1727 @cindex Whitesmith style
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1728 @code{whitesmith} --- Popularized by the examples that came with
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1729 Whitesmiths C, an early commercial C compiler.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1730
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1731 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1732 @cindex Stroustrup style
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1733 @code{stroustrup} --- The classic Stroustrup style for C++ code.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1734
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1735 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1736 @cindex Ellemtel style
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1737 @code{ellemtel} --- Popular C++ coding standards as defined by
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1738 ``Programming in C++, Rules and Recommendations'', Erik Nyquist and Mats
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1739 Henricson, Ellemtel @footnote{This document is ftp'able from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1740 @code{euagate.eua.ericsson.se}}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1741
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1742 @item
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1743 @cindex Linux style
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1744 @code{linux} --- C coding standard for Linux development.
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1745
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1746 @item
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1747 @cindex Python style
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1748 @code{python} --- C coding standard for Python extension
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1749 modules@footnote{Python is a high level scripting language with a C/C++
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1750 foreign function interface. For more information, see
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1751 @code{<http://www.python.org/>}.}.
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1752
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1753 @item
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1754 @cindex Java style
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1755 @cindex java-mode
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1756 @code{java} --- The style for editing Java code. Note that this style is
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1757 automatically installed when you enter @code{java-mode}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1758
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1759 @end itemize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1760
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1761 @findex c-set-style
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1762 @findex set-style (c-)
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1763 @kindex C-c .
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1764 If you'd like to experiment with these built-in styles you can simply
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1765 type the following in a @ccmode{} buffer:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1766 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1767 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1768
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1769 @kbd{C-c . @var{STYLE-NAME} RET}
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1770
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1771 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1772 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1773 @noindent
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1774 @kbd{C-c .} runs the command @code{c-set-style}. Note that all style
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1775 names are case insensitive, even the ones you define.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1776
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1777 Setting a style in this way does @emph{not} automatically re-indent your
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1778 file. For commands that you can use to view the effect of your changes,
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1779 see @ref{Commands}.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1780
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1781 Once you find a built-in style you like, you can make the change
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1782 permanent by adding some lisp to your @file{.emacs} file. Let's say for
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1783 example that you want to use the @samp{ellemtel} style in all your
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1784 files. You would add this:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1785 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1786 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1787
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1788 (defun my-c-mode-common-hook ()
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1789 ;; use Ellemtel style for all C like languages
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1790 (c-set-style "ellemtel")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1791 ;; other customizations can go here
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1792 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1793 (add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1794
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1795 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1796 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1797
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1798 @cindex cc-mode style
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1799 There is one other special style you can use, called @samp{cc-mode}
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1800 style. This style is special because all other styles implicitly
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1801 inherit from it; in other words, whenever you set a style,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1802 @samp{cc-mode} is applied before the one you selected. This means
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1803 your style need only define the differences between it and
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1804 @samp{cc-mode} style.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1805
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1806 Note @emph{you should never change any of the default styles}.
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1807 Instead, it's better to add a new style using @code{c-add-style}
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1808 (@xref{Adding Styles}). This is especially true for @code{cc-mode} and
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1809 @code{java} styles.
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1810
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1811 @vindex c-indentation-style
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1812 @vindex indentation-style (c-)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1813 Note that for BOCM compatibility, @samp{gnu} is the default
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1814 style, and any non-style based customizations you make (i.e. in
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1815 @code{c-mode-common-hook} in your
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1816 @file{.emacs} file) will be based on @samp{gnu} style unless you do
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1817 a @code{c-set-style} as the first thing in your hook. The variable
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1818 @code{c-indentation-style} always contains the buffer's current style name,
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1819 as a string.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1820
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1821
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1822 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1823 @node Adding Styles, File Styles, Built-in Styles, Styles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1824 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1825
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1826 @subsection Adding Styles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1827 @cindex Adding Styles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1828 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1829
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1830 @vindex c-style-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1831 @vindex style-alist (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1832 @findex c-add-style
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1833 @findex add-style (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1834 If none of the built-in styles is appropriate, you'll probably want to
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1835 add a new @dfn{style definition}. Styles are kept in the
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1836 @code{c-style-alist} variable, but you should never modify this variable
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1837 directly. Instead, @ccmode{} provides the function
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1838 @code{c-add-style} that you can use to easily add new styles or change
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1839 existing styles. This function takes two arguments, a @var{stylename}
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1840 string, and an association list @var{description} of style
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1841 customizations. If @var{stylename} is not already in
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1842 @code{c-style-alist}, the new style is added, otherwise the style is
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1843 changed to the new @var{description}.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1844 This function also takes an optional third argument, which if
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1845 non-@code{nil}, automatically applies the new style to the current
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1846 buffer.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1847
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1848 @comment TBD: The next paragraph is bogus. I really need to better
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1849 @comment document adding styles, including setting up inherited styles.
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1850
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1851 The sample @file{.emacs} file provides a concrete example of how a new
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1852 style can be added and automatically set. @xref{Sample .emacs File}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1853
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1854 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1855 @node File Styles, , Adding Styles, Styles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1856 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1857
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1858 @subsection File Styles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1859 @cindex File Styles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1860 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1861
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1862 @cindex local variables
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1863
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1864 The Emacs manual describes how you can customize certain variables on a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1865 per-file basis by including a @dfn{Local Variable} block at the end of
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1866 the file. So far, you've only seen a functional interface to @ccmode{}
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1867 customization, which is highly inconvenient for use in a Local Variable
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1868 block. @ccmode{} provides two variables that make it easier for you to
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1869 customize your style on a per-file basis@footnote{Note that file styles
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1870 don't work with Emacs versions before XEmacs 19.12 and Emacs 19.29.
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1871 File styles work via the standard Emacs hook variable
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1872 @code{hack-local-variables-hook}.}.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1873
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1874 @vindex c-file-style
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1875 @vindex file-style (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1876 @vindex c-file-offsets
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1877 @vindex file-offsets (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1878
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1879 The variable @code{c-file-style} can be set to a style name string.
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1880 When the file is visited, @ccmode{} will automatically set the
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1881 file's style to this style using @code{c-set-style}.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1882
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1883 @vindex c-offsets-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1884 @vindex offsets-alist (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1885 @findex c-set-offset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1886 @findex set-offset (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1887 Another variable, @code{c-file-offsets}, takes an association list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1888 similar to what is allowed in @code{c-offsets-alist}. When the file is
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1889 visited, @ccmode{} will automatically institute these offets using
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1890 @code{c-set-offset}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1891
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1892 Note that file style settings (i.e. @code{c-file-style}) are applied
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1893 before file offset settings (i.e. @code{c-file-offsets}).
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1894
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1895
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1896 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1897 @node Advanced Customizations, , Styles, Customizing Indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1898 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1899
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1900 @section Advanced Customizations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1901 @cindex Advanced Customizations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1902 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1903
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1904 @vindex c-style-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1905 @vindex style-alist (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1906 @vindex c-basic-offset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1907 @vindex basic-offset (c-)
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1908 For most users, @ccmode{} will support their coding styles with
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1909 very little need for more advanced customizations. Usually, one of the
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1910 standard styles defined in @code{c-style-alist} will do the trick. At
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1911 most, perhaps one of the syntactic symbol offsets will need to be
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1912 tweaked slightly, or maybe @code{c-basic-offset} will need to be
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1913 changed. However, some styles require a more flexible framework for
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1914 customization, and one of the real strengths of @ccmode{} is that
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1915 the syntactic analysis model provides just such a framework. This allows
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1916 you to implement custom indentation calculations for situations not
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1917 handled by the mode directly.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1918
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1919 @vindex c-style-variables-are-local-p
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1920 @vindex style-variables-are-local-p
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1921 Note that the style controlling variables can either have global values,
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1922 or can be buffer local (e.g. different in every buffer). If all the C
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1923 files you edit tend to have the same style, you might want to keep the
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1924 variables global. If you tend to edit files with many different styles,
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1925 you will have to make the variables buffer local. The variable
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1926 @code{c-style-variables-are-local-p} controls this.
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1927
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1928 When @code{c-style-variables-are-local-p} is non-nil, then the style
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1929 variables will have a different settable value for each buffer,
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1930 otherwise all buffers will share the same values. By default, its value
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1931 is @code{nil} (i.e. global values). You @strong{must} set this variable
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1932 before @ccmode{} is loaded into your Emacs session, and once the
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1933 variables are made buffer local, they cannot be made global again
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
1934 (unless you restart Emacs of course!)
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1935
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1936 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1937 * Custom Indentation Functions::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1938 * Custom Brace and Colon Hanging::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1939 * Customizing Semi-colons and Commas::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1940 * Other Special Indentations::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1941 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1942
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1943 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1944 @node Custom Indentation Functions, Custom Brace and Colon Hanging, , Advanced Customizations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1945 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1946
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1947 @subsection Custom Indentation Functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1948 @cindex Custom Indentation Functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1949 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1950
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1951 @cindex custom indentation functions
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1952 The most flexible way to customize @ccmode{} is by writing @dfn{custom
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1953 indentation functions} and associating them with specific syntactic
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1954 symbols (see @ref{Syntactic Symbols}). @ccmode{} itself uses custom
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1955 indentation functions to provide more sophisticated indentation, for
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
1956 example when lining up C++ stream operator blocks:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1957 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1958 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1959
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1960 1: void main(int argc, char**)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1961 2: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1962 3: cout << "There were "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1963 4: << argc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1964 5: << "arguments passed to the program"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1965 6: << endl;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1966 7: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1967
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1968 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1969 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1970
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1971 In this example, lines 4 through 6 are assigned the @code{stream-op}
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1972 syntactic symbol. Here, @code{stream-op} has an offset of @code{+}, and
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1973 with a @code{c-basic-offset} of 2, you can see that lines 4 through 6
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1974 are simply indented two spaces to the right of line 3. But perhaps we'd
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1975 like @ccmode{} to be a little more intelligent so that it aligns
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1976 all the @samp{<<} symbols in lines 3 through 6. To do this, we have
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1977 to write a custom indentation function which finds the column of first
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1978 stream operator on the first line of the statement. Here is sample
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
1979 lisp code implementing this:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1980 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1981 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1982
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1983 (defun c-lineup-streamop (langelem)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1984 ;; lineup stream operators
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1985 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1986 (let* ((relpos (cdr langelem))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1987 (curcol (progn (goto-char relpos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1988 (current-column))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1989 (re-search-forward "<<\\|>>" (c-point 'eol) 'move)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1990 (goto-char (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1991 (- (current-column) curcol))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1992
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1993 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1994 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1995 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1996 Custom indent functions take a single argument, which is a syntactic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1997 component cons cell (see @ref{Syntactic Analysis}). The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1998 function returns an integer offset value that will be added to the
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1999 running total indentation for the line. Note that what actually gets
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2000 returned is the difference between the column that the first stream
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2001 operator is on, and the column of the buffer relative position passed in
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
2002 the function's argument. Remember that @ccmode{} automatically
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2003 adds in the column of the component's relative buffer position and we
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
2004 don't the column offset added in twice.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2005
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2006 @cindex stream-op syntactic symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2007 @findex c-lineup-streamop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2008 @findex lineup-streamop (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2009 Now, to associate the function @code{c-lineup-streamop} with the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2010 @code{stream-op} syntactic symbol, we can add something like the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2011 following to our @code{c++-mode-hook}@footnote{It probably makes more
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2012 sense to add this to @code{c++-mode-hook} than @code{c-mode-common-hook}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2013 since stream operators are only relevent for C++.}:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2014 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2015
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2016 (c-set-offset 'stream-op 'c-lineup-streamop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2017
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2018 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2019
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2020 @kindex C-c C-q
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2021 Now the function looks like this after re-indenting (using @kbd{C-c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2022 C-q}):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2023 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2024 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2025
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2026 1: void main(int argc, char**)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2027 2: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2028 3: cout << "There were "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2029 4: << argc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2030 5: << "arguments passed to the program"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2031 6: << endl;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2032 7: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2033
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2034 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2035 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2036
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2037 @vindex c-offsets-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2038 @vindex offsets-alist (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2039 Custom indentation functions can be as simple or as complex as you like,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2040 and any syntactic symbol that appears in @code{c-offsets-alist} can have
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
2041 a custom indentation function associated with it. @ccmode{} comes
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2042 with several standard custom indentation functions, not all of which are
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2043 used by the default styles.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2044
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2045 @itemize @bullet
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2046 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2047 @findex c-lineup-arglist
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2048 @findex lineup-arglist (c-)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2049 @code{c-lineup-arglist} --- lines up function argument lines under the
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2050 argument on the previous line.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2051
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2052 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2053 @findex c-lineup-arglist-intro-after-paren
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2054 @findex lineup-arglist-intro-after-paren (c-)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2055 @code{c-lineup-arglist-intro-after-paren} --- similar to
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2056 @code{c-lineup-arglist}, but works for argument lists that begin with an
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2057 open parenthesis followed by a newline.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2058
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2059 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2060 @findex c-lineup-arglist-close-under-paren
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2061 @findex lineup-arglist-close-under-paren (c-)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2062 @code{c-lineup-arglist-close-under-paren} --- set your
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2063 @code{arglist-close} syntactic symbol to this line-up function so that
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2064 parentheses that close argument lists will line up under the parenthesis
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2065 that opened the argument list.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2066
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2067 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2068 @findex c-lineup-streamop
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2069 @findex lineup-streamop (c-)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2070 @code{c-lineup-streamop} --- lines up C++ stream operators
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2071 (e.g. @samp{<<} and @samp{>>}).
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2072
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2073 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2074 @findex c-lineup-multi-inher
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2075 @findex lineup-multi-inher (c-)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2076 @code{c-lineup-multi-inher} --- lines up multiple inheritance lines.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2077
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2078 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2079 @findex c-lineup-C-comments
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2080 @findex lineup-C-comments (c-)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2081 @code{c-lineup-C-comments} --- lines up C block comment continuation
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2082 lines.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2083
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2084 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2085 @findex c-lineup-comment
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2086 @findex lineup-comment (c-)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2087 @vindex c-comment-only-line-offset
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2088 @vindex comment-only-line-offset (c-)
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
2089 @code{c-lineup-comment} --- lines up comment only lines according to
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
2090 the variable @code{c-comment-only-line-offset}.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2091
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2092 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2093 @findex c-lineup-runin-statements
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2094 @findex lineup-runin-statements (c-)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2095 @code{c-lineup-runin-statements} --- lines up @code{statement}s for coding
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2096 standards which place the first statement in a block on the same line as
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
2097 the block opening brace@footnote{Run-in style doesn't really work too
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
2098 well. You might need to write your own custom indentation functions to
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
2099 better support this style.}.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2100
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2101 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2102 @findex c-lineup-math
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2103 @findex lineup-math (c-)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2104 @code{c-lineup-math} --- lines up math @code{statement-cont} lines under
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2105 the previous line after the equals sign.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2106
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2107 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2108 @findex c-lineup-ObjC-method-call
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2109 @findex lineup-ObjC-method-call (c-)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2110 @code{c-lineup-ObjC-method-call} --- for Objective-C code, lines up
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2111 selector arguments just after the message receiver.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2112
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2113 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2114 @findex c-lineup-ObjC-method-args
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2115 @findex lineup-ObjC-method-args (c-)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2116 @code{c-lineup-ObjC-method-args} --- for Objective-C code, lines up the
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2117 colons that separate arguments by aligning colons vertically.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2118
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2119 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2120 @findex c-lineup-ObjC-method-args-2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2121 @findex lineup-ObjC-method-args-2 (c-)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2122 @code{c-lineup-ObjC-method-args-2} --- similar to
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2123 @code{c-lineup-ObjC-method-args} but lines up the colon on the current
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2124 line with the colon on the previous line.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2125
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2126 @end itemize
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2127
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2128 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2129 @node Custom Brace and Colon Hanging, Customizing Semi-colons and Commas, Custom Indentation Functions, Advanced Customizations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2130 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2131
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2132 @subsection Custom Brace and Colon Hanging
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2133 @cindex Custom Brace and Colon Hanging
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2134 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2135
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2136 @vindex c-hanging-braces-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2137 @vindex hanging-braces-alist (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2138 Syntactic symbols aren't the only place where you can customize
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
2139 @ccmode{} with the lisp equivalent of callback functions. Brace
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2140 ``hanginess'' can also be determined by custom functions associated with
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2141 syntactic symbols on the @code{c-hanging-braces-alist} variable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2142 Remember that @var{ACTION}'s are typically a list containing some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2143 combination of the symbols @code{before} and @code{after} (see
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2144 @ref{Hanging Braces}). However, an @var{ACTION} can also be a function
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
2145 which gets called when a brace matching that syntactic symbol is
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
2146 entered.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2147
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2148 @cindex customizing brace hanging
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2149 These @var{ACTION} functions are called with two arguments: the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2150 syntactic symbol for the brace, and the buffer position at which the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2151 brace was inserted. The @var{ACTION} function is expected to return a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2152 list containing some combination of @code{before} and @code{after}. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2153 function can also return @code{nil}. This return value has the normal
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2154 brace hanging semantics.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2155
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
2156 As an example, @ccmode{} itself uses this feature to dynamically
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2157 determine the hanginess of braces which close ``do-while''
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2158 constructs:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2159 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2160 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2161
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2162 void do_list( int count, char** atleast_one_string )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2163 @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2164 int i=0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2165 do @{
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2166 handle_string( atleast_one_string[i] );
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2167 i++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2168 @} while( i < count );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2169 @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2170
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2171 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2172 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2173
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2174 @findex c-snug-do-while
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2175 @findex snug-do-while (c-)
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
2176 @ccmode{} assigns the @code{block-close} syntactic symbol to the
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2177 brace that closes the @code{do} construct, and normally we'd like the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2178 line that follows a @code{block-close} brace to begin on a separate
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2179 line. However, with ``do-while'' constructs, we want the
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2180 @code{while} clause to follow the closing brace. To do this, we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2181 associate the @code{block-close} symbol with the @var{ACTION} function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2182 @code{c-snug-do-while}:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2183 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2184
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2185 (defun c-snug-do-while (syntax pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2186 "Dynamically calculate brace hanginess for do-while statements.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2187 Using this function, `while' clauses that end a `do-while' block will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2188 remain on the same line as the brace that closes that block.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2189
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2190 See `c-hanging-braces-alist' for how to utilize this function as an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2191 ACTION associated with `block-close' syntax."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2192 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2193 (let (langelem)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2194 (if (and (eq syntax 'block-close)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2195 (setq langelem (assq 'block-close c-syntactic-context))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2196 (progn (goto-char (cdr langelem))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2197 (if (= (following-char) ?@{)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2198 (forward-sexp -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2199 (looking-at "\\<do\\>[^_]")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2200 '(before)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2201 '(before after)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2202
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2203 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2204
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2205 This function simply looks to see if the brace closes a ``do-while''
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2206 clause and if so, returns the list @samp{(before)} indicating
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2207 that a newline should be inserted before the brace, but not after it.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2208 In all other cases, it returns the list @samp{(before after)} so
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2209 that the brace appears on a line by itself.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2210
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2211 @vindex c-syntactic-context
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2212 @vindex syntactic-context (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2213 During the call to the brace hanging @var{ACTION} function, the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2214 @code{c-syntactic-context} is bound to the full syntactic analysis list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2215
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2216 @cindex customizing colon hanging
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2217 @vindex c-hanging-colon-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2218 @vindex hanging-colon-alist (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2219 Note that for symmetry, colon hanginess should be customizable by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2220 allowing function symbols as @var{ACTION}s on the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2221 @code{c-hanging-colon-alist} variable. Since no use has actually been
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
2222 found for this feature, it isn't currently implemented!
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2223
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2224 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2225 @node Customizing Semi-colons and Commas, Other Special Indentations, Custom Brace and Colon Hanging, Advanced Customizations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2226 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2227
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2228 @subsection Customizing Semi-colons and Commas
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2229 @cindex Customizing Semi-colons and Commas
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2230 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2231
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2232 @cindex customizing semi-colons and commas
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2233 @vindex c-hanging-semi&comma-criteria
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2234 @vindex hanging-semi&comma-criteria (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2235 You can also customize the insertion of newlines after semi-colons and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2236 commas, when the auto-newline minor mode is enabled (see @ref{Minor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2237 Modes}). This is controlled by the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2238 @code{c-hanging-semi&comma-criteria}, which contains a list of functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2239 that are called in the order they appear. Each function is called with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2240 zero arguments, and is expected to return one of the following values:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2241
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2242 @itemize @bullet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2243 @item
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2244 non-@code{nil} --- A newline is inserted, and no more functions from the
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2245 list are called.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2246
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2247 @item
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2248 @code{stop} --- No more functions from the list are called, but no
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2249 newline is inserted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2250
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2251 @item
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2252 @code{nil} --- No determination is made, and the next function in the
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2253 list is called.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2254
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2255 @end itemize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2256
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2257 If every function in the list is called without a determination being
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2258 made, then no newline is added. The default value for this variable is a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2259 list containing a single function which inserts newlines only after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2260 semi-colons which do not appear inside parenthesis lists (i.e. those
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2261 that separate @code{for}-clause statements).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2262
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2263 Here's an example of a criteria function that will prevent newlines from
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2264 being inserted after semicolons when there is a non-blank following
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
2265 line. Otherwise, it makes no determination. To use, add this to the
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
2266 front of the @code{c-hanging-semi&comma-criteria} list.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2267
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2268 @example
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2269 @group
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2270
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2271 (defun my-semicolon-criteria ()
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2272 (save-excursion
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
2273 (if (and (eq last-command-char ?\;)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2274 (zerop (forward-line 1))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2275 (not (looking-at "^[ \t]*$")))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2276 'stop
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2277 nil)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2278
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2279 @end group
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2280 @end example
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2281
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2282
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2283 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2284 @node Other Special Indentations, , Customizing Semi-colons and Commas, Advanced Customizations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2285 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2286
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2287 @subsection Other Special Indentations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2288 @cindex Customizing Semi-colons and Commas
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2289 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2290
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2291 @vindex c-label-minimum-indentation
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2292 @vindex label-minimum-indentation (c-)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2293 In @samp{gnu} style (see @ref{Built-in Styles}), a minimum indentation
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
2294 is imposed on lines inside top-level constructs. This minimum
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
2295 indentation is controlled by the variable
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2296 @code{c-label-minimum-indentation}. The default value for this variable
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2297 is 1.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2298
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2299 @vindex c-special-indent-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2300 @vindex special-indent-hook (c-)
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
2301 One other customization variable is available in @ccmode{}:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2302 @code{c-special-indent-hook}. This is a standard hook variable that is
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
2303 called after every line is indented by @ccmode{}. You can use it
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2304 to do any special indentation or line adjustments your style dictates,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2305 such as adding extra indentation to constructors or destructor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2306 declarations in a class definition, etc. Note however, that you should
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
2307 not change point or mark inside your @code{c-special-indent-hook}
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2308 functions (i.e. you'll probably want to wrap your function in a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2309 @code{save-excursion}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2310
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2311 Setting @code{c-special-indent-hook} in your style definition is handled
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2312 slightly differently than other variables. In your style definition,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2313 you should set the value for
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2314 @code{c-special-indent-hook} to a function or list of functions, which
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2315 will be appended to @code{c-special-indent-hook} using @code{add-hook}.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2316 That way, the current setting for the buffer local value of
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2317 @code{c-special-indent-hook} won't be overridden.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2318
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 171
diff changeset
2319 @kindex M-;
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 171
diff changeset
2320 @findex indent-for-comment
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 171
diff changeset
2321 @vindex c-indent-comments-syntactically-p
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 171
diff changeset
2322 @vindex indent-comments-syntactically-p (c-)
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 171
diff changeset
2323 @vindex comment-column
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 171
diff changeset
2324
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 171
diff changeset
2325 Normally, the standard Emacs command @kbd{M-;}
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 171
diff changeset
2326 (@code{indent-for-comment}) will indent comment-only lines to
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 171
diff changeset
2327 @code{comment-column}. Some users however, prefer that @kbd{M-;} act
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 171
diff changeset
2328 just like @kbd{TAB} for purposes of indenting comment-only lines;
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 171
diff changeset
2329 i.e. they want the comments to always indent as they would for normal
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 171
diff changeset
2330 code, regardless of whether @kbd{TAB} or @kbd{M-;} were used. This
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 171
diff changeset
2331 behavior is controlled by the variable
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 171
diff changeset
2332 @code{c-indent-comments-syntactically-p}. When @code{nil} (the
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 171
diff changeset
2333 default), @kbd{M-;} indents comment-only lines to @code{comment-column},
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 171
diff changeset
2334 otherwise, they are indented just as they would be if @kbd{TAB} were
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 171
diff changeset
2335 typed.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2336
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2337 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2338 @node Syntactic Symbols, Performance Issues, Customizing Indentation, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2339 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2340
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2341 @chapter Syntactic Symbols
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2342 @cindex Syntactic Symbols
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2343 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2344
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2345 @vindex c-offsets-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2346 @vindex offsets-alist (c-)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2347
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2348 Here is a complete list of the recognized syntactic symbols as described
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2349 in the @code{c-offsets-alist} variable, along with a brief description.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2350 More detailed descriptions follow below.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2351
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2352 @itemize @bullet
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2353 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2354 @code{string} --- inside multi-line string
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2355 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2356 @code{c} --- inside a multi-line C style block comment
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2357 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2358 @code{defun-open} --- brace that opens a function definition
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2359 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2360 @code{defun-close} --- brace that closes a function definition
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2361 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2362 @code{defun-block-intro} --- the first line in a top-level defun
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2363 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2364 @code{class-open} --- brace that opens a class definition
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2365 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2366 @code{class-close} --- brace that closes a class definition
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2367 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2368 @code{inline-open} --- brace that opens an in-class inline method
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2369 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2370 @code{inline-close} --- brace that closes an in-class inline method
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2371 @item
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
2372 @code{func-decl-cont} --- the region between a function definition's
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
2373 argument list and the function opening brace (excluding K&R argument
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
2374 declarations). In C, you cannot put anything but whitespace and comments
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
2375 between them; in C++ and Java, @code{throws} declarations and other
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
2376 things can appear in this context.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2377 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2378 @code{knr-argdecl-intro} --- first line of a K&R C argument declaration
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2379 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2380 @code{knr-argdecl} --- subsequent lines in a K&R C argument declaration
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2381 @item
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
2382 @code{topmost-intro} --- the first line in a topmost definition
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2383 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2384 @code{topmost-intro-cont} --- topmost definition continuation lines
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2385 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2386 @code{member-init-intro} --- first line in a member initialization list
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2387 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2388 @code{member-init-cont} --- subsequent member initialization list lines
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2389 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2390 @code{inher-intro} --- first line of a multiple inheritance list
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2391 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2392 @code{inher-cont} --- subsequent multiple inheritance lines
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2393 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2394 @code{block-open} --- statement block open brace
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2395 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2396 @code{block-close} --- statement block close brace
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2397 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2398 @code{brace-list-open} --- open brace of an enum or static array list
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2399 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2400 @code{brace-list-close} --- close brace of an enum or static array list
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2401 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2402 @code{brace-list-intro} --- first line in an enum or static array list
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2403 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2404 @code{brace-list-entry} --- subsequent lines in an enum or static array list
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2405 @item
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
2406 @code{statement} --- a C statement
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2407 @item
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
2408 @code{statement-cont} --- a continuation of a C statement
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2409 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2410 @code{statement-block-intro} --- the first line in a new statement block
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2411 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2412 @code{statement-case-intro} --- the first line in a case `block'
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2413 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2414 @code{statement-case-open} --- the first line in a case block starting
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2415 with brace
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2416 @item
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
2417 @code{substatement} --- the first line after a conditional
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2418 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2419 @code{substatement-open} --- the brace that opens a substatement block
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2420 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2421 @code{case-label} --- a case or default label
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2422 @item
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
2423 @code{access-label} --- C++ access control label
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2424 @item
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
2425 @code{label} --- any non-special C label
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2426 @item
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
2427 @code{do-while-closure} --- the `while' that ends a
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
2428 @code{do}-@code{while} construct
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2429 @item
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
2430 @code{else-clause} --- the `else' of an @code{if}-@code{else} construct
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2431 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2432 @code{comment-intro} --- a line containing only a comment introduction
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2433 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2434 @code{arglist-intro} --- the first line in an argument list
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2435 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2436 @code{arglist-cont} --- subsequent argument list lines when no arguments
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2437 follow on the same line as the the arglist opening paren
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2438 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2439 @code{arglist-cont-nonempty} --- subsequent argument list lines when at
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2440 least one argument follows on the same line as the arglist opening paren
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2441 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2442 @code{arglist-close} --- the solo close paren of an argument list
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2443 @item
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
2444 @code{stream-op} --- lines continuing a stream operator
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2445 @item
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
2446 @code{inclass} --- the line is nested inside a class definition
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2447 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2448 @code{cpp-macro} --- the start of a cpp macro
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2449 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2450 @code{friend} --- a C++ friend declaration
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2451 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2452 @code{objc-method-intro} --- the first line of an Objective-C method definition
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2453 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2454 @code{objc-method-args-cont} --- lines continuing an Objective-C method
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2455 definition
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2456 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2457 @code{objc-method-call-cont} --- lines continuing an Objective-C method call
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2458 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2459 @code{extern-lang-open} --- brace that opens an external language block
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2460 @item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2461 @code{extern-lang-close} --- brace that closes an external language block
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2462 @item
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
2463 @code{inextern-lang} --- analogous to `inclass' syntactic symbol, but
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
2464 for @code{extern} blocks.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2465 @end itemize
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2466
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2467 @cindex -open syntactic symbols
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2468 @cindex -close syntactic symbols
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2469 Most syntactic symbol names follow a general naming convention. When a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2470 line begins with an open or close brace, the syntactic symbol will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2471 contain the suffix @code{-open} or @code{-close} respectively.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2472
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2473 @cindex -intro syntactic symbols
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2474 @cindex -cont syntactic symbols
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2475 @cindex -block-intro syntactic symbols
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2476 Usually, a distinction is made between the first line that introduces a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2477 construct and lines that continue a construct, and the syntactic symbols
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2478 that represent these lines will contain the suffix @code{-intro} or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2479 @code{-cont} respectively. As a sub-classification of this scheme, a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2480 line which is the first of a particular brace block construct will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2481 contain the suffix @code{-block-intro}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2482
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2483 @kindex C-c C-s
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2484 Let's look at some examples to understand how this works. Remember that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2485 you can check the syntax of any line by using @kbd{C-c C-s}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2486 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2487 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2488
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2489 1: void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2490 2: swap( int& a, int& b )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2491 3: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2492 4: int tmp = a;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2493 5: a = b;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2494 6: b = tmp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2495 7: int ignored =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2496 8: a + b;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2497 9: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2498
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2499 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2500 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2501
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2502 @cindex topmost-intro syntactic symbol
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2503 @cindex topmost-intro-cont syntactic symbol
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2504 @cindex defun-open syntactic symbol
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2505 @cindex defun-close syntactic symbol
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2506 @cindex defun-block-intro syntactic symbol
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2507 Line 1 shows a @code{topmost-intro} since it is the first line that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2508 introduces a top-level construct. Line 2 is a continuation of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2509 top-level construct introduction so it has the syntax
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2510 @code{topmost-intro-cont}. Line 3 shows a @code{defun-open} since it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2511 the brace that opens a top-level function definition. Line 9 is a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2512 @code{defun-close} since it contains the brace that closes the top-level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2513 function definition. Line 4 is a @code{defun-block-intro}, i.e. it is
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
2514 the first line of a brace-block, enclosed in a
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2515 top-level function definition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2516
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2517 @cindex statement syntactic symbol
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2518 @cindex statement-cont syntactic symbol
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2519 Lines 5, 6, and 7 are all given @code{statement} syntax since there
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2520 isn't much special about them. Note however that line 8 is given
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2521 @code{statement-cont} syntax since it continues the statement begun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2522 on the previous line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2523
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2524 Here's another example, which illustrates some C++ class syntactic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2525 symbols:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2526 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2527 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2528
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2529 1: class Bass
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2530 2: : public Guitar,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2531 3: public Amplifiable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2532 4: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2533 5: public:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2534 6: Bass()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2535 7: : eString( new BassString( 0.105 )),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2536 8: aString( new BassString( 0.085 )),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2537 9: dString( new BassString( 0.065 )),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2538 10: gString( new BassString( 0.045 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2539 11: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2540 12: eString.tune( 'E' );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2541 13: aString.tune( 'A' );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2542 14: dString.tune( 'D' );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2543 15: gString.tune( 'G' );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2544 16: @}
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2545 17: friend class Luthier;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2546 18: @}
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2547
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2548 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2549 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2550
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2551 @cindex class-open syntactic symbol
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2552 @cindex class-close syntactic symbol
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2553 As in the previous example, line 1 has the @code{topmost-intro} syntax.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2554 Here however, the brace that opens a C++ class definition on line 4 is
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2555 assigned the @code{class-open} syntax. Note that in C++, classes,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2556 structs, and unions are essentially equivalent syntactically (and are
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2557 very similar semantically), so replacing the @code{class} keyword in the
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2558 example above with @code{struct} or @code{union} would still result in a
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2559 syntax of @code{class-open} for line 4 @footnote{This is the case even
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2560 for C and Objective-C. For consistency, structs in all supported
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2561 languages are syntactically equivalent to classes. Note however that
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2562 the keyword @code{class} is meaningless in C and Objective-C.}.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2563 Similarly, line 18 is assigned @code{class-close} syntax.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2564
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2565 @cindex inher-intro syntactic symbol
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2566 @cindex inher-cont syntactic symbol
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2567 Line 2 introduces the inheritance list for the class so it is assigned
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2568 the @code{inher-intro} syntax, and line 3, which continues the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2569 inheritance list is given @code{inher-cont} syntax.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2570
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2571 @cindex access-label syntactic symbol
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2572 @cindex inclass syntactic symbol
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2573 Hitting @kbd{C-c C-s} on line 5 shows the following analysis:
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2574
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2575 @example
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2576 @group
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2577
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2578 @code{((inclass . 1) (access-label . 67))}
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2579
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2580 @end group
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2581 @end example
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2582
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2583 @noindent
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2584 The primary syntactic symbol for this line is @code{access-label} as
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2585 this a label keyword that specifies access protection in C++. However,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2586 because this line is also a top-level construct inside a class
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2587 definition, the analysis actually shows two syntactic symbols. The
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2588 other syntactic symbol assigned to this line is @code{inclass}.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2589 Similarly, line 6 is given both @code{inclass} and @code{topmost-intro}
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2590 syntax:
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2591
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2592 @example
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2593 @group
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2594
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2595 @code{((inclass . 58) (topmost-intro . 60))}
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2596
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2597 @end group
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2598 @end example
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2599
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2600 @cindex member-init-intro syntactic symbol
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2601 @cindex member-init-cont syntactic symbol
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2602 Line 7 introduces a C++ member initialization list and as such is given
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2603 @code{member-init-intro} syntax. Note that in this case it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2604 @emph{not} assigned @code{inclass} since this is not considered a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2605 top-level construct. Lines 8 through 10 are all assigned
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2606 @code{member-init-cont} since they continue the member initialization
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2607 list started on line 7.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2608
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2609 @cindex in-class inline methods
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2610 @cindex inline-open syntactic symbol
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2611 @cindex inline-close syntactic symbol
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
2612 Line 11's analysis is a bit more complicated:
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2613
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2614 @example
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2615 @group
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2616
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2617 @code{((inclass . 1) (inline-open))}
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2618
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2619 @end group
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2620 @end example
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2621
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2622 This line is assigned a syntax of both @code{inline-open} and
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2623 @code{inclass} because it opens an @dfn{in-class} C++ inline method
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2624 definition. This is distinct from, but related to, the C++ notion of an
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2625 inline function in that its definition occurs inside an enclosing class
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2626 definition, which in C++ implies that the function should be inlined.
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
2627 If though, the definition of the @code{Bass} constructor appeared
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
2628 outside the class definition, the construct would be given the
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2629 @code{defun-open} syntax, even if the keyword @code{inline} appeared
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2630 before the method name, as in:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2631 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2632 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2633
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2634 class Bass
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2635 : public Guitar,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2636 public Amplifiable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2637 @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2638 public:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2639 Bass();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2640 @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2641
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2642 inline
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2643 Bass::Bass()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2644 : eString( new BassString( 0.105 )),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2645 aString( new BassString( 0.085 )),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2646 dString( new BassString( 0.065 )),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2647 gString( new BassString( 0.045 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2648 @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2649 eString.tune( 'E' );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2650 aString.tune( 'A' );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2651 dString.tune( 'D' );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2652 gString.tune( 'G' );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2653 @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2654
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2655 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2656 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2657
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2658 @cindex friend syntactic symbol
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2659 Returning to the previous example, line 16 is given @code{inline-close}
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2660 syntax, while line 12 is given @code{defun-block-open} syntax, and lines
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2661 13 through 15 are all given @code{statement} syntax. Line 17 is
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
2662 interesting in that its syntactic analysis list contains three
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2663 elements:
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2664
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2665 @example
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2666
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2667 @code{((friend) (inclass . 58) (topmost-intro . 380))}
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2668
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2669 @end example
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2670
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2671 The @code{friend} syntactic symbol is a modifier that typically does not
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2672 have a relative buffer position.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2673
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2674 Here is another (totally contrived) example which illustrates how syntax
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2675 is assigned to various conditional constructs:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2676 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2677 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2678
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2679 1: void spam( int index )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2680 2: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2681 3: for( int i=0; i<index; i++ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2682 4: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2683 5: if( i == 10 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2684 6: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2685 7: do_something_special();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2686 8: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2687 9: else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2688 10: do_something( i );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2689 11: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2690 12: do @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2691 13: another_thing( i-- );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2692 14: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2693 15: while( i > 0 );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2694 16: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2695
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2696
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2697 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2698 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2699
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2700 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2701 Only the lines that illustrate new syntactic symbols will be discussed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2702
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2703 @cindex substatement-open syntactic symbol
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2704 @cindex substatement-block-intro syntactic symbol
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2705 @cindex block-close syntactic symbol
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2706 Line 4 has a brace which opens a conditional's substatement block. It
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2707 is thus assigned @code{substatement-open} syntax, and since line 5 is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2708 the first line in the substatement block, it is assigned
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2709 @code{substatement-block-intro} syntax. Lines 6 and 7 are assigned
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2710 similar syntax. Line 8 contains the brace that closes the inner
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2711 substatement block. It is given the syntax @code{block-close},
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2712 as are lines 11 and 14.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2713
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2714 @cindex else-clause syntactic symbol
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2715 @cindex substatement syntactic symbol
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2716 Line 9 is a little different --- since it contains the keyword
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2717 @code{else} matching the @code{if} statement introduced on line 5, it is
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2718 given the @code{else-clause} syntax. Note also that line 10 is slightly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2719 different too. Because @code{else} is considered a conditional
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2720 introducing keyword @footnote{The list of conditional keywords are (in
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2721 C, C++, Objective-C, and Java): @code{for}, @code{if}, @code{do},
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2722 @code{else}, @code{while}, and @code{switch}. C++ and Java have two
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2723 additional conditional keywords: @code{try} and @code{catch}. Java also
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2724 has the @code{finally} and @code{synchronized} keywords.}, and because
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2725 the following substatement is not a brace block, line 10 is assigned the
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2726 @code{substatement} syntax.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2727
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2728 @cindex do-while-closure syntactic symbol
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2729 One other difference is seen on line 15. The @code{while} construct
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2730 that closes a @code{do} conditional is given the special syntax
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2731 @code{do-while-closure} if it appears on a line by itself. Note that if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2732 the @code{while} appeared on the same line as the preceding close brace,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2733 that line would have been assigned @code{block-close} syntax instead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2734
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2735 Switch statements have their own set of syntactic symbols. Here's an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2736 example:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2737 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2738 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2739
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2740 1: void spam( enum Ingredient i )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2741 2: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2742 3: switch( i ) @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2743 4: case Ham:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2744 5: be_a_pig();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2745 6: break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2746 7: case Salt:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2747 8: drink_some_water();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2748 9: break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2749 10: default:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2750 11: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2751 12: what_is_it();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2752 13: break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2753 14: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2754 15: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2755 14: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2756
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2757 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2758 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2759
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2760 @cindex case-label syntactic symbol
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2761 @cindex statement-case-intro syntactic symbol
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2762 @cindex statement-case-open syntactic symbol
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2763 Here, lines 4, 7, and 10 are all assigned @code{case-label} syntax,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2764 while lines 5 and 8 are assigned @code{statement-case-intro}. Line 11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2765 is treated slightly differently since it contains a brace that opens a
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2766 block --- it is given @code{statement-case-open} syntax.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2767
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2768 @cindex brace lists
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2769 There are a set of syntactic symbols that are used to recognize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2770 constructs inside of brace lists. A brace list is defined as an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2771 @code{enum} or aggregate initializer list, such as might statically
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2772 initialize an array of structs. For example:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2773 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2774 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2775
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2776 1: static char* ingredients[] =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2777 2: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2778 3: "Ham",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2779 4: "Salt",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2780 5: NULL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2781 6: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2782
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2783 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2784 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2785
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2786 @cindex brace-list-open syntactic symbol
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2787 @cindex brace-list-intro syntactic symbol
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2788 @cindex brace-list-close syntactic symbol
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2789 @cindex brace-list-entry syntactic symbol
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2790 Following convention, line 2 in this example is assigned
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2791 @code{brace-list-open} syntax, and line 3 is assigned
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2792 @code{brace-list-intro} syntax. Likewise, line 6 is assigned
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2793 @code{brace-list-close} syntax. Lines 4 and 5 however, are assigned
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2794 @code{brace-list-entry} syntax, as would all subsequent lines in this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2795 initializer list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2796
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2797 External language definition blocks also have their own syntactic
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2798 symbols. In this example:
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2799 @example
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2800 @group
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2801
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2802 1: extern "C"
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2803 2: @{
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2804 3: int thing_one( int );
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2805 4: int thing_two( double );
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2806 5: @}
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2807
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2808 @end group
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2809 @end example
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2810
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2811 @cindex extern-lang-open syntactic symbol
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2812 @cindex extern-lang-close syntactic symbol
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2813 @cindex inextern-lang syntactic symbol
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2814 @cindex inclass syntactic symbol
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2815 @noindent
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2816 line 2 is given the @code{extern-lang-open} syntax while line 5 is given
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2817 the @code{extern-lang-close} syntax. The analysis for line 3 yields:
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2818 @code{((inextern-lang) (topmost-intro . 14))}, where
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2819 @code{inextern-lang} is a modifier similar in purpose to @code{inclass}.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2820
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2821 A number of syntactic symbols are associated with parenthesis lists,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2822 a.k.a argument lists, as found in function declarations and function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2823 calls. This example illustrates these:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2824 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2825 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2826
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2827 1: void a_function( int line1,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2828 2: int line2 );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2829 3:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2830 4: void a_longer_function(
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2831 5: int line1,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2832 6: int line2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2833 7: );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2834 8:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2835 9: void call_them( int line1, int line2 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2836 10: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2837 11: a_function(
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2838 12: line1,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2839 13: line2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2840 14: );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2841 15:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2842 16: a_longer_function( line1,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2843 17: line2 );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2844 18: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2845
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2846 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2847 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2848
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2849 @cindex arglist-intro syntactic symbol
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2850 @cindex arglist-close syntactic symbol
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2851 Lines 5 and 12 are assigned @code{arglist-intro} syntax since they are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2852 the first line following the open parenthesis, and lines 7 and 14 are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2853 assigned @code{arglist-close} syntax since they contain the parenthesis
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2854 that closes the argument list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2855
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2856 @cindex arglist-cont-nonempty syntactic symbol
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2857 @cindex arglist-cont syntactic symbol
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2858 Lines that continue argument lists can be assigned one of two syntactic
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2859 symbols. For example, Lines 2 and 17
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2860 are assigned @code{arglist-cont-nonempty} syntax. What this means
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2861 is that they continue an argument list, but that the line containing the
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2862 parenthesis that opens the list is @emph{not empty} following the open
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2863 parenthesis. Contrast this against lines 6 and 13 which are assigned
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2864 @code{arglist-cont} syntax. This is because the parenthesis that opens
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
2865 their argument lists is the last character on that line.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2866
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2867 Note that there is no @code{arglist-open} syntax. This is because any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2868 parenthesis that opens an argument list, appearing on a separate line,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2869 is assigned the @code{statement-cont} syntax instead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2870
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2871 A few miscellaneous syntactic symbols that haven't been previously
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
2872 covered are illustrated by this C++ example:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2873 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2874 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2875
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2876 1: void Bass::play( int volume )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2877 2: const
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2878 3: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2879 4: /* this line starts a multi-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2880 5: * comment. This line should get `c' syntax */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2881 6:
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
2882 7: char* a_multiline_string = "This line starts a multi-line \
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2883 8: string. This line should get `string' syntax.";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2884 9:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2885 10: note:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2886 11: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2887 12: #ifdef LOCK
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2888 13: Lock acquire();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2889 14: #endif // LOCK
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2890 15: slap_pop();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2891 16: cout << "I played "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2892 17: << "a note\n";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2893 18: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2894 19: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2895
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2896 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2897 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2898
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2899 @cindex modifier syntactic symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2900 The lines to note in this example include:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2901
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2902 @itemize @bullet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2903
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
2904 @cindex func-decl-cont syntactic symbol
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2905 @item
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
2906 line 2, assigned the @code{func-decl-cont} syntax;
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2907
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2908 @cindex comment-intro syntactic symbol
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2909 @item
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2910 line 4, assigned both @code{defun-block-intro} @emph{and}
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
2911 @code{comment-intro} syntax;
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2912
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2913 @cindex c syntactic symbol
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2914 @item
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2915 line 5, assigned @code{c} syntax;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2916
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2917 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2918 @cindex syntactic whitespace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2919 line 6 which, even though it contains nothing but whitespace, is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2920 assigned @code{defun-block-intro}. Note that the appearance of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2921 comment on lines 4 and 5 do not cause line 6 to be assigned
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2922 @code{statement} syntax because comments are considered to be
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2923 @dfn{syntactic whitespace}, which are ignored when analyzing
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2924 code;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2925
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2926 @cindex string syntactic symbol
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2927 @item
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2928 line 8, assigned @code{string} syntax;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2929
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2930 @cindex label syntactic symbol
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2931 @item
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2932 line 10, assigned @code{label} syntax;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2933
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2934 @cindex block-open syntactic symbol
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2935 @item
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2936 line 11, assigned @code{block-open} syntax;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2937
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2938 @cindex cpp-macro syntactic symbol
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2939 @item
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2940 lines 12 and 14, assigned @code{cpp-macro} syntax;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2941
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2942 @cindex stream-op syntactic symbol
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2943 @item
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
2944 line 17, assigned @code{stream-op} syntax.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2945
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2946 @end itemize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2947
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2948 In Objective-C buffers, there are three additional syntactic symbols
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2949 assigned to various message calling constructs. Here's an example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2950 illustrating these:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2951 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2952 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2953
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2954 1: - (void)setDelegate:anObject
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2955 2: withStuff:stuff
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2956 3: @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2957 4: [delegate masterWillRebind:self
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2958 5: toDelegate:anObject
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2959 6: withExtraStuff:stuff];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2960 7: @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2961
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2962 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2963 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2964
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2965 @cindex objc-method-intro syntactic symbol
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2966 @cindex objc-method-args-cont syntactic symbol
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2967 @cindex objc-method-call-cont syntactic symbol
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2968 Here, line 1 is assigned @code{objc-method-intro} syntax, and line 2 is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2969 assigned @code{objc-method-args-cont} syntax. Lines 5 and 6 are both
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2970 assigned @code{objc-method-call-cont} syntax.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2971
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2972 @cindex knr-argdecl-intro
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2973 @cindex knr-argdecl
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2974 Two other syntactic symbols can appear in old style, non-prototyped C
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2975 code @footnote{a.k.a. K&R C, or Kernighan & Ritchie C}:
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2976 @example
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2977 @group
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2978
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2979 1: int add_three_integers(a, b, c)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2980 2: int a;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2981 3: int b;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2982 4: int c;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2983 5: @{
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2984 6: return a + b + c;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2985 7: @}
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2986
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2987 @end group
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2988 @end example
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2989
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2990 Here, line 2 is the first line in an argument declaration list and so is
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2991 given the @code{knr-argdecl-intro} syntactic symbol. Subsequent lines
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2992 (i.e. lines 3 and 4 in this example), are given @code{knr-argdecl}
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2993 syntax.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2994
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2995 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2996 @node Performance Issues, Frequently Asked Questions, Syntactic Symbols, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2997 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2998
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2999 @chapter Performance Issues
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3000 @cindex Performance Issues
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3001 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3002
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
3003 C and its derivative languages are highly complex creatures. Often,
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3004 ambiguous code situations arise that require @ccmode{} to scan
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3005 large portions of the buffer to determine syntactic context. Such
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3006 pathological code@footnote{such as the output of @code{lex(1)}!}
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3007 can cause @ccmode{} to perform fairly badly.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3008 This section identifies some of the coding styles to watch out for, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3009 suggests some workarounds that you can use to improve performance.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3010
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3011 Because @ccmode{} has to scan the buffer backwards from the current
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3012 insertion point, and because C's syntax is fairly difficult to parse in
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3013 the backwards direction, @ccmode{} often tries to find the nearest
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3014 position higher up in the buffer from which to begin a forward scan.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3015 The farther this position is from the current insertion point, the
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3016 slower the mode gets. Some coding styles can even force @ccmode{}
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
3017 to scan from the beginning of the buffer for every line of code!
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3018
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3019 @findex beginning-of-defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3020 @findex defun-prompt-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3021 One of the simplest things you can do to reduce scan time, is make sure
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3022 any brace that opens a top-level block construct always appears in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3023 leftmost column. This is actually an Emacs constraint, as embodied in
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3024 the @code{beginning-of-defun} function which @ccmode{} uses
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3025 heavily. If you insist on hanging top-level open braces on the right
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3026 side of the line, then you should set the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3027 @code{defun-prompt-regexp} to something reasonable @footnote{Note that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3028 this variable is only defined in Emacs 19.}, however that ``something
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3029 reasonable'' is difficult to define, so @ccmode{} doesn't do it
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3030 for you.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3031
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3032 @vindex c-Java-defun-prompt-regexp
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3033 @vindex Java-defun-prompt-regexp (c-)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3034 A special note about @code{defun-prompt-regexp} in Java mode: while much
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3035 of the early sample Java code seems to encourage a style where the brace
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3036 that opens a class is hung on the right side of the line, this is not a
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3037 good style to pursue in Emacs. @ccmode{} comes with a variable
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3038 @code{c-Java-defun-prompt-regexp} which tries to define a regular
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3039 expression usable for this style, but there are problems with it. In
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3040 some cases it can cause @code{beginning-of-defun} to hang@footnote{This
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3041 has been observed in Emacs 19.34 and XEmacs 19.15.}. For this reason,
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3042 it is not used by default, but if you feel adventurous, you can set
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3043 @code{defun-prompt-regexp} to it in your mode hook. In any event,
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3044 setting and rely on @code{defun-prompt-regexp} will definitely slow
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3045 things down!
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3046
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3047 You will probably notice pathological behavior from @ccmode{} when
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3048 working in files containing large amounts of cpp macros. This is
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
3049 because Emacs cannot be made to quickly skip backwards over these lines.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3050
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3051 @vindex c-recognize-knr-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3052 @vindex recognize-knr-p (c-)
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3053 Previous versions of @ccmode{} had potential performance problems
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3054 when recognizing K&R style function argument declarations. This was
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3055 because there are ambiguities in the C syntax when K&R style argument
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3056 lists are used@footnote{It is hard to distinguish them from top-level
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3057 declarations.}. @ccmode{} has adopted BOCM's convention for
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3058 limiting the search: it assumes that argdecls are indented at least one
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3059 space, and that the function headers are not indented at all. With
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3060 current versions of @ccmode{}, user customization of
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3061 @code{c-recognize-knr-p} is deprecated. Just don't put argdecls in
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3062 column zero!
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3063
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3064 @cindex @file{cc-lobotomy.el} file
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3065 @vindex cc-lobotomy-pith-list
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3066 You might want to investigate the speed-ups contained in the
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
3067 file @file{cc-lobotomy.el}, which comes as part of the @ccmode{}
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
3068 distribution, but is completely unsupported.
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3069 As mentioned previous, @ccmode{} always trades accuracy for speed,
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3070 however it is recognized that sometimes you need speed and can sacrifice
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3071 some accuracy in indentation. The file @file{cc-lobotomy.el} contains
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3072 hacks that will ``dumb down'' @ccmode{} in some specific ways, making
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3073 that trade-off of speed for accuracy. I won't go into details of its
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3074 use here; you should read the comments at the top of the file, and look
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3075 at the variable @code{cc-lobotomy-pith-list} for details.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3076
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3077
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3078 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3079 @node Frequently Asked Questions, Getting the latest CC Mode release, Performance Issues, Top
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3080 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3081
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3082 @chapter Frequently Asked Questions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3083 @cindex Frequently Asked Questions
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3084 @comment FAQ
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3085 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3086
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3087 @kindex C-x h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3088 @kindex ESC C-\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3089 @kindex ESC C-x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3090 @kindex C-c C-q
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3091 @kindex ESC C-q
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3092 @kindex ESC C-u
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3093 @kindex RET
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
3094 @kindex C-j
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3095 @findex newline-and-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3096 @quotation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3097
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3098 @strong{Q.} @emph{How do I re-indent the whole file?}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3099
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3100 @strong{A.} Visit the file and hit @kbd{C-x h} to mark the whole
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3101 buffer. Then hit @kbd{@key{ESC} C-\}.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3102 @sp 1
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3103
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3104 @strong{Q.} @emph{How do I re-indent the entire function?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3105 @kbd{@key{ESC} C-x} doesn't work.}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3106
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3107 @strong{A.} @kbd{@key{ESC} C-x} is reserved for future Emacs use.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3108 To re-indent the entire function hit @kbd{C-c C-q}.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3109 @sp 1
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3110
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3111 @strong{Q.} @emph{How do I re-indent the current block?}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3112
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3113 @strong{A.} First move to the brace which opens the block with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3114 @kbd{@key{ESC} C-u}, then re-indent that expression with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3115 @kbd{@key{ESC} C-q}.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3116 @sp 1
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3117
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3118 @strong{Q.} @emph{Why doesn't the @key{RET} key indent the line to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3119 where the new text should go after inserting the newline?}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3120
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3121 @strong{A.} Emacs' convention is that @key{RET} just adds a newline,
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 110
diff changeset
3122 and that @key{C-j} adds a newline and indents it. You can make
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3123 @key{RET} do this too by adding this to your
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3124 @code{c-mode-common-hook} (see the sample @file{.emacs} file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3125 @ref{Sample .emacs File}):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3126 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3127
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3128 (define-key c-mode-map "\C-m" 'newline-and-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3129
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3130 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3131
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3132 This is a very common question. If you want this to be the default
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3133 behavior, don't lobby me, lobby RMS! @code{:-)}
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3134 @sp 1
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3135
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3136 @strong{Q.} @emph{I put @code{(c-set-offset 'substatement-open 0)}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3137 in my @file{.emacs} file but I get an error saying that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3138 @code{c-set-offset}'s function definition is void.}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3139
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3140 @strong{A.} This means that @ccmode{} wasn't loaded into your
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3141 Emacs session by the time the @code{c-set-offset} call was reached,
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3142 mostly likely because @ccmode{} is being autoloaded. Instead
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3143 of putting the @code{c-set-offset} line in your top-level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3144 @file{.emacs} file, put it in your @code{c-mode-common-hook}, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3145 simply add the following to the top of your @file{.emacs} file:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3146 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3147
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3148 (require 'cc-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3149
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3150 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3151
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3152 See the sample @file{.emacs} file @ref{Sample .emacs File} for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3153 details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3154
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3155 @sp 1
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3156 @strong{Q.} @emph{How do I make strings, comments, keywords, and other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3157 constructs appear in different colors, or in bold face, etc.?}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3158
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
3159 @strong{A.} ``Syntax Colorization'' is a standard Emacs feature,
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
3160 controlled by @code{font-lock-mode}. It is not part of @ccmode{}.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3161
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3162 @end quotation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3163
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3165 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3166 @node Getting the latest CC Mode release, Sample .emacs File, Frequently Asked Questions, Top
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3167 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3168
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3169 @chapter Getting the latest CC Mode release
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3170 @cindex Getting the latest CC Mode release
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3171 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3172
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
3173 @ccmode{} is now standard with later versions Emacs 19 and XEmacs 19.
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
3174 It is also the standard for XEmacs 20, and will be the standard for
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
3175 Emacs 20 (unreleased as of this writing). You would typically just use
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
3176 the version that comes with your X/Emacs. These may be slightly out of
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
3177 date due to release schedule skew, so you should always check the
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
3178 canonical site for the latest version.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3179
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3180 @example
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3181 @group
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3182
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3183 World Wide Web:
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3184
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3185 @code{http://www.python.org/ftp/emacs/}
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3186
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3187 Anonymous FTP:
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3188
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3189 @code{ftp://ftp.python.org/pub/emacs/}
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3190
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3191 @end group
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3192 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3193
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3194 There are many files under these directories; you can pick up the entire
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3195 distribution (named @code{cc-mode.tar.gz}; a gzip'd tar file), or any of
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3196 the individual files, including PostScript documentation.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3197
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3198 If you do not have World Wide Web, or anonymous ftp access, you can get
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3199 the distribution through an anonymous ftp-to-mail gateway, such as the
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3200 one run by DEC at:
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3201 @example
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3202
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3203 @code{ftpmail@@decwrl.dec.com}
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3204
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3205 @end example
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3206 To get @ccmode{} via email, send the following message in the body of
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3207 your mail to that address:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3208 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3209
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3210 reply <a valid net address back to you>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3211 connect ftp.python.org
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3212 binary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3213 uuencode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3214 chdir pub/emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3215 get cc-mode.tar.gz
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3216
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3217 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3218 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3219 or just send the message "help" for more information on ftpmail.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3220 Response times will vary with the number of requests in the queue. I am
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3221 in no way connected to this service, so I make no claims or guarantees
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3222 about its availability!
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3223
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3224 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3225 @node Sample .emacs File, Limitations and Known Bugs, Getting the latest CC Mode release, Top
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3226 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3227
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3228 @chapter Sample .emacs file
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3229 @cindex Sample .emacs file
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3230 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3231
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3232 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3233 ;; Here's a sample .emacs file that might help you along the way. Just
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3234 ;; copy this region and paste it into your .emacs file. You may want to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3235 ;; change some of the actual values.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3236
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3237 (defconst my-c-style
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3238 '((c-tab-always-indent . t)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3239 (c-comment-only-line-offset . 4)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3240 (c-hanging-braces-alist . ((substatement-open after)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3241 (brace-list-open)))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3242 (c-hanging-colons-alist . ((member-init-intro before)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3243 (inher-intro)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3244 (case-label after)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3245 (label after)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3246 (access-label after)))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3247 (c-cleanup-list . (scope-operator
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3248 empty-defun-braces
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3249 defun-close-semi))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3250 (c-offsets-alist . ((arglist-close . c-lineup-arglist)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3251 (substatement-open . 0)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3252 (case-label . 4)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3253 (block-open . 0)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3254 (knr-argdecl-intro . -)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3255 (c-echo-syntactic-information-p . t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3256 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3257 "My C Programming Style")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3258
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3259 ;; Customizations for all of c-mode, c++-mode, and objc-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3260 (defun my-c-mode-common-hook ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3261 ;; add my personal style and set it for the current buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3262 (c-add-style "PERSONAL" my-c-style t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3263 ;; offset customizations not in my-c-style
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3264 (c-set-offset 'member-init-intro '++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3265 ;; other customizations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3266 (setq tab-width 8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3267 ;; this will make sure spaces are used instead of tabs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3268 indent-tabs-mode nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3269 ;; we like auto-newline and hungry-delete
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3270 (c-toggle-auto-hungry-state 1)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3271 ;; keybindings for all supported languages. We can put these in
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
3272 ;; c-mode-base-map because c-mode-map, c++-mode-map, objc-mode-map,
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
3273 ;; java-mode-map, and idl-mode-map inherit from it.
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
3274 (define-key c-mode-base-map "\C-m" 'newline-and-indent)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3275 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3276
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3277 (add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3278 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3279
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3280 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3281 @node Limitations and Known Bugs, Mailing Lists and Submitting Bug Reports, Sample .emacs File, Top
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3282 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3283 @chapter Limitations and Known Bugs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3284 @cindex Limitations and Known Bugs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3285 @comment * Limitations and Known Bugs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3286 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3287
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3288 @itemize @bullet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3289 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3290 Multi-line macros are not handled properly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3291
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3292 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3293 Re-indenting large regions or expressions can be slow.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3294
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3295 @item
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3296 Add-on fill packages may not work as well as @ccmode{}'s built-in
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3297 filling routines. I no longer recommend you use @code{filladapt} to
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3298 fill comments.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3299
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3300 @cindex c-indent-exp
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3301 @cindex indent-exp (c-)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3302 @item
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3303 @code{c-indent-exp} has not been fully optimized. It essentially
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3304 equivalent to hitting @kbd{TAB} (@code{c-indent-command}) on every
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3305 line. Some information is cached from line to line, but such caching
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3306 invariable causes inaccuracies in analysis in some bizarre situations.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3307
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3308 @end itemize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3309
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3310 @c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3311 @node Mailing Lists and Submitting Bug Reports, Concept Index, Limitations and Known Bugs, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3312 @comment node-name, next, previous,up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3313 @chapter Mailing Lists and Submitting Bug Reports
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3314 @cindex Mailing Lists and Submitting Bug Reports
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3315 @c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3316
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3317 @kindex C-c C-b
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3318 @findex c-submit-bug-report
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3319 @findex submit-bug-report (c-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3320 @cindex beta testers mailing list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3321 @cindex announcement mailing list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3322 To report bugs, use the @kbd{C-c C-b} (@code{c-submit-bug-report})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3323 command. This provides vital information I need to reproduce your
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3324 problem. Make sure you include a concise, but complete code example.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3325 Please try to boil your example down to just the essential code needed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3326 to reproduce the problem, and include an exact recipe of steps needed to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3327 expose the bug. Be especially sure to include any code that appears
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3328 @emph{before} your bug example, if you think it might affect my ability
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3329 to reproduce it.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3330
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3331 Bug reports are now sent to the following email addresses:
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3332 @code{cc-mode-help@@python.org} and
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3333 @code{bug-gnu-emacs@@prep.ai.mit.edu}; the latter is mirrored on the
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
3334 Usenet newsgroup @code{gnu.emacs.bug}. You can send other questions and
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
3335 suggestions (kudos? @code{;-)} to @code{cc-mode-help@@python.org}, or
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3336 @code{help-gnu-emacs@@prep.ai.mit.edu} which is mirrored on newsgroup
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3337 @code{gnu.emacs.help}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3338
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
3339 If you want to get announcements of new CC Mode releases, send the
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
3340 word @emph{subscribe} in the body of a message to
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
3341 @code{cc-mode-announce-request@@python.org}. Announcements will also be
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
3342 posted to the Usenet newsgroups @code{gnu.emacs.sources},
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
3343 @code{comp.emacs}, @code{comp.emacs.xemacs}, and possibly some of the
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
3344 language oriented newsgroups. Note that the
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
3345 @code{cc-mode-victims@@python.org} mailing list was recently
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
3346 decommissioned.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3347
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3348 @c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3349 @node Concept Index, Command Index, Mailing Lists and Submitting Bug Reports, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3350 @comment node-name, next, previous, up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3351 @unnumbered Concept Index
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3352 @c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3353
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3354 @printindex cp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3355
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3356
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3357 @c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3358 @node Command Index, Key Index, Concept Index, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3359 @comment node-name, next, previous, up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3360 @unnumbered Command Index
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3361 @c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3362
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3363 @ifinfo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3364
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3365 @end ifinfo
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3366 Since all @ccmode{} commands are prepended with the string
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3367 @samp{c-}, each appears under its @code{c-@var{<thing>}} name and its
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3368 @code{@var{<thing>} (c-)} name.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3369 @iftex
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3370 @sp 2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3371 @end iftex
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3372 @printindex fn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3373
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3374
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3375 @c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3376 @node Key Index, Variable Index, Command Index, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3377 @comment node-name, next, previous, up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3378 @unnumbered Key Index
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3379 @c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3380
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3381 @printindex ky
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3382
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3383
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3384 @c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3385 @node Variable Index, , Key Index, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3386 @comment node-name, next, previous, up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3387 @unnumbered Variable Index
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3388 @c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3389
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
3390 Since all @ccmode{} variables are prepended with the string
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3391 @samp{c-}, each appears under its @code{c-@var{<thing>}} name and its
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3392 @code{@var{<thing>} (c-)} name.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3393 @iftex
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3394 @sp 2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3395 @end iftex
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3396 @printindex vr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3397 @summarycontents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3398 @contents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3399 @bye