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