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