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