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