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