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