comparison lisp/cc-mode/cc-vars.el @ 165:5a88923fcbfe r20-3b9

Import from CVS: tag r20-3b9
author cvs
date Mon, 13 Aug 2007 09:44:42 +0200
parents
children 929b76928fce
comparison
equal deleted inserted replaced
164:4e0740e5aab2 165:5a88923fcbfe
1 ;;; cc-vars.el --- user customization variables for CC Mode
2
3 ;; Copyright (C) 1985,87,92,93,94,95,96,97 Free Software Foundation, Inc.
4
5 ;; Authors: 1992-1997 Barry A. Warsaw
6 ;; 1987 Dave Detlefs and Stewart Clamen
7 ;; 1985 Richard M. Stallman
8 ;; Maintainer: cc-mode-help@python.org
9 ;; Created: 22-Apr-1997 (split from cc-mode.el)
10 ;; Version: 5.11
11 ;; Keywords: c languages oop
12
13 ;; This file is part of GNU Emacs.
14
15 ;; GNU Emacs is free software; you can redistribute it and/or modify
16 ;; it under the terms of the GNU General Public License as published by
17 ;; the Free Software Foundation; either version 2, or (at your option)
18 ;; any later version.
19
20 ;; GNU Emacs is distributed in the hope that it will be useful,
21 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
22 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 ;; GNU General Public License for more details.
24
25 ;; You should have received a copy of the GNU General Public License
26 ;; along with GNU Emacs; see the file COPYING. If not, write to the
27 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
28 ;; Boston, MA 02111-1307, USA.
29
30 (require 'custom)
31
32
33 (defcustom c-strict-syntax-p nil
34 "*If non-nil, all syntactic symbols must be found in `c-offsets-alist'.
35 If the syntactic symbol for a particular line does not match a symbol
36 in the offsets alist, an error is generated, otherwise no error is
37 reported and the syntactic symbol is ignored."
38 :type 'boolean
39 :group 'c)
40
41 (defcustom c-echo-syntactic-information-p nil
42 "*If non-nil, syntactic info is echoed when the line is indented."
43 :type 'boolean
44 :group 'c)
45
46 (defcustom c-basic-offset 4
47 "*Amount of basic offset used by + and - symbols in `c-offsets-alist'."
48 :type 'integer
49 :group 'c)
50
51 (defcustom c-tab-always-indent t
52 "*Controls the operation of the TAB key.
53 If t, hitting TAB always just indents the current line. If nil,
54 hitting TAB indents the current line if point is at the left margin or
55 in the line's indentation, otherwise it insert a `real' tab character
56 \(see note\). If other than nil or t, then tab is inserted only
57 within literals -- defined as comments and strings -- and inside
58 preprocessor directives, but line is always reindented.
59
60 Note: The value of `indent-tabs-mode' will determine whether a real
61 tab character will be inserted, or the equivalent number of space.
62 When inserting a tab, actually the function stored in the variable
63 `c-insert-tab-function' is called.
64
65 Note: indentation of lines containing only comments is also controlled
66 by the `c-comment-only-line-offset' variable."
67 :type '(radio
68 :extra-offset 8
69 :format "%{Tab Always Indent%}:\n The TAB key\n%v"
70 (const :tag "always indents, never inserts TAB" t)
71 (const :tag "indents in left margin, otherwise inserts TAB" nil)
72 (const :tag "inserts TAB in literals, otherwise indent" other))
73 :group 'c)
74
75 (defcustom c-insert-tab-function 'insert-tab
76 "*Function used when inserting a tab for \\[TAB].
77 Only used when `c-tab-always-indent' indicates a `real' tab character
78 should be inserted. Value must be a function taking no arguments."
79 :type 'function
80 :group 'c)
81
82 (defcustom c-comment-only-line-offset 0
83 "*Extra offset for line which contains only the start of a comment.
84 Can contain an integer or a cons cell of the form:
85
86 (NON-ANCHORED-OFFSET . ANCHORED-OFFSET)
87
88 Where NON-ANCHORED-OFFSET is the amount of offset given to
89 non-column-zero anchored comment-only lines, and ANCHORED-OFFSET is
90 the amount of offset to give column-zero anchored comment-only lines.
91 Just an integer as value is equivalent to (<val> . -1000)."
92 :type '(choice (integer :tag "Non-anchored offset")
93 (cons :tag "Non-anchored & anchored offset"
94 :value (0 . 0)
95 :extra-offset 8
96 (integer :tag "Non-anchored offset")
97 (integer :tag "Anchored offset")))
98 :group 'c)
99
100 (defcustom c-indent-comments-syntactically-p nil
101 "*Specifies how comment-only lines should be indented.
102 When this variable is non-nil, comment-only lines are indented
103 according to syntactic analysis via `c-offsets-alist', even when
104 \\[indent-for-comment] is used."
105 :type 'boolean
106 :group 'c)
107
108 (defcustom c-cleanup-list '(scope-operator)
109 "*List of various C/C++/ObjC constructs to \"clean up\".
110 These clean ups only take place when the auto-newline feature is
111 turned on, as evidenced by the `/a' or `/ah' appearing next to the
112 mode name. Valid symbols are:
113
114 brace-else-brace -- cleans up `} else {' constructs by placing entire
115 construct on a single line. This clean up
116 only takes place when there is nothing but
117 white space between the braces and the `else'.
118 Clean up occurs when the open-brace after the
119 `else' is typed.
120 brace-elseif-brace -- similar to brace-else-brace, but cleans up
121 `} else if {' constructs.
122 empty-defun-braces -- cleans up empty defun braces by placing the
123 braces on the same line. Clean up occurs when
124 the defun closing brace is typed.
125 defun-close-semi -- cleans up the terminating semi-colon on defuns
126 by placing the semi-colon on the same line as
127 the closing brace. Clean up occurs when the
128 semi-colon is typed.
129 list-close-comma -- cleans up commas following braces in array
130 and aggregate initializers. Clean up occurs
131 when the comma is typed.
132 scope-operator -- cleans up double colons which may designate
133 a C++ scope operator split across multiple
134 lines. Note that certain C++ constructs can
135 generate ambiguous situations. This clean up
136 only takes place when there is nothing but
137 whitespace between colons. Clean up occurs
138 when the second colon is typed."
139 :type '(set
140 :extra-offset 8
141 (const :tag "Put `} else {' on one line" brace-else-brace)
142 (const :tag "Put `} else if {' on one line" brace-elseif-brace)
143 (const :tag "Put empty defun braces on one line" empty-defun-braces)
144 (const :tag "Put `},' in aggregates on one line" list-close-comma)
145 (const :tag "Put C++ style `::' on one line" scope-operator))
146 :group 'c)
147
148 (defcustom c-hanging-braces-alist '((brace-list-open)
149 (substatement-open after)
150 (block-close . c-snug-do-while)
151 (extern-lang-open after)
152 )
153 "*Controls the insertion of newlines before and after braces.
154 This variable contains an association list with elements of the
155 following form: (SYNTACTIC-SYMBOL . ACTION).
156
157 When a brace (either opening or closing) is inserted, the syntactic
158 context it defines is looked up in this list, and if found, the
159 associated ACTION is used to determine where newlines are inserted.
160 If the context is not found, the default is to insert a newline both
161 before and after the brace.
162
163 SYNTACTIC-SYMBOL can be any of: defun-open, defun-close, class-open,
164 class-close, inline-open, inline-close, block-open, block-close,
165 substatement-open, statement-case-open, extern-lang-open,
166 extern-lang-close, brace-list-open, brace-list-close,
167 brace-list-intro, or brace-list-entry. See `c-offsets-alist' for
168 details.
169
170 ACTION can be either a function symbol or a list containing any
171 combination of the symbols `before' or `after'. If the list is empty,
172 no newlines are inserted either before or after the brace.
173
174 When ACTION is a function symbol, the function is called with a two
175 arguments: the syntactic symbol for the brace and the buffer position
176 at which the brace was inserted. The function must return a list as
177 described in the preceding paragraph. Note that during the call to
178 the function, the variable `c-syntactic-context' is set to the entire
179 syntactic context for the brace line."
180 :type '(repeat
181 (cons :format "%v"
182 (choice :tag "Syntax"
183 (const defun-open) (const defun-close)
184 (const class-open) (const class-close)
185 (const inline-open) (const inline-close)
186 (const block-open) (const block-close)
187 (const substatement-open) (const statement-case-open)
188 (const extern-lang-open) (const extern-lang-close)
189 (const brace-list-open) (const brace-list-close)
190 (const brace-list-intro) (const brace-list-entry))
191 (choice :tag "Action"
192 (set :format "%v"
193 :extra-offset 8
194 (const before) (const after))
195 (function :format "%v" :value c-)
196 )))
197 :group 'c)
198
199 (defcustom c-hanging-colons-alist nil
200 "*Controls the insertion of newlines before and after certain colons.
201 This variable contains an association list with elements of the
202 following form: (SYNTACTIC-SYMBOL . ACTION).
203
204 SYNTACTIC-SYMBOL can be any of: case-label, label, access-label,
205 member-init-intro, or inher-intro.
206
207 See the variable `c-hanging-braces-alist' for the semantics of this
208 variable. Note however that making ACTION a function symbol is
209 currently not supported for this variable."
210 :type '(repeat
211 (cons :format "%v"
212 (choice :tag "Syntax"
213 (const case-label) (const label) (const access-label)
214 (const member-init-intro) (const inher-intro))
215 (set :tag "Action"
216 :format "%t: %v"
217 :extra-offset 8
218 (const before) (const after))))
219 :group 'c)
220
221 (defcustom c-hanging-semi&comma-criteria '(c-semi&comma-inside-parenlist)
222 "*List of functions that decide whether to insert a newline or not.
223 The functions in this list are called, in order, whenever the
224 auto-newline minor mode is activated (as evidenced by a `/a' or `/ah'
225 string in the mode line), and a semicolon or comma is typed (see
226 `c-electric-semi&comma'). Each function in this list is called with
227 no arguments, and should return one of the following values:
228
229 nil -- no determination made, continue checking
230 'stop -- do not insert a newline, and stop checking
231 (anything else) -- insert a newline, and stop checking
232
233 If every function in the list is called with no determination made,
234 then no newline is inserted."
235 :type '(repeat function)
236 :group 'c)
237
238 (defcustom c-hanging-comment-ender-p t
239 "*Controls what \\[fill-paragraph] does to C block comment enders.
240 When set to nil, C block comment enders are left on their own line.
241 When set to t, block comment enders will be placed at the end of the
242 previous line (i.e. they `hang' on that line)."
243 :type 'boolean
244 :group 'c)
245
246 (defcustom c-hanging-comment-starter-p t
247 "*Controls what \\[fill-paragraph] does to C block comment starters.
248 When set to nil, C block comment starters are left on their own line.
249 When set to t, text that follows a block comment starter will be
250 placed on the same line as the block comment starter (i.e. the text
251 `hangs' on that line)."
252 :type 'boolean
253 :group 'c)
254
255 (defcustom c-backslash-column 48
256 "*Column to insert backslashes when macroizing a region."
257 :type 'integer
258 :group 'c)
259
260 (defcustom c-special-indent-hook nil
261 "*Hook for user defined special indentation adjustments.
262 This hook gets called after a line is indented by the mode."
263 :type 'hook
264 :group 'c)
265
266 (defcustom c-backspace-function 'backward-delete-char-untabify
267 "*Function called by `c-electric-backspace' when deleting backwards."
268 :type 'function
269 :group 'c)
270
271 (defcustom c-delete-function 'delete-char
272 "*Function called by `c-electric-delete' when deleting forwards."
273 :type 'function
274 :group 'c)
275
276 (defcustom c-electric-pound-behavior nil
277 "*List of behaviors for electric pound insertion.
278 Only currently supported behavior is `alignleft'."
279 :type '(set :extra-offset 8 (const alignleft))
280 :group 'c)
281
282 (defcustom c-label-minimum-indentation 1
283 "*Minimum indentation for lines inside of top-level constructs.
284 This variable typically only affects code using the `gnu' style, which
285 mandates a minimum of one space in front of every line inside
286 top-level constructs. Specifically, the function
287 `c-gnu-impose-minimum' on your `c-special-indent-hook' is what
288 enforces this."
289 :type 'integer
290 :group 'c)
291
292 (defcustom c-progress-interval 5
293 "*Interval used to update progress status during long re-indentation.
294 If a number, percentage complete gets updated after each interval of
295 that many seconds. Set to nil to inhibit updating. This is only
296 useful for Emacs 19."
297 :type 'integer
298 :group 'c)
299
300 (defcustom c-site-default-style "gnu"
301 "Default style for your site.
302 To change the default style at your site, you can set this variable to
303 any style defined in `c-style-alist'. However, if CC Mode is usually
304 loaded into your Emacs at compile time, you will need to set this
305 variable in the `site-init.el' file before CC Mode is loaded, then
306 re-dump Emacs."
307 :type 'string
308 :group 'c)
309
310 (defcustom c-style-variables-are-local-p nil
311 "*Whether style variables should be buffer local by default.
312 If non-nil, then all indentation style related variables will be made
313 buffer local by default. If nil, they will remain global. Variables
314 are made buffer local when this file is loaded, and once buffer
315 localized, they cannot be made global again.
316
317 The list of variables to buffer localize are:
318 c-offsets-alist
319 c-basic-offset
320 c-file-style
321 c-file-offsets
322 c-comment-only-line-offset
323 c-cleanup-list
324 c-hanging-braces-alist
325 c-hanging-colons-alist
326 c-hanging-comment-starter-p
327 c-hanging-comment-ender-p
328 c-backslash-column
329 c-label-minimum-indentation
330 c-special-indent-hook
331 c-indentation-style"
332 :type 'boolean
333 :group 'c)
334
335 (defcustom c-mode-hook nil
336 "*Hook called by `c-mode'."
337 :type '(hook :format "%{C Mode Hook%}:\n%v")
338 :group 'c)
339
340 (defcustom c++-mode-hook nil
341 "*Hook called by `c++-mode'."
342 :type 'hook
343 :group 'c)
344
345 (defcustom objc-mode-hook nil
346 "*Hook called by `objc-mode'."
347 :type 'hook
348 :group 'c)
349
350 (defcustom java-mode-hook nil
351 "*Hook called by `java-mode'."
352 :type 'hook
353 :group 'c)
354
355 (defcustom c-mode-common-hook nil
356 "*Hook called by all CC Mode modes for common initializations."
357 :type '(hook :format "%{CC Mode Common Hook%}:\n%v")
358 :group 'c)
359
360
361
362 ;; Non-customizable variables, still part of the interface to CC Mode
363 (defvar c-file-style nil
364 "Variable interface for setting style via File Local Variables.
365 In a file's Local Variable section, you can set this variable to a
366 string suitable for `c-set-style'. When the file is visited, CC Mode
367 will set the style of the file to this value automatically.
368
369 Note that file style settings are applied before file offset settings
370 as designated in the variable `c-file-offsets'.")
371
372 (defvar c-file-offsets nil
373 "Variable interface for setting offsets via File Local Variables.
374 In a file's Local Variable section, you can set this variable to an
375 association list similar to the values allowed in `c-offsets-alist'.
376 When the file is visited, CC Mode will institute these offset settings
377 automatically.
378
379 Note that file offset settings are applied after file style settings
380 as designated in the variable `c-file-style'.")
381
382 (defvar c-syntactic-context nil
383 "Variable containing syntactic analysis list during indentation.")
384
385 (defvar c-indentation-style c-site-default-style
386 "Name of style installed in the current buffer.")
387
388
389 (provide 'cc-vars)
390 ;;; cc-vars.el ends here