Commit | Line | Data |
---|---|---|
785eecbb RS |
1 | ;;; cc-vars.el --- user customization variables for CC Mode |
2 | ||
92ab3834 | 3 | ;; Copyright (C) 1985, 1987, 1992, 1993, 1994, 1995, 1996, 1997, 1998, |
4e643dd2 | 4 | ;; 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 |
d7a0267c | 5 | ;; Free Software Foundation, Inc. |
785eecbb | 6 | |
e309f66c AM |
7 | ;; Authors: 2002- Alan Mackenzie |
8 | ;; 1998- Martin Stjernholm | |
d9e94c22 | 9 | ;; 1992-1999 Barry A. Warsaw |
785eecbb RS |
10 | ;; 1987 Dave Detlefs and Stewart Clamen |
11 | ;; 1985 Richard M. Stallman | |
0ec8351b | 12 | ;; Maintainer: bug-cc-mode@gnu.org |
785eecbb | 13 | ;; Created: 22-Apr-1997 (split from cc-mode.el) |
541aeedf | 14 | ;; Version: See cc-mode.el |
785eecbb RS |
15 | ;; Keywords: c languages oop |
16 | ||
17 | ;; This file is part of GNU Emacs. | |
18 | ||
19 | ;; GNU Emacs is free software; you can redistribute it and/or modify | |
20 | ;; it under the terms of the GNU General Public License as published by | |
1a484753 | 21 | ;; the Free Software Foundation; either version 3, or (at your option) |
785eecbb RS |
22 | ;; any later version. |
23 | ||
24 | ;; GNU Emacs is distributed in the hope that it will be useful, | |
25 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
26 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
27 | ;; GNU General Public License for more details. | |
28 | ||
29 | ;; You should have received a copy of the GNU General Public License | |
0386b551 | 30 | ;; along with this program; see the file COPYING. If not, write to |
3a35cf56 LK |
31 | ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
32 | ;; Boston, MA 02110-1301, USA. | |
785eecbb | 33 | |
3afbc435 PJ |
34 | ;;; Commentary: |
35 | ||
36 | ;;; Code: | |
37 | ||
0ec8351b | 38 | (eval-when-compile |
51f606de | 39 | (let ((load-path |
130c507e GM |
40 | (if (and (boundp 'byte-compile-dest-file) |
41 | (stringp byte-compile-dest-file)) | |
42 | (cons (file-name-directory byte-compile-dest-file) load-path) | |
51f606de | 43 | load-path))) |
d9e94c22 | 44 | (load "cc-bytecomp" nil t))) |
130c507e GM |
45 | |
46 | (cc-require 'cc-defs) | |
47 | ||
48 | ;; Silence the compiler. | |
0386b551 AM |
49 | (cc-bytecomp-defun get-char-table) ; XEmacs |
50 | ||
51 | (cc-eval-when-compile | |
52 | (require 'custom) | |
53 | (require 'widget)) | |
51f606de | 54 | |
a66cd3ee MS |
55 | (cc-eval-when-compile |
56 | ;; Need the function form of `backquote', which isn't standardized | |
57 | ;; between Emacsen. It's called `bq-process' in XEmacs, and | |
58 | ;; `backquote-process' in Emacs. `backquote-process' returns a | |
59 | ;; slightly more convoluted form, so let `bq-process' be the norm. | |
60 | (if (fboundp 'backquote-process) | |
61 | (cc-bytecomp-defmacro bq-process (form) | |
62 | `(cdr (backquote-process ,form))))) | |
63 | ||
51f606de GM |
64 | \f |
65 | ;;; Helpers | |
66 | ||
d9e94c22 | 67 | ;; This widget exists in newer versions of the Custom library |
51f606de GM |
68 | (or (get 'other 'widget-type) |
69 | (define-widget 'other 'sexp | |
70 | "Matches everything, but doesn't let the user edit the value. | |
71 | Useful as last item in a `choice' widget." | |
72 | :tag "Other" | |
73 | :format "%t%n" | |
74 | :value 'other)) | |
75 | ||
b4d0e517 | 76 | ;; The next defun will supersede c-const-symbol. |
3a3995f8 AM |
77 | (eval-and-compile |
78 | (defun c-constant-symbol (sym len) | |
b4d0e517 AM |
79 | "Create an uneditable symbol for customization buffers. |
80 | SYM is the name of the symbol, LEN the length of the field (in | |
81 | characters) the symbol will be displayed in. LEN must be big | |
82 | enough. | |
83 | ||
84 | This returns a (const ....) structure, suitable for embedding | |
85 | within a customization type." | |
86 | (or (symbolp sym) (error "c-constant-symbol: %s is not a symbol" sym)) | |
87 | (let* ((name (symbol-name sym)) | |
88 | (l (length name)) | |
89 | (disp (concat name ":" (make-string (- len l 1) ?\ )))) | |
90 | `(const | |
91 | :size ,len | |
92 | :format ,disp | |
3a3995f8 | 93 | :value ,sym)))) |
b4d0e517 | 94 | |
51f606de | 95 | (define-widget 'c-const-symbol 'item |
b4d0e517 AM |
96 | "An uneditable lisp symbol. This is obsolete - |
97 | use c-constant-symbol instead." | |
51f606de GM |
98 | :value nil |
99 | :tag "Symbol" | |
100 | :format "%t: %v\n%d" | |
101 | :match (lambda (widget value) (symbolp value)) | |
102 | :value-to-internal | |
103 | (lambda (widget value) | |
104 | (let ((s (if (symbolp value) | |
105 | (symbol-name value) | |
106 | value)) | |
107 | (l (widget-get widget :size))) | |
108 | (if l | |
109 | (setq s (concat s (make-string (- l (length s)) ?\ )))) | |
110 | s)) | |
111 | :value-to-external | |
112 | (lambda (widget value) | |
113 | (if (stringp value) | |
114 | (intern (progn | |
115 | (string-match "\\`[^ ]*" value) | |
116 | (match-string 0 value))) | |
117 | value))) | |
118 | ||
a66cd3ee MS |
119 | (define-widget 'c-integer-or-nil 'sexp |
120 | "An integer or the value nil." | |
121 | :value nil | |
122 | :tag "Optional integer" | |
123 | :match (lambda (widget value) (or (integerp value) (null value)))) | |
124 | ||
d9e94c22 MS |
125 | (define-widget 'c-symbol-list 'sexp |
126 | "A single symbol or a list of symbols." | |
127 | :tag "Symbols separated by spaces" | |
128 | :validate 'widget-field-validate | |
129 | :match | |
130 | (lambda (widget value) | |
131 | (or (symbolp value) | |
132 | (catch 'ok | |
133 | (while (listp value) | |
134 | (unless (symbolp (car value)) | |
135 | (throw 'ok nil)) | |
136 | (setq value (cdr value))) | |
137 | (null value)))) | |
138 | :value-to-internal | |
139 | (lambda (widget value) | |
140 | (cond ((null value) | |
141 | "") | |
142 | ((symbolp value) | |
143 | (symbol-name value)) | |
144 | ((consp value) | |
145 | (mapconcat (lambda (symbol) | |
146 | (symbol-name symbol)) | |
147 | value | |
148 | " ")) | |
149 | (t | |
150 | value))) | |
151 | :value-to-external | |
152 | (lambda (widget value) | |
153 | (if (stringp value) | |
154 | (let (list end) | |
155 | (while (string-match "\\S +" value end) | |
156 | (setq list (cons (intern (match-string 0 value)) list) | |
157 | end (match-end 0))) | |
158 | (if (and list (not (cdr list))) | |
159 | (car list) | |
160 | (nreverse list))) | |
161 | value))) | |
162 | ||
51f606de | 163 | (defvar c-style-variables |
a66cd3ee MS |
164 | '(c-basic-offset c-comment-only-line-offset c-indent-comment-alist |
165 | c-indent-comments-syntactically-p c-block-comment-prefix | |
d9e94c22 MS |
166 | c-comment-prefix-regexp c-doc-comment-style c-cleanup-list |
167 | c-hanging-braces-alist c-hanging-colons-alist | |
168 | c-hanging-semi&comma-criteria c-backslash-column c-backslash-max-column | |
169 | c-special-indent-hook c-label-minimum-indentation c-offsets-alist) | |
51f606de GM |
170 | "List of the style variables.") |
171 | ||
a66cd3ee MS |
172 | (defvar c-fallback-style nil) |
173 | ||
174 | (defsubst c-set-stylevar-fallback (name val) | |
175 | (put name 'c-stylevar-fallback val) | |
176 | (setq c-fallback-style (cons (cons name val) c-fallback-style))) | |
177 | ||
51f606de | 178 | (defmacro defcustom-c-stylevar (name val doc &rest args) |
6e4fcd29 GM |
179 | "Define a style variable NAME with VAL and DOC. |
180 | More precisely, convert the given `:type FOO', mined out of ARGS, | |
181 | to an aggregate `:type (radio STYLE (PREAMBLE FOO))', append some | |
182 | some boilerplate documentation to DOC, arrange for the fallback | |
183 | value of NAME to be VAL, and call `custom-declare-variable' to | |
184 | do the rest of the work. | |
185 | ||
186 | STYLE stands for the choice where the value is taken from some | |
187 | style setting. PREAMBLE is optionally prepended to FOO; that is, | |
188 | if FOO contains :tag or :value, the respective two-element list | |
189 | component is ignored." | |
190 | (declare (debug (symbolp form stringp &rest))) | |
191 | (let* ((expanded-doc (concat doc " | |
51f606de GM |
192 | |
193 | This is a style variable. Apart from the valid values described | |
6e4fcd29 GM |
194 | above, it can be set to the symbol `set-from-style'. In that case, |
195 | it takes its value from the style system (see `c-default-style' and | |
a66cd3ee | 196 | `c-style-alist') when a CC Mode buffer is initialized. Otherwise, |
51f606de | 197 | the value set here overrides the style system (there is a variable |
6e4fcd29 GM |
198 | `c-old-style-variable-behavior' that changes this, though).")) |
199 | (typ (eval (plist-get args :type))) | |
200 | (type (if (consp typ) typ (list typ))) | |
201 | (head (car type)) | |
202 | (tail (cdr type)) | |
203 | (newt (append (unless (plist-get tail :tag) | |
204 | '(:tag "Override style settings")) | |
205 | (unless (plist-get tail :value) | |
206 | `(:value ,(eval val))) | |
207 | tail)) | |
208 | (aggregate `'(radio | |
209 | (const :tag "Use style settings" set-from-style) | |
210 | ,(cons head newt)))) | |
211 | `(progn | |
212 | (c-set-stylevar-fallback ',name ,val) | |
213 | (custom-declare-variable | |
214 | ',name ''set-from-style | |
215 | ,expanded-doc | |
216 | ,@(plist-put args :type aggregate))))) | |
51f606de GM |
217 | |
218 | (defun c-valid-offset (offset) | |
e7f767c2 | 219 | "Return non-nil if OFFSET is a valid offset for a syntactic symbol. |
51f606de GM |
220 | See `c-offsets-alist'." |
221 | (or (eq offset '+) | |
222 | (eq offset '-) | |
223 | (eq offset '++) | |
224 | (eq offset '--) | |
225 | (eq offset '*) | |
226 | (eq offset '/) | |
227 | (integerp offset) | |
228 | (functionp offset) | |
0386b551 | 229 | (and (symbolp offset) (boundp offset)) |
a66cd3ee MS |
230 | (and (vectorp offset) |
231 | (= (length offset) 1) | |
232 | (integerp (elt offset 0))) | |
0386b551 AM |
233 | (and (consp offset) |
234 | (not (eq (car offset) 'quote)) ; Detect misquoted lists. | |
235 | (progn | |
236 | (when (memq (car offset) '(first min max add)) | |
237 | (setq offset (cdr offset))) | |
238 | (while (and (consp offset) | |
239 | (c-valid-offset (car offset))) | |
240 | (setq offset (cdr offset))) | |
241 | (null offset))))) | |
51f606de GM |
242 | |
243 | ||
785eecbb | 244 | \f |
51f606de GM |
245 | ;;; User variables |
246 | ||
785eecbb RS |
247 | (defcustom c-strict-syntax-p nil |
248 | "*If non-nil, all syntactic symbols must be found in `c-offsets-alist'. | |
249 | If the syntactic symbol for a particular line does not match a symbol | |
0ec8351b BW |
250 | in the offsets alist, or if no non-nil offset value can be determined |
251 | for a symbol, an error is generated, otherwise no error is reported | |
51f606de GM |
252 | and the syntactic symbol is ignored. |
253 | ||
254 | This variable is considered obsolete; it doesn't work well with lineup | |
255 | functions that return nil to support the feature of using lists on | |
256 | syntactic symbols in `c-offsets-alist'. Please keep it set to nil." | |
785eecbb RS |
257 | :type 'boolean |
258 | :group 'c) | |
259 | ||
260 | (defcustom c-echo-syntactic-information-p nil | |
261 | "*If non-nil, syntactic info is echoed when the line is indented." | |
262 | :type 'boolean | |
263 | :group 'c) | |
264 | ||
a66cd3ee MS |
265 | (defcustom c-report-syntactic-errors nil |
266 | "*If non-nil, certain syntactic errors are reported with a ding | |
267 | and a message, for example when an \"else\" is indented for which | |
268 | there's no corresponding \"if\". | |
269 | ||
270 | Note however that CC Mode doesn't make any special effort to check for | |
271 | syntactic errors; that's the job of the compiler. The reason it can | |
272 | report cases like the one above is that it can't find the correct | |
273 | anchoring position to indent the line in that case." | |
274 | :type 'boolean | |
275 | :group 'c) | |
276 | ||
51f606de | 277 | (defcustom-c-stylevar c-basic-offset 4 |
e96f5cb7 GM |
278 | "*Amount of basic offset used by + and - symbols in `c-offsets-alist'. |
279 | Also used as the indentation step when `c-syntactic-indentation' is | |
280 | nil." | |
785eecbb RS |
281 | :type 'integer |
282 | :group 'c) | |
631c8020 | 283 | ;;;###autoload(put 'c-basic-offset 'safe-local-variable 'integerp) |
785eecbb RS |
284 | |
285 | (defcustom c-tab-always-indent t | |
286 | "*Controls the operation of the TAB key. | |
2a15eb73 MS |
287 | If t, hitting TAB always just indents the current line. If nil, hitting |
288 | TAB indents the current line if point is at the left margin or in the | |
289 | line's indentation, otherwise it inserts a `real' tab character \(see | |
290 | note\). If some other value (not nil or t), then tab is inserted only | |
291 | within literals \(comments and strings), but the line is always | |
292 | reindented. | |
785eecbb RS |
293 | |
294 | Note: The value of `indent-tabs-mode' will determine whether a real | |
51f606de | 295 | tab character will be inserted, or the equivalent number of spaces. |
785eecbb RS |
296 | When inserting a tab, actually the function stored in the variable |
297 | `c-insert-tab-function' is called. | |
298 | ||
299 | Note: indentation of lines containing only comments is also controlled | |
300 | by the `c-comment-only-line-offset' variable." | |
301 | :type '(radio | |
a66cd3ee MS |
302 | (const :tag "TAB key always indents, never inserts TAB" t) |
303 | (const :tag "TAB key indents in left margin, otherwise inserts TAB" nil) | |
304 | (other :tag "TAB key inserts TAB in literals, otherwise indents" other)) | |
785eecbb RS |
305 | :group 'c) |
306 | ||
307 | (defcustom c-insert-tab-function 'insert-tab | |
e96f5cb7 | 308 | "*Function used when inserting a tab for \\[c-indent-command]. |
785eecbb RS |
309 | Only used when `c-tab-always-indent' indicates a `real' tab character |
310 | should be inserted. Value must be a function taking no arguments." | |
311 | :type 'function | |
312 | :group 'c) | |
313 | ||
e96f5cb7 | 314 | (defcustom c-syntactic-indentation t |
130c507e | 315 | "*Whether the indentation should be controlled by the syntactic context. |
e96f5cb7 | 316 | |
a66cd3ee | 317 | If t, the indentation functions indent according to the syntactic |
e96f5cb7 GM |
318 | context, using the style settings specified by `c-offsets-alist'. |
319 | ||
320 | If nil, every line is just indented to the same level as the previous | |
a66cd3ee MS |
321 | one, and the \\[c-indent-command] command adjusts the indentation in |
322 | steps specified by `c-basic-offset'. The indentation style has no | |
323 | effect in this mode, nor any of the indentation associated variables, | |
e96f5cb7 GM |
324 | e.g. `c-special-indent-hook'." |
325 | :type 'boolean | |
326 | :group 'c) | |
0386b551 | 327 | (make-variable-buffer-local 'c-syntactic-indentation) |
fc9a9287 | 328 | (put 'c-syntactic-indentation 'safe-local-variable 'booleanp) |
e96f5cb7 | 329 | |
a66cd3ee MS |
330 | (defcustom c-syntactic-indentation-in-macros t |
331 | "*Enable syntactic analysis inside macros. | |
332 | If this is nil, all lines inside macro definitions are analyzed as | |
333 | `cpp-macro-cont'. Otherwise they are analyzed syntactically, just | |
334 | like normal code, and `cpp-define-intro' is used to create the | |
335 | additional indentation of the bodies of \"#define\" macros. | |
336 | ||
337 | Having this enabled simplifies editing of large multiline macros, but | |
338 | it might complicate editing if CC Mode doesn't recognize the context | |
339 | of the macro content. The default context inside the macro is the | |
340 | same as the top level, so if it contains \"bare\" statements they | |
341 | might be indented wrongly, although there are special cases that | |
d9e94c22 | 342 | handle this in most cases. If this problem occurs, it's usually |
a66cd3ee MS |
343 | countered easily by surrounding the statements by a block \(or even |
344 | better with the \"do { ... } while \(0)\" trick)." | |
345 | :type 'boolean | |
346 | :group 'c) | |
fc9a9287 | 347 | (put 'c-syntactic-indentation-in-macros 'safe-local-variable 'booleanp) |
a66cd3ee | 348 | |
51f606de | 349 | (defcustom-c-stylevar c-comment-only-line-offset 0 |
785eecbb RS |
350 | "*Extra offset for line which contains only the start of a comment. |
351 | Can contain an integer or a cons cell of the form: | |
352 | ||
353 | (NON-ANCHORED-OFFSET . ANCHORED-OFFSET) | |
354 | ||
355 | Where NON-ANCHORED-OFFSET is the amount of offset given to | |
356 | non-column-zero anchored comment-only lines, and ANCHORED-OFFSET is | |
357 | the amount of offset to give column-zero anchored comment-only lines. | |
51f606de GM |
358 | Just an integer as value is equivalent to (<val> . -1000). |
359 | ||
360 | Note that this variable only has effect when the `c-lineup-comment' | |
361 | lineup function is used on the `comment-intro' syntactic symbol (the | |
362 | default)." | |
363 | :type '(choice (integer :tag "Non-anchored offset" 0) | |
785eecbb RS |
364 | (cons :tag "Non-anchored & anchored offset" |
365 | :value (0 . 0) | |
785eecbb RS |
366 | (integer :tag "Non-anchored offset") |
367 | (integer :tag "Anchored offset"))) | |
368 | :group 'c) | |
369 | ||
a66cd3ee MS |
370 | (defcustom-c-stylevar c-indent-comment-alist |
371 | '((anchored-comment . (column . 0)) | |
372 | (end-block . (space . 1)) | |
373 | (cpp-end-block . (space . 2))) | |
374 | "*Specifies how \\[indent-for-comment] calculates the comment start column. | |
375 | This is an association list that contains entries of the form: | |
376 | ||
377 | (LINE-TYPE . INDENT-SPEC) | |
378 | ||
379 | LINE-TYPE specifies a type of line as described below, and INDENT-SPEC | |
380 | says what \\[indent-for-comment] should do when used on that type of line. | |
381 | ||
382 | The recognized values for LINE-TYPE are: | |
383 | ||
384 | empty-line -- The line is empty. | |
385 | anchored-comment -- The line contains a comment that starts in column 0. | |
386 | end-block -- The line contains a solitary block closing brace. | |
387 | cpp-end-block -- The line contains a preprocessor directive that | |
388 | closes a block, i.e. either \"#endif\" or \"#else\". | |
389 | other -- The line does not match any other entry | |
390 | currently on the list. | |
391 | ||
392 | An INDENT-SPEC is a cons cell of the form: | |
393 | ||
394 | (ACTION . VALUE) | |
395 | ||
396 | ACTION says how \\[indent-for-comment] should align the comment, and | |
397 | VALUE is interpreted depending on ACTION. ACTION can be any of the | |
398 | following: | |
399 | ||
400 | space -- Put VALUE spaces between the end of the line and the start | |
401 | of the comment. | |
402 | column -- Start the comment at the column VALUE. If the line is | |
403 | longer than that, the comment is preceded by a single | |
404 | space. If VALUE is nil, `comment-column' is used. | |
405 | align -- Align the comment with one on the previous line, if there | |
406 | is any. If the line is too long, the comment is preceded | |
407 | by a single space. If there isn't a comment start on the | |
408 | previous line, the behavior is specified by VALUE, which | |
409 | in turn is interpreted as an INDENT-SPEC. | |
410 | ||
411 | If a LINE-TYPE is missing, then \\[indent-for-comment] indents the comment | |
412 | according to `comment-column'. | |
413 | ||
414 | Note that a non-nil value on `c-indent-comments-syntactically-p' | |
415 | overrides this variable, so empty lines are indentented syntactically | |
416 | in that case, i.e. as if \\[c-indent-command] was used instead." | |
417 | :type | |
418 | (let ((space '(cons :tag "space" | |
419 | :format "%v" | |
420 | :value (space . 1) | |
421 | (const :format "space " space) | |
422 | (integer :format "%v"))) | |
423 | (column '(cons :tag "column" | |
424 | :format "%v" | |
425 | (const :format "column " column) | |
426 | (c-integer-or-nil :format "%v")))) | |
427 | `(set ,@(mapcar | |
428 | (lambda (elt) | |
429 | `(cons :format "%v" | |
b4d0e517 | 430 | ,(c-constant-symbol elt 20) |
a66cd3ee MS |
431 | (choice |
432 | :format "%[Choice%] %v" | |
433 | :value (column . nil) | |
434 | ,space | |
435 | ,column | |
436 | (cons :tag "align" | |
437 | :format "%v" | |
438 | (const :format "align " align) | |
439 | (choice | |
440 | :format "%[Choice%] %v" | |
441 | :value (column . nil) | |
442 | ,space | |
443 | ,column))))) | |
444 | '(empty-line anchored-comment end-block cpp-end-block other)))) | |
445 | :group 'c) | |
446 | ||
447 | (defcustom-c-stylevar c-indent-comments-syntactically-p nil | |
51f606de | 448 | "*Specifies how \\[indent-for-comment] should handle comment-only lines. |
785eecbb | 449 | When this variable is non-nil, comment-only lines are indented |
51f606de GM |
450 | according to syntactic analysis via `c-offsets-alist'. Otherwise, the |
451 | comment is indented as if it was preceded by code. Note that this | |
452 | variable does not affect how the normal line indentation treats | |
453 | comment-only lines." | |
785eecbb RS |
454 | :type 'boolean |
455 | :group 'c) | |
456 | ||
130c507e GM |
457 | (make-obsolete-variable 'c-comment-continuation-stars |
458 | 'c-block-comment-prefix) | |
459 | ||
460 | ;; Although c-comment-continuation-stars is obsolete, we look at it in | |
461 | ;; some places in CC Mode anyway, so make the compiler ignore it | |
462 | ;; during our compilation. | |
d2f79585 TTN |
463 | ;; [This is unclean; better to use `symbol-value'. --ttn] |
464 | ;;(cc-bytecomp-obsolete-var c-comment-continuation-stars) | |
465 | ;;(cc-bytecomp-defvar c-comment-continuation-stars) | |
130c507e | 466 | |
51f606de GM |
467 | (defcustom-c-stylevar c-block-comment-prefix |
468 | (if (boundp 'c-comment-continuation-stars) | |
d2f79585 | 469 | (symbol-value 'c-comment-continuation-stars) |
51f606de GM |
470 | "* ") |
471 | "*Specifies the line prefix of continued C-style block comments. | |
d278ad4f RS |
472 | You should set this variable to the literal string that gets inserted |
473 | at the front of continued block style comment lines. This should | |
51f606de GM |
474 | either be the empty string, or some characters without preceding |
475 | spaces. To adjust the alignment under the comment starter, put an | |
476 | appropriate value on the `c' syntactic symbol (see the | |
477 | `c-offsets-alist' variable). | |
478 | ||
479 | It's only used when a one-line block comment is broken into two or | |
480 | more lines for the first time; otherwise the appropriate prefix is | |
481 | adapted from the comment. This variable is not used for C++ line | |
482 | style comments." | |
a66cd3ee | 483 | :type 'string |
51f606de GM |
484 | :group 'c) |
485 | ||
130c507e GM |
486 | (defcustom-c-stylevar c-comment-prefix-regexp |
487 | '((pike-mode . "//+!?\\|\\**") | |
0386b551 | 488 | (awk-mode . "#+") |
130c507e | 489 | (other . "//+\\|\\**")) |
51f606de GM |
490 | "*Regexp to match the line prefix inside comments. |
491 | This regexp is used to recognize the fill prefix inside comments for | |
492 | correct paragraph filling and other things. | |
493 | ||
130c507e GM |
494 | If this variable is a string, it will be used in all CC Mode major |
495 | modes. It can also be an association list, to associate specific | |
496 | regexps to specific major modes. The symbol for the major mode is | |
497 | looked up in the association list, and its value is used as the line | |
498 | prefix regexp. If it's not found, then the symbol `other' is looked | |
499 | up and its value is used instead. | |
500 | ||
501 | The regexp should match the prefix used in both C++ style line | |
502 | comments and C style block comments, but it does not need to match a | |
503 | block comment starter. In other words, it should at least match | |
504 | \"//\" for line comments and the string in `c-block-comment-prefix', | |
505 | which is sometimes inserted by CC Mode inside block comments. It | |
506 | should not match any surrounding whitespace. | |
51f606de | 507 | |
a66cd3ee | 508 | Note that CC Mode uses this variable to set many other variables that |
d9e94c22 | 509 | handle the paragraph filling. That's done at mode initialization or |
a66cd3ee MS |
510 | when you switch to a style which sets this variable. Thus, if you |
511 | change it in some other way, e.g. interactively in a CC Mode buffer, | |
0923382c MS |
512 | you will need to do \\[c-setup-paragraph-variables] afterwards so that |
513 | the other variables are updated with the new value. | |
a66cd3ee | 514 | |
0923382c MS |
515 | Note also that when CC Mode starts up, all variables are initialized |
516 | before the mode hooks are run. It's therefore necessary to make a | |
517 | call to `c-setup-paragraph-variables' explicitly if you change this | |
518 | variable in a mode hook." | |
130c507e GM |
519 | :type '(radio |
520 | (regexp :tag "Regexp for all modes") | |
521 | (list | |
522 | :tag "Mode-specific regexps" | |
523 | (set | |
524 | :inline t :format "%v" | |
525 | (cons :format "%v" | |
526 | (const :format "C " c-mode) (regexp :format "%v")) | |
527 | (cons :format "%v" | |
528 | (const :format "C++ " c++-mode) (regexp :format "%v")) | |
529 | (cons :format "%v" | |
530 | (const :format "ObjC " objc-mode) (regexp :format "%v")) | |
531 | (cons :format "%v" | |
532 | (const :format "Java " java-mode) (regexp :format "%v")) | |
533 | (cons :format "%v" | |
534 | (const :format "IDL " idl-mode) (regexp :format "%v")) | |
535 | (cons :format "%v" | |
0386b551 AM |
536 | (const :format "Pike " pike-mode) (regexp :format "%v")) |
537 | (cons :format "%v" | |
538 | (const :format "AWK " awk-mode) (regexp :format "%v"))) | |
130c507e GM |
539 | (cons :format " %v" |
540 | (const :format "Other " other) (regexp :format "%v")))) | |
d278ad4f RS |
541 | :group 'c) |
542 | ||
d9e94c22 MS |
543 | (defcustom-c-stylevar c-doc-comment-style |
544 | '((java-mode . javadoc) | |
0386b551 AM |
545 | (pike-mode . autodoc) |
546 | (c-mode . gtkdoc)) | |
d9e94c22 MS |
547 | "*Specifies documentation comment style(s) to recognize. |
548 | This is primarily used to fontify doc comments and the markup within | |
549 | them, e.g. Javadoc comments. | |
550 | ||
551 | The value can be any of the following symbols for various known doc | |
552 | comment styles: | |
553 | ||
554 | javadoc -- Javadoc style for \"/** ... */\" comments (default in Java mode). | |
555 | autodoc -- Pike autodoc style for \"//! ...\" comments (default in Pike mode). | |
0386b551 | 556 | gtkdoc -- GtkDoc style for \"/** ... **/\" comments (default in C mode). |
d9e94c22 MS |
557 | |
558 | The value may also be a list of doc comment styles, in which case all | |
559 | of them are recognized simultaneously (presumably with markup cues | |
560 | that don't conflict). | |
561 | ||
562 | The value may also be an association list to specify different doc | |
563 | comment styles for different languages. The symbol for the major mode | |
564 | is then looked up in the alist, and the value of that element is | |
565 | interpreted as above if found. If it isn't found then the symbol | |
566 | `other' is looked up and its value is used instead. | |
567 | ||
568 | Note that CC Mode uses this variable to set other variables that | |
569 | handle fontification etc. That's done at mode initialization or when | |
570 | you switch to a style which sets this variable. Thus, if you change | |
571 | it in some other way, e.g. interactively in a CC Mode buffer, you will | |
572 | need to do \\[java-mode] (or whatever mode you're currently using) to | |
573 | reinitialize. | |
574 | ||
575 | Note also that when CC Mode starts up, the other variables are | |
576 | modified before the mode hooks are run. If you change this variable | |
577 | in a mode hook, you have to call `c-setup-doc-comment-style' | |
578 | afterwards to redo that work." | |
579 | ;; Symbols other than those documented above may be used on this | |
580 | ;; variable. If a variable exists that has that name with | |
581 | ;; "-font-lock-keywords" appended, it's value is prepended to the | |
582 | ;; font lock keywords list. If it's a function then it's called and | |
583 | ;; the result is prepended. | |
584 | :type '(radio | |
585 | (c-symbol-list :tag "Doc style(s) in all modes") | |
586 | (list | |
587 | :tag "Mode-specific doc styles" | |
588 | (set | |
589 | :inline t :format "%v" | |
590 | (cons :format "%v" | |
591 | (const :format "C " c-mode) | |
592 | (c-symbol-list :format "%v")) | |
593 | (cons :format "%v" | |
594 | (const :format "C++ " c++-mode) | |
595 | (c-symbol-list :format "%v")) | |
596 | (cons :format "%v" | |
597 | (const :format "ObjC " objc-mode) | |
598 | (c-symbol-list :format "%v")) | |
599 | (cons :format "%v" | |
600 | (const :format "Java " java-mode) | |
601 | (c-symbol-list :format "%v")) | |
602 | (cons :format "%v" | |
603 | (const :format "IDL " idl-mode) | |
604 | (c-symbol-list :format "%v")) | |
605 | (cons :format "%v" | |
606 | (const :format "Pike " pike-mode) | |
607 | (c-symbol-list :format "%v")) | |
0386b551 AM |
608 | (cons :format "%v" |
609 | (const :format "AWK " awk-mode) | |
610 | (c-symbol-list :format "%v")) | |
d9e94c22 MS |
611 | (cons :format "%v" |
612 | (const :format "Other " other) | |
613 | (c-symbol-list :format "%v"))))) | |
614 | :group 'c) | |
615 | ||
51f606de GM |
616 | (defcustom c-ignore-auto-fill '(string cpp code) |
617 | "*List of contexts in which automatic filling never occurs. | |
618 | If Auto Fill mode is active, it will be temporarily disabled if point | |
619 | is in any context on this list. It's e.g. useful to enable Auto Fill | |
620 | in comments only, but not in strings or normal code. The valid | |
621 | contexts are: | |
622 | ||
623 | string -- inside a string or character literal | |
624 | c -- inside a C style block comment | |
625 | c++ -- inside a C++ style line comment | |
626 | cpp -- inside a preprocessor directive | |
627 | code -- anywhere else, i.e. in normal code" | |
628 | :type '(set | |
51f606de GM |
629 | (const :tag "String literals" string) |
630 | (const :tag "C style block comments" c) | |
631 | (const :tag "C++ style line comments" c++) | |
632 | (const :tag "Preprocessor directives" cpp) | |
633 | (const :tag "Normal code" code)) | |
634 | :group 'c) | |
635 | ||
636 | (defcustom-c-stylevar c-cleanup-list '(scope-operator) | |
785eecbb | 637 | "*List of various C/C++/ObjC constructs to \"clean up\". |
130c507e | 638 | The following clean ups only take place when the auto-newline feature |
0386b551 AM |
639 | is turned on, as evidenced by the `/la' appearing next to the mode |
640 | name: | |
785eecbb | 641 | |
130c507e GM |
642 | brace-else-brace -- Clean up \"} else {\" constructs by placing |
643 | entire construct on a single line. This clean | |
644 | up only takes place when there is nothing but | |
785eecbb | 645 | white space between the braces and the `else'. |
51f606de | 646 | Clean up occurs when the open brace after the |
785eecbb | 647 | `else' is typed. |
130c507e GM |
648 | brace-elseif-brace -- Similar to brace-else-brace, but clean up |
649 | \"} else if (...) {\" constructs. Clean up | |
650 | occurs after the open parenthesis and the open | |
651 | brace. | |
652 | brace-catch-brace -- Similar to brace-elseif-brace, but clean up | |
653 | \"} catch (...) {\" constructs. | |
654 | empty-defun-braces -- Clean up empty defun braces by placing the | |
785eecbb | 655 | braces on the same line. Clean up occurs when |
0386b551 | 656 | the defun closing brace is typed. |
51c9af45 AM |
657 | one-liner-defun -- If the code inside a function body can fit in |
658 | a single line, then remove any newlines | |
659 | between that line and the defun braces so that | |
660 | the whole body becomes a single line. | |
0386b551 AM |
661 | `c-max-one-liner-length' gives the maximum |
662 | length allowed for the resulting line. Clean | |
663 | up occurs when the closing brace is typed. | |
130c507e | 664 | defun-close-semi -- Clean up the terminating semi-colon on defuns |
0386b551 AM |
665 | by placing the semi-colon on the same line as |
666 | the closing brace. Clean up occurs when the | |
667 | semi-colon is typed. | |
130c507e | 668 | list-close-comma -- Clean up commas following braces in array |
785eecbb | 669 | and aggregate initializers. Clean up occurs |
0386b551 | 670 | when the comma is typed. |
130c507e | 671 | scope-operator -- Clean up double colons which may designate |
0386b551 AM |
672 | a C++ scope operator split across multiple |
673 | lines. Note that certain C++ constructs can | |
674 | generate ambiguous situations. This clean up | |
675 | only takes place when there is nothing but | |
676 | whitespace between colons. Clean up occurs | |
677 | when the second colon is typed. | |
130c507e GM |
678 | |
679 | The following clean ups always take place when they are on this list, | |
680 | regardless of the auto-newline feature, since they typically don't | |
681 | involve auto-newline inserted newlines: | |
682 | ||
683 | space-before-funcall -- Insert exactly one space before the opening | |
684 | parenthesis of a function call. Clean up | |
685 | occurs when the opening parenthesis is typed. | |
686 | compact-empty-funcall -- Clean up any space before the function call | |
0386b551 | 687 | opening parenthesis if and only if the |
130c507e GM |
688 | argument list is empty. This is typically |
689 | useful together with `space-before-funcall' to | |
690 | get the style \"foo (bar)\" and \"foo()\". | |
691 | Clean up occurs when the closing parenthesis | |
0386b551 AM |
692 | is typed. |
693 | comment-close-slash -- When a slash is typed after the comment prefix | |
694 | on a bare line in a c-style comment, the comment | |
695 | is closed by cleaning up preceding space and | |
696 | inserting a star if needed." | |
785eecbb | 697 | :type '(set |
0386b551 | 698 | (const :tag "Put \"} else {\" on one line (brace-else-brace)" |
130c507e | 699 | brace-else-brace) |
0386b551 | 700 | (const :tag "Put \"} else if (...) {\" on one line (brace-elseif-brace)" |
130c507e | 701 | brace-elseif-brace) |
0386b551 | 702 | (const :tag "Put \"} catch (...) {\" on one line (brace-catch-brace)" |
130c507e | 703 | brace-catch-brace) |
0386b551 | 704 | (const :tag "Put empty defun braces on one line (empty-defun-braces)" |
130c507e | 705 | empty-defun-braces) |
0386b551 AM |
706 | (const :tag "Put short function bodies on one line (one-liner-defun)" |
707 | one-liner-defun) | |
708 | (const :tag "Put \"};\" ending defuns on one line (defun-close-semi)" | |
130c507e | 709 | defun-close-semi) |
0386b551 | 710 | (const :tag "Put \"},\" in aggregates on one line (list-close-comma)" |
130c507e | 711 | list-close-comma) |
0386b551 | 712 | (const :tag "Put C++ style \"::\" on one line (scope-operator)" |
130c507e | 713 | scope-operator) |
0386b551 | 714 | (const :tag "Put a space before funcall parens, e.g. \"foo (bar)\" (space-before-funcall)" |
130c507e | 715 | space-before-funcall) |
0386b551 AM |
716 | (const :tag "Remove space before empty funcalls, e.g. \"foo()\" (compact-empty-funcall)" |
717 | compact-empty-funcall) | |
718 | (const :tag "Make / on a bare line of a C-style comment close it (comment-close-slash)" | |
719 | comment-close-slash)) | |
785eecbb RS |
720 | :group 'c) |
721 | ||
51f606de GM |
722 | (defcustom-c-stylevar c-hanging-braces-alist '((brace-list-open) |
723 | (brace-entry-open) | |
d9e94c22 | 724 | (statement-cont) |
51f606de GM |
725 | (substatement-open after) |
726 | (block-close . c-snug-do-while) | |
727 | (extern-lang-open after) | |
d9e94c22 MS |
728 | (namespace-open after) |
729 | (module-open after) | |
730 | (composition-open after) | |
51f606de | 731 | (inexpr-class-open after) |
4fae8922 AM |
732 | (inexpr-class-close before) |
733 | (arglist-cont-nonempty)) | |
51f606de GM |
734 | "*Controls the insertion of newlines before and after braces |
735 | when the auto-newline feature is active. This variable contains an | |
736 | association list with elements of the following form: | |
737 | \(SYNTACTIC-SYMBOL . ACTION). | |
785eecbb RS |
738 | |
739 | When a brace (either opening or closing) is inserted, the syntactic | |
740 | context it defines is looked up in this list, and if found, the | |
741 | associated ACTION is used to determine where newlines are inserted. | |
742 | If the context is not found, the default is to insert a newline both | |
743 | before and after the brace. | |
744 | ||
d9e94c22 MS |
745 | SYNTACTIC-SYMBOL can be statement-cont, brace-list-intro, |
746 | inexpr-class-open, inexpr-class-close, and any of the *-open and | |
747 | *-close symbols. See `c-offsets-alist' for details, except for | |
748 | inexpr-class-open and inexpr-class-close, which doesn't have any | |
749 | corresponding symbols there. Those two symbols are used for the | |
750 | opening and closing braces, respectively, of anonymous inner classes | |
751 | in Java. | |
785eecbb RS |
752 | |
753 | ACTION can be either a function symbol or a list containing any | |
754 | combination of the symbols `before' or `after'. If the list is empty, | |
755 | no newlines are inserted either before or after the brace. | |
756 | ||
757 | When ACTION is a function symbol, the function is called with a two | |
758 | arguments: the syntactic symbol for the brace and the buffer position | |
759 | at which the brace was inserted. The function must return a list as | |
760 | described in the preceding paragraph. Note that during the call to | |
761 | the function, the variable `c-syntactic-context' is set to the entire | |
762 | syntactic context for the brace line." | |
51f606de GM |
763 | :type |
764 | `(set ,@(mapcar | |
765 | (lambda (elt) | |
766 | `(cons :format "%v" | |
b4d0e517 | 767 | ,(c-constant-symbol elt 24) |
51f606de | 768 | (choice :format "%[Choice%] %v" |
a66cd3ee | 769 | :value (before after) |
51f606de | 770 | (set :menu-tag "Before/after" |
b4d0e517 AM |
771 | :format "Newline %v brace\n" |
772 | (const :format "%v, " before) | |
773 | (const :format "%v " after)) | |
51f606de | 774 | (function :menu-tag "Function" |
b4d0e517 | 775 | :format "Run function: %v")))) |
51f606de GM |
776 | '(defun-open defun-close |
777 | class-open class-close | |
778 | inline-open inline-close | |
779 | block-open block-close | |
d9e94c22 | 780 | statement-cont substatement-open statement-case-open |
51f606de GM |
781 | brace-list-open brace-list-close |
782 | brace-list-intro brace-entry-open | |
d9e94c22 | 783 | extern-lang-open extern-lang-close |
51f606de | 784 | namespace-open namespace-close |
d9e94c22 MS |
785 | module-open module-close |
786 | composition-open composition-close | |
4fae8922 AM |
787 | inexpr-class-open inexpr-class-close |
788 | arglist-cont-nonempty))) | |
51f606de GM |
789 | :group 'c) |
790 | ||
0386b551 AM |
791 | (defcustom c-max-one-liner-length 80 |
792 | "Maximum length of line that clean-up \"one-liner-defun\" will compact to. | |
793 | Zero or nil means no limit." | |
794 | :type 'integer | |
795 | :group 'c) | |
796 | ||
51f606de | 797 | (defcustom-c-stylevar c-hanging-colons-alist nil |
785eecbb RS |
798 | "*Controls the insertion of newlines before and after certain colons. |
799 | This variable contains an association list with elements of the | |
800 | following form: (SYNTACTIC-SYMBOL . ACTION). | |
801 | ||
802 | SYNTACTIC-SYMBOL can be any of: case-label, label, access-label, | |
803 | member-init-intro, or inher-intro. | |
804 | ||
805 | See the variable `c-hanging-braces-alist' for the semantics of this | |
806 | variable. Note however that making ACTION a function symbol is | |
807 | currently not supported for this variable." | |
51f606de GM |
808 | :type |
809 | `(set ,@(mapcar | |
810 | (lambda (elt) | |
811 | `(cons :format "%v" | |
b4d0e517 AM |
812 | ,(c-constant-symbol elt 20) |
813 | (set :format "Newline %v colon\n" | |
814 | (const :format "%v, " before) | |
51f606de GM |
815 | (const :format "%v" after)))) |
816 | '(case-label label access-label member-init-intro inher-intro))) | |
785eecbb RS |
817 | :group 'c) |
818 | ||
51f606de GM |
819 | (defcustom-c-stylevar c-hanging-semi&comma-criteria |
820 | '(c-semi&comma-inside-parenlist) | |
785eecbb RS |
821 | "*List of functions that decide whether to insert a newline or not. |
822 | The functions in this list are called, in order, whenever the | |
823 | auto-newline minor mode is activated (as evidenced by a `/a' or `/ah' | |
824 | string in the mode line), and a semicolon or comma is typed (see | |
825 | `c-electric-semi&comma'). Each function in this list is called with | |
826 | no arguments, and should return one of the following values: | |
827 | ||
828 | nil -- no determination made, continue checking | |
829 | 'stop -- do not insert a newline, and stop checking | |
830 | (anything else) -- insert a newline, and stop checking | |
831 | ||
832 | If every function in the list is called with no determination made, | |
833 | then no newline is inserted." | |
834 | :type '(repeat function) | |
835 | :group 'c) | |
836 | ||
51f606de | 837 | (defcustom-c-stylevar c-backslash-column 48 |
a66cd3ee MS |
838 | "*Minimum alignment column for line continuation backslashes. |
839 | This is used by the functions that automatically insert or align the | |
840 | line continuation backslashes in multiline macros. If any line in the | |
841 | macro exceeds this column then the next tab stop from that line is | |
aeef2654 | 842 | used as alignment column instead. See also `c-backslash-max-column'." |
785eecbb RS |
843 | :type 'integer |
844 | :group 'c) | |
664a80e9 | 845 | ;;;###autoload(put 'c-backslash-column 'safe-local-variable 'integerp) |
785eecbb | 846 | |
a66cd3ee MS |
847 | (defcustom-c-stylevar c-backslash-max-column 72 |
848 | "*Maximum alignment column for line continuation backslashes. | |
849 | This is used by the functions that automatically insert or align the | |
850 | line continuation backslashes in multiline macros. If any line in the | |
851 | macro exceeds this column then the backslashes for the other lines | |
852 | will be aligned at this column." | |
853 | :type 'integer | |
854 | :group 'c) | |
855 | ||
856 | (defcustom c-auto-align-backslashes t | |
857 | "*Align automatically inserted line continuation backslashes. | |
858 | When line continuation backslashes are inserted automatically for line | |
859 | breaks in multiline macros, e.g. by \\[c-context-line-break], they are | |
860 | aligned with the other backslashes in the same macro if this flag is | |
861 | set. Otherwise the inserted backslashes are preceded by a single | |
862 | space." | |
863 | :type 'boolean | |
785eecbb RS |
864 | :group 'c) |
865 | ||
866 | (defcustom c-backspace-function 'backward-delete-char-untabify | |
867 | "*Function called by `c-electric-backspace' when deleting backwards." | |
868 | :type 'function | |
869 | :group 'c) | |
870 | ||
871 | (defcustom c-delete-function 'delete-char | |
d9e94c22 | 872 | "*Function called by `c-electric-delete-forward' when deleting forwards." |
785eecbb RS |
873 | :type 'function |
874 | :group 'c) | |
875 | ||
e2c21e66 | 876 | (defcustom c-require-final-newline |
0386b551 | 877 | ;; C and C++ mandate that all nonempty files should end with a |
e2c21e66 | 878 | ;; newline. Objective-C refers to C for all things it doesn't |
0386b551 | 879 | ;; specify, so the same holds there. The other languages do not |
e2c21e66 MS |
880 | ;; require it (at least not explicitly in a normative text). |
881 | '((c-mode . t) | |
882 | (c++-mode . t) | |
883 | (objc-mode . t)) | |
0386b551 AM |
884 | "*Controls whether a final newline is ensured when the file is saved. |
885 | The value is an association list that for each language mode specifies | |
886 | the value to give to `require-final-newline' at mode initialization; | |
887 | see that variable for details about the value. If a language isn't | |
888 | present on the association list, CC Mode won't touch | |
889 | `require-final-newline' in buffers for that language." | |
e2c21e66 MS |
890 | :type `(set (cons :format "%v" |
891 | (const :format "C " c-mode) | |
0386b551 | 892 | (symbol :format "%v" :value ,require-final-newline)) |
e2c21e66 MS |
893 | (cons :format "%v" |
894 | (const :format "C++ " c++-mode) | |
0386b551 | 895 | (symbol :format "%v" :value ,require-final-newline)) |
e2c21e66 MS |
896 | (cons :format "%v" |
897 | (const :format "ObjC " objc-mode) | |
0386b551 | 898 | (symbol :format "%v" :value ,require-final-newline)) |
e2c21e66 MS |
899 | (cons :format "%v" |
900 | (const :format "Java " java-mode) | |
0386b551 | 901 | (symbol :format "%v" :value ,require-final-newline)) |
e2c21e66 MS |
902 | (cons :format "%v" |
903 | (const :format "IDL " idl-mode) | |
0386b551 | 904 | (symbol :format "%v" :value ,require-final-newline)) |
e2c21e66 MS |
905 | (cons :format "%v" |
906 | (const :format "Pike " pike-mode) | |
0386b551 AM |
907 | (symbol :format "%v" :value ,require-final-newline)) |
908 | (cons :format "%v" | |
909 | (const :format "AWK " awk-mode) | |
910 | (symbol :format "%v" :value ,require-final-newline))) | |
980a8a00 MS |
911 | :group 'c) |
912 | ||
785eecbb RS |
913 | (defcustom c-electric-pound-behavior nil |
914 | "*List of behaviors for electric pound insertion. | |
915 | Only currently supported behavior is `alignleft'." | |
a66cd3ee MS |
916 | :type '(set (const alignleft)) |
917 | :group 'c) | |
918 | ||
919 | (defcustom c-special-indent-hook nil | |
920 | "*Hook for user defined special indentation adjustments. | |
c788945f AM |
921 | This hook gets called after each line is indented by the mode. It is only |
922 | called if `c-syntactic-indentation' is non-nil." | |
a66cd3ee | 923 | :type 'hook |
785eecbb RS |
924 | :group 'c) |
925 | ||
51f606de | 926 | (defcustom-c-stylevar c-label-minimum-indentation 1 |
037558bf | 927 | "*Minimum indentation for lines inside code blocks. |
785eecbb | 928 | This variable typically only affects code using the `gnu' style, which |
037558bf MS |
929 | mandates a minimum of one space in front of every line inside code |
930 | blocks. Specifically, the function `c-gnu-impose-minimum' on your | |
931 | `c-special-indent-hook' is what enforces this." | |
785eecbb RS |
932 | :type 'integer |
933 | :group 'c) | |
934 | ||
935 | (defcustom c-progress-interval 5 | |
936 | "*Interval used to update progress status during long re-indentation. | |
937 | If a number, percentage complete gets updated after each interval of | |
541aeedf KH |
938 | that many seconds. To inhibit all messages during indentation, set |
939 | this variable to nil." | |
785eecbb RS |
940 | :type 'integer |
941 | :group 'c) | |
942 | ||
0386b551 AM |
943 | (defcustom c-default-style '((java-mode . "java") (awk-mode . "awk") |
944 | (other . "gnu")) | |
0ec8351b | 945 | "*Style which gets installed by default when a file is visited. |
87f235fb RS |
946 | |
947 | The value of this variable can be any style defined in | |
0ec8351b BW |
948 | `c-style-alist', including styles you add. The value can also be an |
949 | association list of major mode symbols to style names. | |
950 | ||
951 | When the value is a string, all CC Mode major modes will install this | |
130c507e | 952 | style by default. |
0ec8351b | 953 | |
51f606de GM |
954 | When the value is an alist, the major mode symbol is looked up in it |
955 | and the associated style is installed. If the major mode is not | |
956 | listed in the alist, then the symbol `other' is looked up in it, and | |
957 | if found, the style in that entry is used. If `other' is not found in | |
958 | the alist, then \"gnu\" style is used. | |
959 | ||
960 | The default style gets installed before your mode hooks run, so you | |
961 | can always override the use of `c-default-style' by making calls to | |
130c507e | 962 | `c-set-style' in the appropriate mode hook." |
51f606de | 963 | :type '(radio |
130c507e GM |
964 | (string :tag "Style in all modes") |
965 | (set :tag "Mode-specific styles" | |
966 | (cons :format "%v" | |
967 | (const :format "C " c-mode) (string :format "%v")) | |
968 | (cons :format "%v" | |
969 | (const :format "C++ " c++-mode) (string :format "%v")) | |
970 | (cons :format "%v" | |
971 | (const :format "ObjC " objc-mode) (string :format "%v")) | |
972 | (cons :format "%v" | |
973 | (const :format "Java " java-mode) (string :format "%v")) | |
974 | (cons :format "%v" | |
975 | (const :format "IDL " idl-mode) (string :format "%v")) | |
976 | (cons :format "%v" | |
977 | (const :format "Pike " pike-mode) (string :format "%v")) | |
0386b551 AM |
978 | (cons :format "%v" |
979 | (const :format "AWK " awk-mode) (string :format "%v")) | |
130c507e GM |
980 | (cons :format "%v" |
981 | (const :format "Other " other) (string :format "%v")))) | |
51f606de GM |
982 | :group 'c) |
983 | ||
a66cd3ee MS |
984 | ;; *) At the start of a statement or declaration means in more detail: |
985 | ;; At the closest preceding statement/declaration that starts at boi | |
986 | ;; and doesn't have a label or comment at that position. If there's | |
987 | ;; no such statement within the same block, then back up to the | |
988 | ;; surrounding block or statement, add the appropriate | |
989 | ;; statement-block-intro, defun-block-intro or substatement syntax | |
990 | ;; symbol and continue searching. | |
991 | (c-set-stylevar-fallback 'c-offsets-alist | |
51f606de | 992 | '((string . c-lineup-dont-change) |
0386b551 | 993 | ;; Anchor pos: Beg of previous line. |
51f606de | 994 | (c . c-lineup-C-comments) |
0386b551 | 995 | ;; Anchor pos: Beg of the comment. |
51f606de | 996 | (defun-open . 0) |
0386b551 | 997 | ;; Anchor pos: When inside a class: Boi at the func decl start. |
a66cd3ee MS |
998 | ;; When at top level: Bol at the func decl start. When inside |
999 | ;; a code block (only possible in Pike): At the func decl | |
1000 | ;; start(*). | |
51f606de | 1001 | (defun-close . 0) |
0386b551 AM |
1002 | ;; Anchor pos: At the defun block open if it's at boi, |
1003 | ;; otherwise boi at the func decl start. | |
51f606de | 1004 | (defun-block-intro . +) |
0386b551 | 1005 | ;; Anchor pos: At the block open(*). |
51f606de | 1006 | (class-open . 0) |
0386b551 | 1007 | ;; Anchor pos: Boi at the class decl start. |
51f606de | 1008 | (class-close . 0) |
0386b551 | 1009 | ;; Anchor pos: Boi at the class decl start. |
51f606de | 1010 | (inline-open . +) |
0386b551 AM |
1011 | ;; Anchor pos: None for functions (inclass got the relpos |
1012 | ;; then), boi at the lambda start for lambdas. | |
51f606de | 1013 | (inline-close . 0) |
0386b551 AM |
1014 | ;; Anchor pos: Inexpr functions: At the lambda block open if |
1015 | ;; it's at boi, else at the statement(*) at boi of the start of | |
1016 | ;; the lambda construct. Otherwise: At the inline block open | |
1017 | ;; if it's at boi, otherwise boi at the func decl start. | |
51f606de | 1018 | (func-decl-cont . +) |
0386b551 | 1019 | ;; Anchor pos: Boi at the func decl start. |
51f606de | 1020 | (knr-argdecl-intro . +) |
0386b551 | 1021 | ;; Anchor pos: Boi at the topmost intro line. |
51f606de | 1022 | (knr-argdecl . 0) |
0386b551 | 1023 | ;; Anchor pos: At the beginning of the first K&R argdecl. |
51f606de | 1024 | (topmost-intro . 0) |
0386b551 | 1025 | ;; Anchor pos: Bol at the last line of previous construct. |
a66cd3ee | 1026 | (topmost-intro-cont . c-lineup-topmost-intro-cont) |
0386b551 | 1027 | ;; Anchor pos: Boi at the topmost intro line. |
51f606de | 1028 | (member-init-intro . +) |
0386b551 | 1029 | ;; Anchor pos: Boi at the func decl arglist open. |
e96f5cb7 | 1030 | (member-init-cont . c-lineup-multi-inher) |
0386b551 | 1031 | ;; Anchor pos: Beg of the first member init. |
51f606de | 1032 | (inher-intro . +) |
0386b551 | 1033 | ;; Anchor pos: Boi at the class decl start. |
51f606de | 1034 | (inher-cont . c-lineup-multi-inher) |
0386b551 | 1035 | ;; Anchor pos: Java: At the implements/extends keyword start. |
51f606de GM |
1036 | ;; Otherwise: At the inher start colon, or boi at the class |
1037 | ;; decl start if the first inherit clause hangs and it's not a | |
1038 | ;; func-local inherit clause (when does that occur?). | |
1039 | (block-open . 0) | |
0386b551 AM |
1040 | ;; Anchor pos: Inexpr statement: At the statement(*) at boi of |
1041 | ;; the start of the inexpr construct. Otherwise: None. | |
51f606de | 1042 | (block-close . 0) |
0386b551 AM |
1043 | ;; Anchor pos: Inexpr statement: At the inexpr block open if |
1044 | ;; it's at boi, else at the statement(*) at boi of the start of | |
1045 | ;; the inexpr construct. Block hanging on a case/default | |
1046 | ;; label: At the closest preceding label that starts at boi. | |
1047 | ;; Otherwise: At the block open(*). | |
51f606de | 1048 | (brace-list-open . 0) |
0386b551 | 1049 | ;; Anchor pos: Boi at the brace list decl start, but a starting |
51f606de GM |
1050 | ;; "typedef" token is ignored. |
1051 | (brace-list-close . 0) | |
0386b551 | 1052 | ;; Anchor pos: At the brace list decl start(*). |
51f606de | 1053 | (brace-list-intro . +) |
0386b551 | 1054 | ;; Anchor pos: At the brace list decl start(*). |
51f606de | 1055 | (brace-list-entry . 0) |
0386b551 AM |
1056 | ;; Anchor pos: At the first non-ws char after the open paren if |
1057 | ;; the first token is on the same line, otherwise boi at that | |
51f606de GM |
1058 | ;; token. |
1059 | (brace-entry-open . 0) | |
0386b551 | 1060 | ;; Anchor pos: Same as brace-list-entry. |
51f606de | 1061 | (statement . 0) |
0386b551 | 1062 | ;; Anchor pos: After a `;' in the condition clause of a for |
51f606de | 1063 | ;; statement: At the first token after the starting paren. |
a66cd3ee | 1064 | ;; Otherwise: At the preceding statement(*). |
51f606de | 1065 | (statement-cont . +) |
0386b551 AM |
1066 | ;; Anchor pos: After the first token in the condition clause of |
1067 | ;; a for statement: At the first token after the starting | |
1068 | ;; paren. Otherwise: At the containing statement(*). | |
51f606de | 1069 | (statement-block-intro . +) |
0386b551 AM |
1070 | ;; Anchor pos: In inexpr statement block: At the inexpr block |
1071 | ;; open if it's at boi, else at the statement(*) at boi of the | |
1072 | ;; start of the inexpr construct. In a block hanging on a | |
a66cd3ee MS |
1073 | ;; case/default label: At the closest preceding label that |
1074 | ;; starts at boi. Otherwise: At the start of the containing | |
1075 | ;; block(*). | |
51f606de | 1076 | (statement-case-intro . +) |
0386b551 | 1077 | ;; Anchor pos: At the case/default label(*). |
51f606de | 1078 | (statement-case-open . 0) |
0386b551 | 1079 | ;; Anchor pos: At the case/default label(*). |
51f606de | 1080 | (substatement . +) |
0386b551 | 1081 | ;; Anchor pos: At the containing statement(*). |
51f606de | 1082 | (substatement-open . +) |
0386b551 | 1083 | ;; Anchor pos: At the containing statement(*). |
a66cd3ee | 1084 | (substatement-label . 2) |
0386b551 | 1085 | ;; Anchor pos: At the containing statement(*). |
51f606de | 1086 | (case-label . 0) |
0386b551 | 1087 | ;; Anchor pos: At the start of the switch block(*). |
51f606de | 1088 | (access-label . -) |
0386b551 | 1089 | ;; Anchor pos: Same as inclass. |
51f606de | 1090 | (label . 2) |
0386b551 | 1091 | ;; Anchor pos: At the start of the containing block(*). |
51f606de | 1092 | (do-while-closure . 0) |
0386b551 | 1093 | ;; Anchor pos: At the corresponding while statement(*). |
51f606de | 1094 | (else-clause . 0) |
0386b551 | 1095 | ;; Anchor pos: At the corresponding if statement(*). |
51f606de | 1096 | (catch-clause . 0) |
0386b551 | 1097 | ;; Anchor pos: At the previous try or catch statement clause(*). |
a66cd3ee | 1098 | (comment-intro . (c-lineup-knr-region-comment c-lineup-comment)) |
0386b551 | 1099 | ;; Anchor pos: None. |
51f606de | 1100 | (arglist-intro . +) |
0386b551 AM |
1101 | ;; Anchor pos: At the containing statement(*). |
1102 | ;; 2nd pos: At the open paren. | |
a66cd3ee | 1103 | (arglist-cont . (c-lineup-gcc-asm-reg 0)) |
0386b551 | 1104 | ;; Anchor pos: At the first token after the open paren. |
a66cd3ee | 1105 | (arglist-cont-nonempty . (c-lineup-gcc-asm-reg c-lineup-arglist)) |
0386b551 | 1106 | ;; Anchor pos: At the containing statement(*). |
d9e94c22 | 1107 | ;; 2nd pos: At the open paren. |
51f606de | 1108 | (arglist-close . +) |
0386b551 | 1109 | ;; Anchor pos: At the containing statement(*). |
d9e94c22 | 1110 | ;; 2nd pos: At the open paren. |
51f606de | 1111 | (stream-op . c-lineup-streamop) |
0386b551 | 1112 | ;; Anchor pos: Boi at the first stream op in the statement. |
51f606de | 1113 | (inclass . +) |
0386b551 AM |
1114 | ;; Anchor pos: At the class open brace if it's at boi, |
1115 | ;; otherwise boi at the class decl start. | |
130c507e | 1116 | (cpp-macro . [0]) |
0386b551 | 1117 | ;; Anchor pos: None. |
a66cd3ee | 1118 | (cpp-macro-cont . +) |
0386b551 | 1119 | ;; Anchor pos: At the macro start (always at boi). |
a66cd3ee | 1120 | (cpp-define-intro . (c-lineup-cpp-define +)) |
0386b551 | 1121 | ;; Anchor pos: None. |
51f606de | 1122 | (friend . 0) |
0386b551 | 1123 | ;; Anchor pos: None. |
130c507e | 1124 | (objc-method-intro . [0]) |
0386b551 | 1125 | ;; Anchor pos: Boi. |
51f606de | 1126 | (objc-method-args-cont . c-lineup-ObjC-method-args) |
0386b551 | 1127 | ;; Anchor pos: At the method start (always at boi). |
51f606de | 1128 | (objc-method-call-cont . c-lineup-ObjC-method-call) |
0386b551 | 1129 | ;; Anchor pos: At the open bracket. |
51f606de | 1130 | (extern-lang-open . 0) |
51f606de | 1131 | (namespace-open . 0) |
d9e94c22 MS |
1132 | (module-open . 0) |
1133 | (composition-open . 0) | |
0386b551 | 1134 | ;; Anchor pos: Boi at the extern/namespace/etc keyword. |
d9e94c22 | 1135 | (extern-lang-close . 0) |
51f606de | 1136 | (namespace-close . 0) |
d9e94c22 MS |
1137 | (module-close . 0) |
1138 | (composition-close . 0) | |
0386b551 | 1139 | ;; Anchor pos: Boi at the corresponding extern/namespace/etc keyword. |
d9e94c22 | 1140 | (inextern-lang . +) |
51f606de | 1141 | (innamespace . +) |
d9e94c22 MS |
1142 | (inmodule . +) |
1143 | (incomposition . +) | |
0386b551 AM |
1144 | ;; Anchor pos: At the extern/namespace/etc block open brace if |
1145 | ;; it's at boi, otherwise boi at the keyword. | |
51f606de | 1146 | (template-args-cont . (c-lineup-template-args +)) |
0386b551 AM |
1147 | ;; Anchor pos: Boi at the decl start. This might be changed; |
1148 | ;; the logical position is clearly the opening '<'. | |
51f606de | 1149 | (inlambda . c-lineup-inexpr-block) |
0386b551 | 1150 | ;; Anchor pos: None. |
51f606de | 1151 | (lambda-intro-cont . +) |
0386b551 | 1152 | ;; Anchor pos: Boi at the lambda start. |
a66cd3ee | 1153 | (inexpr-statement . +) |
0386b551 | 1154 | ;; Anchor pos: None. |
51f606de | 1155 | (inexpr-class . +) |
0386b551 | 1156 | ;; Anchor pos: None. |
51f606de GM |
1157 | )) |
1158 | (defcustom c-offsets-alist nil | |
1159 | "Association list of syntactic element symbols and indentation offsets. | |
1160 | As described below, each cons cell in this list has the form: | |
1161 | ||
1162 | (SYNTACTIC-SYMBOL . OFFSET) | |
1163 | ||
1164 | When a line is indented, CC Mode first determines the syntactic | |
1165 | context of it by generating a list of symbols called syntactic | |
0386b551 AM |
1166 | elements. The global variable `c-syntactic-context' is bound to the |
1167 | that list. Each element in the list is in turn a list where the first | |
1168 | element is a syntactic symbol which tells what kind of construct the | |
1169 | indentation point is located within. More elements in the syntactic | |
1170 | element lists are optional. If there is one more and it isn't nil, | |
1171 | then it's the anchor position for that construct. | |
1172 | ||
1173 | After generating the syntactic context for the line, CC Mode | |
1174 | calculates the absolute indentation: First the base indentation is | |
1175 | found by using the anchor position for the first syntactic element | |
1176 | that provides one. If none does, zero is used as base indentation. | |
1177 | Then CC Mode looks at each syntactic element in the context in turn. | |
1178 | It compares the car of the syntactic element against the | |
1179 | SYNTACTIC-SYMBOL's in `c-offsets-alist'. When it finds a match, it | |
1180 | adds OFFSET to the base indentation. The sum of this calculation is | |
51f606de GM |
1181 | the absolute offset for line being indented. |
1182 | ||
1183 | If the syntactic element does not match any in the `c-offsets-alist', | |
130c507e GM |
1184 | the element is ignored. |
1185 | ||
0386b551 AM |
1186 | OFFSET can specify an offset in several different ways: |
1187 | ||
1188 | If OFFSET is nil then it's ignored. | |
1189 | ||
1190 | If OFFSET is an integer then it's used as relative offset, i.e. it's | |
1191 | added to the base indentation. | |
130c507e | 1192 | |
0386b551 AM |
1193 | If OFFSET is one of the symbols `+', `-', `++', `--', `*', or `/' |
1194 | then a positive or negative multiple of `c-basic-offset' is added to | |
1195 | the base indentation; 1, -1, 2, -2, 0.5, and -0.5, respectively. | |
130c507e | 1196 | |
0386b551 AM |
1197 | If OFFSET is a symbol with a value binding then that value, which |
1198 | must be an integer, is used as relative offset. | |
130c507e | 1199 | |
12f5c601 | 1200 | If OFFSET is a vector then its first element, which must be an |
0386b551 AM |
1201 | integer, is used as an absolute indentation column. This overrides |
1202 | the previous base indentation and the relative offsets applied to | |
1203 | it, and it becomes the new base indentation. | |
130c507e | 1204 | |
0386b551 AM |
1205 | If OFFSET is a function or a lambda expression then it's called with |
1206 | a single argument containing the cons of the syntactic symbol and | |
1207 | the anchor position (or nil if there is none). The return value | |
1208 | from the function is then reinterpreted as an offset specification. | |
130c507e | 1209 | |
0386b551 AM |
1210 | If OFFSET is a list then its elements are evaluated recursively as |
1211 | offset specifications. If the first element is any of the symbols | |
1212 | below then it isn't evaluated but instead specifies how the | |
1213 | remaining offsets in the list should be combined. If it's something | |
1214 | else then the list is combined according the method `first'. The | |
1215 | valid combination methods are: | |
1216 | ||
1217 | `first' -- Use the first offset (that doesn't evaluate to nil). | |
1218 | `min' -- Use the minimum of all the offsets. All must be either | |
1219 | relative or absolute - they can't be mixed. | |
1220 | `max' -- Use the maximum of all the offsets. All must be either | |
1221 | relative or absolute - they can't be mixed. | |
1222 | `add' -- Add all the evaluated offsets together. Exactly one of | |
1223 | them may be absolute, in which case the result is | |
1224 | absolute. Any relative offsets that preceded the | |
1225 | absolute one in the list will be ignored in that case. | |
51f606de GM |
1226 | |
1227 | `c-offsets-alist' is a style variable. This means that the offsets on | |
1228 | this variable are normally taken from the style system in CC Mode | |
a66cd3ee | 1229 | \(see `c-default-style' and `c-style-alist'). However, any offsets |
51f606de GM |
1230 | put explicitly on this list will override the style system when a CC |
1231 | Mode buffer is initialized \(there is a variable | |
1232 | `c-old-style-variable-behavior' that changes this, though). | |
1233 | ||
1234 | Here is the current list of valid syntactic element symbols: | |
1235 | ||
1236 | string -- Inside multi-line string. | |
1237 | c -- Inside a multi-line C style block comment. | |
1238 | defun-open -- Brace that opens a function definition. | |
1239 | defun-close -- Brace that closes a function definition. | |
1240 | defun-block-intro -- The first line in a top-level defun. | |
1241 | class-open -- Brace that opens a class definition. | |
1242 | class-close -- Brace that closes a class definition. | |
1243 | inline-open -- Brace that opens an in-class inline method. | |
1244 | inline-close -- Brace that closes an in-class inline method. | |
1245 | func-decl-cont -- The region between a function definition's | |
1246 | argument list and the function opening brace | |
1247 | (excluding K&R argument declarations). In C, you | |
1248 | cannot put anything but whitespace and comments | |
1249 | between them; in C++ and Java, throws declarations | |
1250 | and other things can appear in this context. | |
1251 | knr-argdecl-intro -- First line of a K&R C argument declaration. | |
1252 | knr-argdecl -- Subsequent lines in a K&R C argument declaration. | |
1253 | topmost-intro -- The first line in a topmost construct definition. | |
1254 | topmost-intro-cont -- Topmost definition continuation lines. | |
1255 | member-init-intro -- First line in a member initialization list. | |
1256 | member-init-cont -- Subsequent member initialization list lines. | |
1257 | inher-intro -- First line of a multiple inheritance list. | |
1258 | inher-cont -- Subsequent multiple inheritance lines. | |
1259 | block-open -- Statement block open brace. | |
1260 | block-close -- Statement block close brace. | |
1261 | brace-list-open -- Open brace of an enum or static array list. | |
1262 | brace-list-close -- Close brace of an enum or static array list. | |
1263 | brace-list-intro -- First line in an enum or static array list. | |
1264 | brace-list-entry -- Subsequent lines in an enum or static array list. | |
1265 | brace-entry-open -- Subsequent lines in an enum or static array | |
1266 | list that start with an open brace. | |
1267 | statement -- A C (or like) statement. | |
1268 | statement-cont -- A continuation of a C (or like) statement. | |
1269 | statement-block-intro -- The first line in a new statement block. | |
1270 | statement-case-intro -- The first line in a case \"block\". | |
1271 | statement-case-open -- The first line in a case block starting with brace. | |
1272 | substatement -- The first line after an if/while/for/do/else. | |
1273 | substatement-open -- The brace that opens a substatement block. | |
a66cd3ee MS |
1274 | substatement-label -- Labelled line after an if/while/for/do/else. |
1275 | case-label -- A \"case\" or \"default\" label. | |
51f606de GM |
1276 | access-label -- C++ private/protected/public access label. |
1277 | label -- Any ordinary label. | |
a66cd3ee MS |
1278 | do-while-closure -- The \"while\" that ends a do/while construct. |
1279 | else-clause -- The \"else\" of an if/else construct. | |
1280 | catch-clause -- The \"catch\" or \"finally\" of a try/catch construct. | |
51f606de GM |
1281 | comment-intro -- A line containing only a comment introduction. |
1282 | arglist-intro -- The first line in an argument list. | |
1283 | arglist-cont -- Subsequent argument list lines when no | |
1284 | arguments follow on the same line as the | |
1285 | arglist opening paren. | |
1286 | arglist-cont-nonempty -- Subsequent argument list lines when at | |
1287 | least one argument follows on the same | |
1288 | line as the arglist opening paren. | |
1289 | arglist-close -- The solo close paren of an argument list. | |
1290 | stream-op -- Lines continuing a stream operator construct. | |
1291 | inclass -- The construct is nested inside a class definition. | |
1292 | Used together with e.g. `topmost-intro'. | |
1293 | cpp-macro -- The start of a C preprocessor macro definition. | |
a66cd3ee | 1294 | cpp-macro-cont -- Inside a multi-line C preprocessor macro definition. |
51f606de GM |
1295 | friend -- A C++ friend declaration. |
1296 | objc-method-intro -- The first line of an Objective-C method definition. | |
1297 | objc-method-args-cont -- Lines continuing an Objective-C method definition. | |
1298 | objc-method-call-cont -- Lines continuing an Objective-C method call. | |
d9e94c22 MS |
1299 | extern-lang-open -- Brace that opens an \"extern\" block. |
1300 | extern-lang-close -- Brace that closes an \"extern\" block. | |
51f606de | 1301 | inextern-lang -- Analogous to the `inclass' syntactic symbol, |
d9e94c22 MS |
1302 | but used inside \"extern\" blocks. |
1303 | namespace-open, namespace-close, innamespace | |
1304 | -- Similar to the three `extern-lang' symbols, but for | |
1305 | C++ \"namespace\" blocks. | |
1306 | module-open, module-close, inmodule | |
1307 | -- Similar to the three `extern-lang' symbols, but for | |
1308 | CORBA IDL \"module\" blocks. | |
1309 | composition-open, composition-close, incomposition | |
1310 | -- Similar to the three `extern-lang' symbols, but for | |
1311 | CORBA CIDL \"composition\" blocks. | |
51f606de GM |
1312 | template-args-cont -- C++ template argument list continuations. |
1313 | inlambda -- In the header or body of a lambda function. | |
1314 | lambda-intro-cont -- Continuation of the header of a lambda function. | |
1315 | inexpr-statement -- The statement is inside an expression. | |
1316 | inexpr-class -- The class is inside an expression. Used e.g. for | |
1317 | Java anonymous classes." | |
1318 | :type | |
1319 | `(set :format "%{%t%}: | |
1320 | Override style setting | |
1321 | | Syntax Offset | |
1322 | %v" | |
1323 | ,@(mapcar | |
1324 | (lambda (elt) | |
1325 | `(cons :format "%v" | |
1326 | :value ,elt | |
b4d0e517 | 1327 | ,(c-constant-symbol (car elt) 25) |
51f606de GM |
1328 | (sexp :format "%v" |
1329 | :validate | |
1330 | (lambda (widget) | |
1331 | (unless (c-valid-offset (widget-value widget)) | |
1332 | (widget-put widget :error "Invalid offset") | |
1333 | widget))))) | |
1334 | (get 'c-offsets-alist 'c-stylevar-fallback))) | |
785eecbb RS |
1335 | :group 'c) |
1336 | ||
037558bf MS |
1337 | ;; The syntactic symbols that can occur inside code blocks. Used by |
1338 | ;; `c-gnu-impose-minimum'. | |
1339 | (defconst c-inside-block-syms | |
1340 | '(defun-block-intro block-open block-close statement statement-cont | |
1341 | statement-block-intro statement-case-intro statement-case-open | |
1342 | substatement substatement-open substatement-label case-label label | |
1343 | do-while-closure else-clause catch-clause inlambda)) | |
1344 | ||
e96f5cb7 | 1345 | (defcustom c-style-variables-are-local-p t |
785eecbb RS |
1346 | "*Whether style variables should be buffer local by default. |
1347 | If non-nil, then all indentation style related variables will be made | |
1348 | buffer local by default. If nil, they will remain global. Variables | |
1349 | are made buffer local when this file is loaded, and once buffer | |
1350 | localized, they cannot be made global again. | |
1351 | ||
d9e94c22 MS |
1352 | This variable must be set appropriately before CC Mode is loaded. |
1353 | ||
785eecbb | 1354 | The list of variables to buffer localize are: |
785eecbb | 1355 | c-basic-offset |
785eecbb | 1356 | c-comment-only-line-offset |
d9e94c22 MS |
1357 | c-indent-comment-alist |
1358 | c-indent-comments-syntactically-p | |
51f606de GM |
1359 | c-block-comment-prefix |
1360 | c-comment-prefix-regexp | |
d9e94c22 | 1361 | c-doc-comment-style |
785eecbb RS |
1362 | c-cleanup-list |
1363 | c-hanging-braces-alist | |
1364 | c-hanging-colons-alist | |
51f606de | 1365 | c-hanging-semi&comma-criteria |
785eecbb | 1366 | c-backslash-column |
d9e94c22 | 1367 | c-backslash-max-column |
785eecbb | 1368 | c-label-minimum-indentation |
d9e94c22 | 1369 | c-offsets-alist |
785eecbb RS |
1370 | c-special-indent-hook |
1371 | c-indentation-style" | |
1372 | :type 'boolean | |
1373 | :group 'c) | |
1374 | ||
1375 | (defcustom c-mode-hook nil | |
1376 | "*Hook called by `c-mode'." | |
51f606de | 1377 | :type 'hook |
785eecbb RS |
1378 | :group 'c) |
1379 | ||
1380 | (defcustom c++-mode-hook nil | |
1381 | "*Hook called by `c++-mode'." | |
1382 | :type 'hook | |
1383 | :group 'c) | |
1384 | ||
1385 | (defcustom objc-mode-hook nil | |
1386 | "*Hook called by `objc-mode'." | |
1387 | :type 'hook | |
1388 | :group 'c) | |
1389 | ||
1390 | (defcustom java-mode-hook nil | |
1391 | "*Hook called by `java-mode'." | |
1392 | :type 'hook | |
1393 | :group 'c) | |
1394 | ||
253011b3 RS |
1395 | (defcustom idl-mode-hook nil |
1396 | "*Hook called by `idl-mode'." | |
1397 | :type 'hook | |
1398 | :group 'c) | |
1399 | ||
51f606de GM |
1400 | (defcustom pike-mode-hook nil |
1401 | "*Hook called by `pike-mode'." | |
1402 | :type 'hook | |
1403 | :group 'c) | |
1404 | ||
0386b551 AM |
1405 | (defcustom awk-mode-hook nil |
1406 | "*Hook called by `awk-mode'." | |
1407 | :type 'hook | |
1408 | :group 'c) | |
1409 | ||
785eecbb RS |
1410 | (defcustom c-mode-common-hook nil |
1411 | "*Hook called by all CC Mode modes for common initializations." | |
d9e94c22 | 1412 | :type 'hook |
785eecbb RS |
1413 | :group 'c) |
1414 | ||
253011b3 RS |
1415 | (defcustom c-initialization-hook nil |
1416 | "*Hook called when the CC Mode package gets initialized. | |
1417 | This hook is only run once per Emacs session and can be used as a | |
1418 | `load-hook' or in place of using `eval-after-load'." | |
1419 | :type 'hook | |
1420 | :group 'c) | |
1421 | ||
0ec8351b | 1422 | (defcustom c-enable-xemacs-performance-kludge-p nil |
87f235fb RS |
1423 | "*Enables a XEmacs only hack that may improve speed for some coding styles. |
1424 | For styles that hang top-level opening braces (as is common with JDK | |
1425 | Java coding styles) this can improve performance between 3 and 60 | |
1426 | times for core indentation functions (e.g. `c-parse-state'). For | |
1427 | styles that conform to the Emacs recommendation of putting these | |
0ec8351b | 1428 | braces in column zero, this can degrade performance about as much. |
a66cd3ee MS |
1429 | This variable only has effect in XEmacs." |
1430 | :type 'boolean | |
1431 | :group 'c) | |
785eecbb | 1432 | |
a66cd3ee | 1433 | (defvar c-old-style-variable-behavior nil |
51f606de GM |
1434 | "*Enables the old style variable behavior when non-nil. |
1435 | ||
1436 | Normally the values of the style variables will override the style | |
1437 | settings specified by the variables `c-default-style' and | |
a66cd3ee | 1438 | `c-style-alist'. However, in CC Mode 5.25 and earlier, it was the |
51f606de GM |
1439 | other way around, meaning that changes made to the style variables |
1440 | from e.g. Customize would not take effect unless special precautions | |
1441 | were taken. That was confusing, especially for novice users. | |
1442 | ||
1443 | It's believed that despite this change, the new behavior will still | |
1444 | produce the same results for most old CC Mode configurations, since | |
1445 | all style variables are per default set in a special non-override | |
1446 | state. Set this variable only if your configuration has stopped | |
1447 | working due to this change.") | |
1448 | ||
d9e94c22 | 1449 | (define-widget 'c-extra-types-widget 'radio |
a02a0f3d | 1450 | "Internal CC Mode widget for the `*-font-lock-extra-types' variables." |
d9e94c22 MS |
1451 | :args '((const :tag "none" nil) |
1452 | (repeat :tag "types" regexp))) | |
1453 | ||
0386b551 AM |
1454 | (defun c-make-font-lock-extra-types-blurb (mode1 mode2 example) |
1455 | (concat "\ | |
d9e94c22 MS |
1456 | *List of extra types (aside from the type keywords) to recognize in " |
1457 | mode1 " mode. | |
1458 | Each list item should be a regexp matching a single identifier. | |
1459 | " example " | |
1460 | ||
0386b551 AM |
1461 | Note that items on this list that don't include any regexp special |
1462 | characters are automatically optimized using `regexp-opt', so you | |
1463 | should not use `regexp-opt' explicitly to build regexps here. | |
1464 | ||
d9e94c22 MS |
1465 | On decoration level 3 (and higher, where applicable), a method is used |
1466 | that finds most types and declarations by syntax alone. This variable | |
1467 | is still used as a first step, but other types are recognized | |
1468 | correctly anyway in most cases. Therefore this variable should be | |
1469 | fairly restrictive and not contain patterns that are uncertain. | |
1470 | ||
1471 | Note that this variable is only consulted when the major mode is | |
1472 | initialized. If you change it later you have to reinitialize CC Mode | |
1473 | by doing \\[" mode2 "]. | |
1474 | ||
1475 | Despite the name, this variable is not only used for font locking but | |
0386b551 | 1476 | also elsewhere in CC Mode to tell types from other identifiers.")) |
d9e94c22 MS |
1477 | |
1478 | ;; Note: Most of the variables below are also defined in font-lock.el | |
0386b551 | 1479 | ;; in older versions of Emacs, so depending on the load order we might |
d9e94c22 MS |
1480 | ;; not install the values below. There's no kludge to cope with this |
1481 | ;; (as opposed to the *-font-lock-keywords-* variables) since the old | |
a02a0f3d | 1482 | ;; values work fairly well anyway. |
d9e94c22 MS |
1483 | |
1484 | (defcustom c-font-lock-extra-types | |
0386b551 AM |
1485 | '("\\sw+_t" |
1486 | ;; Defined in C99: | |
1487 | "bool" "complex" "imaginary" | |
1488 | ;; Standard library types (except those matched by the _t pattern): | |
1489 | "FILE" "lconv" "tm" "va_list" "jmp_buf" | |
d9e94c22 MS |
1490 | ;; I do not appreciate the following very Emacs-specific luggage |
1491 | ;; in the default value, but otoh it can hardly get in the way for | |
1492 | ;; other users, and removing it would cause unnecessary grief for | |
1493 | ;; the old timers that are used to it. /mast | |
1494 | "Lisp_Object") | |
1495 | (c-make-font-lock-extra-types-blurb "C" "c-mode" | |
0386b551 AM |
1496 | "For example, a value of (\"FILE\" \"\\\\sw+_t\") means the word \"FILE\" |
1497 | and words ending in \"_t\" are treated as type names.") | |
d9e94c22 MS |
1498 | :type 'c-extra-types-widget |
1499 | :group 'c) | |
1500 | ||
1501 | (defcustom c++-font-lock-extra-types | |
1502 | '("\\sw+_t" | |
0386b551 AM |
1503 | ;; C library types (except those matched by the _t pattern): |
1504 | "FILE" "lconv" "tm" "va_list" "jmp_buf" | |
1505 | ;; Some standard C++ types that came from font-lock.el. | |
1506 | ;; Experienced C++ users says there's no clear benefit in | |
1507 | ;; extending this to all the types in the standard library, at | |
1508 | ;; least not when they'll be recognized without "std::" too. | |
1509 | "istream" "istreambuf" | |
1510 | "ostream" "ostreambuf" | |
1511 | "ifstream" "ofstream" "fstream" | |
1512 | "strstream" "strstreambuf" "istrstream" "ostrstream" | |
1513 | "ios" | |
d9e94c22 MS |
1514 | "string" "rope" |
1515 | "list" "slist" | |
1516 | "deque" "vector" "bit_vector" | |
1517 | "set" "multiset" | |
1518 | "map" "multimap" | |
0386b551 AM |
1519 | "hash" |
1520 | "hash_set" "hash_multiset" | |
1521 | "hash_map" "hash_multimap" | |
d9e94c22 MS |
1522 | "stack" "queue" "priority_queue" |
1523 | "type_info" | |
1524 | "iterator" "const_iterator" "reverse_iterator" "const_reverse_iterator" | |
1525 | "reference" "const_reference") | |
1526 | (c-make-font-lock-extra-types-blurb "C++" "c++-mode" | |
0386b551 | 1527 | "For example, a value of (\"string\") means the word \"string\" is treated |
d9e94c22 MS |
1528 | as a type name.") |
1529 | :type 'c-extra-types-widget | |
1530 | :group 'c) | |
1531 | ||
1532 | (defcustom objc-font-lock-extra-types | |
1533 | (list (concat "[" c-upper "]\\sw*[" c-lower "]\\sw*")) | |
1534 | (c-make-font-lock-extra-types-blurb "ObjC" "objc-mode" (concat | |
1535 | "For example, a value of (\"[" c-upper "]\\\\sw*[" c-lower "]\\\\sw*\") means | |
1536 | capitalized words are treated as type names (the requirement for a | |
1537 | lower case char is to avoid recognizing all-caps macro and constant | |
1538 | names).")) | |
1539 | :type 'c-extra-types-widget | |
1540 | :group 'c) | |
1541 | ||
1542 | (defcustom java-font-lock-extra-types | |
1543 | (list (concat "[" c-upper "]\\sw*[" c-lower "]\\sw*")) | |
1544 | (c-make-font-lock-extra-types-blurb "Java" "java-mode" (concat | |
1545 | "For example, a value of (\"[" c-upper "]\\\\sw*[" c-lower "]\\\\sw*\") means | |
1546 | capitalized words are treated as type names (the requirement for a | |
1547 | lower case char is to avoid recognizing all-caps constant names).")) | |
1548 | :type 'c-extra-types-widget | |
1549 | :group 'c) | |
1550 | ||
1551 | (defcustom idl-font-lock-extra-types nil | |
1552 | (c-make-font-lock-extra-types-blurb "IDL" "idl-mode" "") | |
1553 | :type 'c-extra-types-widget | |
1554 | :group 'c) | |
1555 | ||
1556 | (defcustom pike-font-lock-extra-types | |
1557 | (list (concat "[" c-upper "]\\sw*[" c-lower "]\\sw*")) | |
1558 | (c-make-font-lock-extra-types-blurb "Pike" "pike-mode" (concat | |
1559 | "For example, a value of (\"[" c-upper "]\\\\sw*[" c-lower "]\\\\sw*\") means | |
1560 | capitalized words are treated as type names (the requirement for a | |
1561 | lower case char is to avoid recognizing all-caps macro and constant | |
1562 | names).")) | |
1563 | :type 'c-extra-types-widget | |
1564 | :group 'c) | |
51f606de | 1565 | |
785eecbb RS |
1566 | \f |
1567 | ;; Non-customizable variables, still part of the interface to CC Mode | |
1568 | (defvar c-file-style nil | |
1569 | "Variable interface for setting style via File Local Variables. | |
1570 | In a file's Local Variable section, you can set this variable to a | |
1571 | string suitable for `c-set-style'. When the file is visited, CC Mode | |
1572 | will set the style of the file to this value automatically. | |
1573 | ||
1574 | Note that file style settings are applied before file offset settings | |
1575 | as designated in the variable `c-file-offsets'.") | |
51f606de | 1576 | (make-variable-buffer-local 'c-file-style) |
631c8020 | 1577 | ;;;###autoload(put 'c-file-style 'safe-local-variable 'string-or-null-p) |
785eecbb RS |
1578 | |
1579 | (defvar c-file-offsets nil | |
1580 | "Variable interface for setting offsets via File Local Variables. | |
1581 | In a file's Local Variable section, you can set this variable to an | |
1582 | association list similar to the values allowed in `c-offsets-alist'. | |
1583 | When the file is visited, CC Mode will institute these offset settings | |
1584 | automatically. | |
1585 | ||
1586 | Note that file offset settings are applied after file style settings | |
1587 | as designated in the variable `c-file-style'.") | |
51f606de | 1588 | (make-variable-buffer-local 'c-file-offsets) |
785eecbb | 1589 | |
0386b551 AM |
1590 | ;; It isn't possible to specify a doc-string without specifying an |
1591 | ;; initial value with `defvar', so the following two variables have been | |
1592 | ;; given doc-strings by setting the property `variable-documentation' | |
1593 | ;; directly. C-h v will read this documentation only for versions of GNU | |
1594 | ;; Emacs from 22.1. It's really good not to have an initial value for | |
1595 | ;; variables like these that always should be dynamically bound, so it's | |
1596 | ;; worth the inconvenience. | |
d9e94c22 MS |
1597 | |
1598 | (cc-bytecomp-defvar c-syntactic-context) | |
1599 | (defvar c-syntactic-context) | |
0386b551 AM |
1600 | (put 'c-syntactic-context 'variable-documentation |
1601 | "Variable containing the syntactic analysis list for a line of code. | |
1602 | ||
1603 | It is a list with one element for each syntactic symbol pertinent to the | |
1604 | line, for example \"((defun-block-intro 1) (comment-intro))\". | |
1605 | ||
1606 | It is dynamically bound when calling \(i) a brace hanging \"action | |
1607 | function\"; \(ii) a semicolon/comma hanging \"criteria function\"; \(iii) a | |
1608 | \"line-up function\"; \(iv) a c-special-indent-hook function. It is also | |
1609 | used internally by CC Mode. | |
1610 | ||
1611 | c-syntactic-context is always bound dynamically. It must NEVER be set | |
1612 | statically (e.g. with `setq').") | |
1613 | ||
d9e94c22 MS |
1614 | |
1615 | (cc-bytecomp-defvar c-syntactic-element) | |
1616 | (defvar c-syntactic-element) | |
0386b551 AM |
1617 | (put 'c-syntactic-element 'variable-documentation |
1618 | "Variable containing the current syntactic element during calls to | |
1619 | the lineup functions. The value is one of the elements in the list in | |
1620 | `c-syntactic-context' and is a list with the symbol name in the first | |
1621 | position, followed by zero or more elements containing any additional | |
1622 | info associated with the syntactic symbol. There are accessor functions | |
1623 | `c-langelem-sym', `c-langelem-pos', `c-langelem-col', and | |
1624 | `c-langelem-2nd-pos' to access the list. | |
1625 | ||
1626 | Specifically, the element returned by `c-langelem-pos' is the anchor | |
1627 | position, or nil if there isn't any. See the comments in the | |
1628 | `c-offsets-alist' variable and the CC Mode manual for more detailed info | |
1629 | about the data each syntactic symbol provides. | |
1630 | ||
1631 | This is always bound dynamically. It should never be set | |
1632 | statically (e.g. with `setq').") | |
785eecbb | 1633 | |
51f606de | 1634 | (defvar c-indentation-style nil |
130c507e | 1635 | "Name of the currently installed style. |
51c9af45 AM |
1636 | Don't change this directly; call `c-set-style' instead, or set the variable |
1637 | `c-file-style' in the file's Local Variable list.") | |
785eecbb | 1638 | |
130c507e GM |
1639 | (defvar c-current-comment-prefix nil |
1640 | "The current comment prefix regexp. | |
1641 | Set from `c-comment-prefix-regexp' at mode initialization.") | |
1642 | (make-variable-buffer-local 'c-current-comment-prefix) | |
d278ad4f | 1643 | |
0386b551 AM |
1644 | ;; N.B. The next three variables are initialized in |
1645 | ;; c-setup-paragraph-variables. Their initializations here are "just in | |
1646 | ;; case". ACM, 2004/2/15. They are NOT buffer local (yet?). | |
1647 | (defvar c-string-par-start | |
1648 | ;; (concat "\\(" (default-value 'paragraph-start) "\\)\\|[ \t]*\\\\$") | |
1649 | "\f\\|[ \t]*\\\\?$" | |
1650 | "Value of paragraph-start used when scanning strings. | |
1651 | It treats escaped EOLs as whitespace.") | |
1652 | ||
1653 | (defvar c-string-par-separate | |
1654 | ;; (concat "\\(" (default-value 'paragraph-separate) "\\)\\|[ \t]*\\\\$") | |
1655 | "[ \t\f]*\\\\?$" | |
1656 | "Value of paragraph-separate used when scanning strings. | |
1657 | It treats escaped EOLs as whitespace.") | |
1658 | ||
1659 | (defvar c-sentence-end-with-esc-eol | |
1660 | (concat "\\(\\(" (c-default-value-sentence-end) "\\)" | |
1661 | ;; N.B.: "$" would be illegal when not enclosed like "\\($\\)". | |
1662 | "\\|" "[.?!][]\"')}]* ?\\\\\\($\\)[ \t\n]*" | |
1663 | "\\)") | |
1664 | "Value used like sentence-end used when scanning strings. | |
1665 | It treats escaped EOLs as whitespace.") | |
1666 | ||
785eecbb | 1667 | \f |
130c507e | 1668 | (cc-provide 'cc-vars) |
3afbc435 | 1669 | |
cbee283d | 1670 | ;; arch-tag: d62e9a55-c9fe-409b-b5b6-050b6aa202c9 |
785eecbb | 1671 | ;;; cc-vars.el ends here |