* speedbar.el (speedbar-ignored-path-regexp, speedbar-line-path)
[emacs.git] / lisp / progmodes / cc-vars.el
blobb6a3c40495737ebc79105bc39f3a6906eabea816
1 ;;; cc-vars.el --- user customization variables for CC Mode
3 ;; Copyright (C) 1985,1987,1992-2003, 2004, 2005 Free Software Foundation, Inc.
5 ;; Authors: 1998- Martin Stjernholm
6 ;; 1992-1999 Barry A. Warsaw
7 ;; 1987 Dave Detlefs and Stewart Clamen
8 ;; 1985 Richard M. Stallman
9 ;; Maintainer: bug-cc-mode@gnu.org
10 ;; Created: 22-Apr-1997 (split from cc-mode.el)
11 ;; Version: See cc-mode.el
12 ;; Keywords: c languages oop
14 ;; This file is part of GNU Emacs.
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.
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.
26 ;; You should have received a copy of the GNU General Public License
27 ;; along with GNU Emacs; see the file COPYING. If not, write to
28 ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
29 ;; Boston, MA 02110-1301, USA.
31 ;;; Commentary:
33 ;;; Code:
35 (eval-when-compile
36 (let ((load-path
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)
40 load-path)))
41 (load "cc-bytecomp" nil t)))
43 (cc-require 'cc-defs)
45 ;; Silence the compiler.
46 (cc-bytecomp-defun get-char-table) ; XEmacs 20+
47 (cc-bytecomp-defun char-table-range) ; Emacs 19+
48 (cc-bytecomp-defun char-table-p) ; Emacs 19+, XEmacs 20+
50 ;; Pull in custom if it exists and is recent enough (the one in Emacs
51 ;; 19.34 isn't).
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 \
64 since 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))))
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)))))
84 ;;; Helpers
86 ;; This widget exists in newer versions of the Custom library
87 (or (get 'other 'widget-type)
88 (define-widget 'other 'sexp
89 "Matches everything, but doesn't let the user edit the value.
90 Useful as last item in a `choice' widget."
91 :tag "Other"
92 :format "%t%n"
93 :value 'other))
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)) ?\ ))))
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)))
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))))
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)
141 ((symbolp value)
142 (symbol-name value))
143 ((consp value)
144 (mapconcat (lambda (symbol)
145 (symbol-name symbol))
146 value
147 " "))
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)))
162 (defvar c-style-variables
163 '(c-basic-offset c-comment-only-line-offset c-indent-comment-alist
164 c-indent-comments-syntactically-p c-block-comment-prefix
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)
169 "List of the style variables.")
171 (defvar c-fallback-style nil)
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)))
177 (defmacro defcustom-c-stylevar (name val doc &rest args)
178 "Defines a style variable."
179 `(let ((-value- ,val))
180 (c-set-stylevar-fallback ',name -value-)
181 (custom-declare-variable
182 ',name ''set-from-style
183 ,(concat doc "
185 This is a style variable. Apart from the valid values described
186 above, it can be set to the symbol `set-from-style'. In that case, it
187 takes its value from the style system (see `c-default-style' and
188 `c-style-alist') when a CC Mode buffer is initialized. Otherwise,
189 the value set here overrides the style system (there is a variable
190 `c-old-style-variable-behavior' that changes this, though).")
191 ,@(plist-put
192 args ':type
193 `(` (radio
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)))))))))
207 (defun c-valid-offset (offset)
208 "Return non-nil iff OFFSET is a valid offset for a syntactic symbol.
209 See `c-offsets-alist'."
210 ;; This function does not do any hidden buffer changes.
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)))
222 (and (vectorp offset)
223 (= (length offset) 1)
224 (integerp (elt offset 0)))
225 (progn
226 (while (and (consp offset)
227 (c-valid-offset (car offset)))
228 (setq offset (cdr offset)))
229 (null offset))))
233 ;;; User variables
235 (defcustom c-strict-syntax-p nil
236 "*If non-nil, all syntactic symbols must be found in `c-offsets-alist'.
237 If the syntactic symbol for a particular line does not match a symbol
238 in the offsets alist, or if no non-nil offset value can be determined
239 for a symbol, an error is generated, otherwise no error is reported
240 and the syntactic symbol is ignored.
242 This variable is considered obsolete; it doesn't work well with lineup
243 functions that return nil to support the feature of using lists on
244 syntactic symbols in `c-offsets-alist'. Please keep it set to nil."
245 :type 'boolean
246 :group 'c)
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)
253 (defcustom c-report-syntactic-errors nil
254 "*If non-nil, certain syntactic errors are reported with a ding
255 and a message, for example when an \"else\" is indented for which
256 there's no corresponding \"if\".
258 Note however that CC Mode doesn't make any special effort to check for
259 syntactic errors; that's the job of the compiler. The reason it can
260 report cases like the one above is that it can't find the correct
261 anchoring position to indent the line in that case."
262 :type 'boolean
263 :group 'c)
265 (defcustom-c-stylevar c-basic-offset 4
266 "*Amount of basic offset used by + and - symbols in `c-offsets-alist'.
267 Also used as the indentation step when `c-syntactic-indentation' is
268 nil."
269 :type 'integer
270 :group 'c)
272 (defcustom c-tab-always-indent t
273 "*Controls the operation of the TAB key.
274 If t, hitting TAB always just indents the current line. If nil, hitting
275 TAB indents the current line if point is at the left margin or in the
276 line's indentation, otherwise it inserts a `real' tab character \(see
277 note\). If some other value (not nil or t), then tab is inserted only
278 within literals \(comments and strings), but the line is always
279 reindented.
281 Note: The value of `indent-tabs-mode' will determine whether a real
282 tab character will be inserted, or the equivalent number of spaces.
283 When inserting a tab, actually the function stored in the variable
284 `c-insert-tab-function' is called.
286 Note: indentation of lines containing only comments is also controlled
287 by the `c-comment-only-line-offset' variable."
288 :type '(radio
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))
292 :group 'c)
294 (defcustom c-insert-tab-function 'insert-tab
295 "*Function used when inserting a tab for \\[c-indent-command].
296 Only used when `c-tab-always-indent' indicates a `real' tab character
297 should be inserted. Value must be a function taking no arguments."
298 :type 'function
299 :group 'c)
301 (defcustom c-syntactic-indentation t
302 "*Whether the indentation should be controlled by the syntactic context.
304 If t, the indentation functions indent according to the syntactic
305 context, using the style settings specified by `c-offsets-alist'.
307 If nil, every line is just indented to the same level as the previous
308 one, and the \\[c-indent-command] command adjusts the indentation in
309 steps specified by `c-basic-offset'. The indentation style has no
310 effect in this mode, nor any of the indentation associated variables,
311 e.g. `c-special-indent-hook'."
312 :type 'boolean
313 :group 'c)
315 (defcustom c-syntactic-indentation-in-macros t
316 "*Enable syntactic analysis inside macros.
317 If this is nil, all lines inside macro definitions are analyzed as
318 `cpp-macro-cont'. Otherwise they are analyzed syntactically, just
319 like normal code, and `cpp-define-intro' is used to create the
320 additional indentation of the bodies of \"#define\" macros.
322 Having this enabled simplifies editing of large multiline macros, but
323 it might complicate editing if CC Mode doesn't recognize the context
324 of the macro content. The default context inside the macro is the
325 same as the top level, so if it contains \"bare\" statements they
326 might be indented wrongly, although there are special cases that
327 handle this in most cases. If this problem occurs, it's usually
328 countered easily by surrounding the statements by a block \(or even
329 better with the \"do { ... } while \(0)\" trick)."
330 :type 'boolean
331 :group 'c)
333 (defcustom-c-stylevar c-comment-only-line-offset 0
334 "*Extra offset for line which contains only the start of a comment.
335 Can contain an integer or a cons cell of the form:
337 (NON-ANCHORED-OFFSET . ANCHORED-OFFSET)
339 Where NON-ANCHORED-OFFSET is the amount of offset given to
340 non-column-zero anchored comment-only lines, and ANCHORED-OFFSET is
341 the amount of offset to give column-zero anchored comment-only lines.
342 Just an integer as value is equivalent to (<val> . -1000).
344 Note that this variable only has effect when the `c-lineup-comment'
345 lineup function is used on the `comment-intro' syntactic symbol (the
346 default)."
347 :type '(choice (integer :tag "Non-anchored offset" 0)
348 (cons :tag "Non-anchored & anchored offset"
349 :value (0 . 0)
350 (integer :tag "Non-anchored offset")
351 (integer :tag "Anchored offset")))
352 :group 'c)
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.
359 This is an association list that contains entries of the form:
361 (LINE-TYPE . INDENT-SPEC)
363 LINE-TYPE specifies a type of line as described below, and INDENT-SPEC
364 says what \\[indent-for-comment] should do when used on that type of line.
366 The recognized values for LINE-TYPE are:
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.
376 An INDENT-SPEC is a cons cell of the form:
378 (ACTION . VALUE)
380 ACTION says how \\[indent-for-comment] should align the comment, and
381 VALUE is interpreted depending on ACTION. ACTION can be any of the
382 following:
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.
395 If a LINE-TYPE is missing, then \\[indent-for-comment] indents the comment
396 according to `comment-column'.
398 Note that a non-nil value on `c-indent-comments-syntactically-p'
399 overrides this variable, so empty lines are indentented syntactically
400 in 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)
433 (defcustom-c-stylevar c-indent-comments-syntactically-p nil
434 "*Specifies how \\[indent-for-comment] should handle comment-only lines.
435 When this variable is non-nil, comment-only lines are indented
436 according to syntactic analysis via `c-offsets-alist'. Otherwise, the
437 comment is indented as if it was preceded by code. Note that this
438 variable does not affect how the normal line indentation treats
439 comment-only lines."
440 :type 'boolean
441 :group 'c)
443 (make-obsolete-variable 'c-comment-continuation-stars
444 'c-block-comment-prefix)
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)
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.
457 You should set this variable to the literal string that gets inserted
458 at the front of continued block style comment lines. This should
459 either be the empty string, or some characters without preceding
460 spaces. To adjust the alignment under the comment starter, put an
461 appropriate value on the `c' syntactic symbol (see the
462 `c-offsets-alist' variable).
464 It's only used when a one-line block comment is broken into two or
465 more lines for the first time; otherwise the appropriate prefix is
466 adapted from the comment. This variable is not used for C++ line
467 style comments."
468 :type 'string
469 :group 'c)
471 (defcustom-c-stylevar c-comment-prefix-regexp
472 '((pike-mode . "//+!?\\|\\**")
473 (other . "//+\\|\\**"))
474 "*Regexp to match the line prefix inside comments.
475 This regexp is used to recognize the fill prefix inside comments for
476 correct paragraph filling and other things.
478 If this variable is a string, it will be used in all CC Mode major
479 modes. It can also be an association list, to associate specific
480 regexps to specific major modes. The symbol for the major mode is
481 looked up in the association list, and its value is used as the line
482 prefix regexp. If it's not found, then the symbol `other' is looked
483 up and its value is used instead.
485 The regexp should match the prefix used in both C++ style line
486 comments and C style block comments, but it does not need to match a
487 block comment starter. In other words, it should at least match
488 \"//\" for line comments and the string in `c-block-comment-prefix',
489 which is sometimes inserted by CC Mode inside block comments. It
490 should not match any surrounding whitespace.
492 Note that CC Mode uses this variable to set many other variables that
493 handle the paragraph filling. That's done at mode initialization or
494 when you switch to a style which sets this variable. Thus, if you
495 change it in some other way, e.g. interactively in a CC Mode buffer,
496 you will need to do \\[c-setup-paragraph-variables] afterwards so that
497 the other variables are updated with the new value.
499 Note also that when CC Mode starts up, all variables are initialized
500 before the mode hooks are run. It's therefore necessary to make a
501 call to `c-setup-paragraph-variables' explicitly if you change this
502 variable in a mode hook."
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"))))
523 :group 'c)
525 (defcustom-c-stylevar c-doc-comment-style
526 '((java-mode . javadoc)
527 (pike-mode . autodoc))
528 "*Specifies documentation comment style(s) to recognize.
529 This is primarily used to fontify doc comments and the markup within
530 them, e.g. Javadoc comments.
532 The value can be any of the following symbols for various known doc
533 comment styles:
535 javadoc -- Javadoc style for \"/** ... */\" comments (default in Java mode).
536 autodoc -- Pike autodoc style for \"//! ...\" comments (default in Pike mode).
538 The value may also be a list of doc comment styles, in which case all
539 of them are recognized simultaneously (presumably with markup cues
540 that don't conflict).
542 The value may also be an association list to specify different doc
543 comment styles for different languages. The symbol for the major mode
544 is then looked up in the alist, and the value of that element is
545 interpreted as above if found. If it isn't found then the symbol
546 `other' is looked up and its value is used instead.
548 Note that CC Mode uses this variable to set other variables that
549 handle fontification etc. That's done at mode initialization or when
550 you switch to a style which sets this variable. Thus, if you change
551 it in some other way, e.g. interactively in a CC Mode buffer, you will
552 need to do \\[java-mode] (or whatever mode you're currently using) to
553 reinitialize.
555 Note also that when CC Mode starts up, the other variables are
556 modified before the mode hooks are run. If you change this variable
557 in a mode hook, you have to call `c-setup-doc-comment-style'
558 afterwards 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)
593 (defcustom c-ignore-auto-fill '(string cpp code)
594 "*List of contexts in which automatic filling never occurs.
595 If Auto Fill mode is active, it will be temporarily disabled if point
596 is in any context on this list. It's e.g. useful to enable Auto Fill
597 in comments only, but not in strings or normal code. The valid
598 contexts are:
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
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)
613 (defcustom-c-stylevar c-cleanup-list '(scope-operator)
614 "*List of various C/C++/ObjC constructs to \"clean up\".
615 The following clean ups only take place when the auto-newline feature
616 is turned on, as evidenced by the `/a' or `/ah' appearing next to the
617 mode name:
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
622 white space between the braces and the `else'.
623 Clean up occurs when the open brace after the
624 `else' is typed.
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
632 braces on the same line. Clean up occurs when
633 the defun closing brace is typed.
634 defun-close-semi -- Clean up the terminating semi-colon on defuns
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.
638 list-close-comma -- Clean up commas following braces in array
639 and aggregate initializers. Clean up occurs
640 when the comma is typed.
641 scope-operator -- Clean up double colons which may designate
642 a C++ scope operator split across multiple
643 lines. Note that certain C++ constructs can
644 generate ambiguous situations. This clean up
645 only takes place when there is nothing but
646 whitespace between colons. Clean up occurs
647 when the second colon is typed.
649 The following clean ups always take place when they are on this list,
650 regardless of the auto-newline feature, since they typically don't
651 involve auto-newline inserted newlines:
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."
663 :type '(set
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))
682 :group 'c)
684 (defcustom-c-stylevar c-hanging-braces-alist '((brace-list-open)
685 (brace-entry-open)
686 (statement-cont)
687 (substatement-open after)
688 (block-close . c-snug-do-while)
689 (extern-lang-open after)
690 (namespace-open after)
691 (module-open after)
692 (composition-open after)
693 (inexpr-class-open after)
694 (inexpr-class-close before))
695 "*Controls the insertion of newlines before and after braces
696 when the auto-newline feature is active. This variable contains an
697 association list with elements of the following form:
698 \(SYNTACTIC-SYMBOL . ACTION).
700 When a brace (either opening or closing) is inserted, the syntactic
701 context it defines is looked up in this list, and if found, the
702 associated ACTION is used to determine where newlines are inserted.
703 If the context is not found, the default is to insert a newline both
704 before and after the brace.
706 SYNTACTIC-SYMBOL can be statement-cont, brace-list-intro,
707 inexpr-class-open, inexpr-class-close, and any of the *-open and
708 *-close symbols. See `c-offsets-alist' for details, except for
709 inexpr-class-open and inexpr-class-close, which doesn't have any
710 corresponding symbols there. Those two symbols are used for the
711 opening and closing braces, respectively, of anonymous inner classes
712 in Java.
714 ACTION can be either a function symbol or a list containing any
715 combination of the symbols `before' or `after'. If the list is empty,
716 no newlines are inserted either before or after the brace.
718 When ACTION is a function symbol, the function is called with a two
719 arguments: the syntactic symbol for the brace and the buffer position
720 at which the brace was inserted. The function must return a list as
721 described in the preceding paragraph. Note that during the call to
722 the function, the variable `c-syntactic-context' is set to the entire
723 syntactic context for the brace line."
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"
732 :value (before after)
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
744 statement-cont substatement-open statement-case-open
745 brace-list-open brace-list-close
746 brace-list-intro brace-entry-open
747 extern-lang-open extern-lang-close
748 namespace-open namespace-close
749 module-open module-close
750 composition-open composition-close
751 inexpr-class-open inexpr-class-close)))
752 :group 'c)
754 (defcustom-c-stylevar c-hanging-colons-alist nil
755 "*Controls the insertion of newlines before and after certain colons.
756 This variable contains an association list with elements of the
757 following form: (SYNTACTIC-SYMBOL . ACTION).
759 SYNTACTIC-SYMBOL can be any of: case-label, label, access-label,
760 member-init-intro, or inher-intro.
762 See the variable `c-hanging-braces-alist' for the semantics of this
763 variable. Note however that making ACTION a function symbol is
764 currently not supported for this variable."
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)))
776 :group 'c)
778 (defcustom-c-stylevar c-hanging-semi&comma-criteria
779 '(c-semi&comma-inside-parenlist)
780 "*List of functions that decide whether to insert a newline or not.
781 The functions in this list are called, in order, whenever the
782 auto-newline minor mode is activated (as evidenced by a `/a' or `/ah'
783 string 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
785 no arguments, and should return one of the following values:
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
791 If every function in the list is called with no determination made,
792 then no newline is inserted."
793 :type '(repeat function)
794 :group 'c)
796 (defcustom-c-stylevar c-backslash-column 48
797 "*Minimum alignment column for line continuation backslashes.
798 This is used by the functions that automatically insert or align the
799 line continuation backslashes in multiline macros. If any line in the
800 macro exceeds this column then the next tab stop from that line is
801 used as alignment column instead."
802 :type 'integer
803 :group 'c)
805 (defcustom-c-stylevar c-backslash-max-column 72
806 "*Maximum alignment column for line continuation backslashes.
807 This is used by the functions that automatically insert or align the
808 line continuation backslashes in multiline macros. If any line in the
809 macro exceeds this column then the backslashes for the other lines
810 will be aligned at this column."
811 :type 'integer
812 :group 'c)
814 (defcustom c-auto-align-backslashes t
815 "*Align automatically inserted line continuation backslashes.
816 When line continuation backslashes are inserted automatically for line
817 breaks in multiline macros, e.g. by \\[c-context-line-break], they are
818 aligned with the other backslashes in the same macro if this flag is
819 set. Otherwise the inserted backslashes are preceded by a single
820 space."
821 :type 'boolean
822 :group 'c)
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)
829 (defcustom c-delete-function 'delete-char
830 "*Function called by `c-electric-delete-forward' when deleting forwards."
831 :type 'function
832 :group 'c)
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 `require-final-newline' in C-related major modes.
843 The value is an association list specifying, for each specific mode,
844 whether to override `require-final-newline'. If the cdr of the element
845 is non-nil, that means to use `mode-require-final-newline' instead."
846 :type `(set (cons :format "%v"
847 (const :format "C " c-mode)
848 (const t))
849 (cons :format "%v"
850 (const :format "C++ " c++-mode)
851 (const t))
852 (cons :format "%v"
853 (const :format "ObjC " objc-mode)
854 (const t))
855 (cons :format "%v"
856 (const :format "Java " java-mode)
857 (const t))
858 (cons :format "%v"
859 (const :format "IDL " idl-mode)
860 (const t))
861 (cons :format "%v"
862 (const :format "Pike " pike-mode)
863 (const t)))
864 :group 'c)
866 (defcustom c-electric-pound-behavior nil
867 "*List of behaviors for electric pound insertion.
868 Only currently supported behavior is `alignleft'."
869 :type '(set (const alignleft))
870 :group 'c)
872 (defcustom c-special-indent-hook nil
873 "*Hook for user defined special indentation adjustments.
874 This hook gets called after a line is indented by the mode."
875 :type 'hook
876 :group 'c)
878 (defcustom-c-stylevar c-label-minimum-indentation 1
879 "*Minimum indentation for lines inside code blocks.
880 This variable typically only affects code using the `gnu' style, which
881 mandates a minimum of one space in front of every line inside code
882 blocks. Specifically, the function `c-gnu-impose-minimum' on your
883 `c-special-indent-hook' is what enforces this."
884 :type 'integer
885 :group 'c)
887 (defcustom c-progress-interval 5
888 "*Interval used to update progress status during long re-indentation.
889 If a number, percentage complete gets updated after each interval of
890 that many seconds. To inhibit all messages during indentation, set
891 this variable to nil."
892 :type 'integer
893 :group 'c)
895 (defcustom c-default-style '((java-mode . "java") (other . "gnu"))
896 "*Style which gets installed by default when a file is visited.
898 The value of this variable can be any style defined in
899 `c-style-alist', including styles you add. The value can also be an
900 association list of major mode symbols to style names.
902 When the value is a string, all CC Mode major modes will install this
903 style by default.
905 When the value is an alist, the major mode symbol is looked up in it
906 and the associated style is installed. If the major mode is not
907 listed in the alist, then the symbol `other' is looked up in it, and
908 if found, the style in that entry is used. If `other' is not found in
909 the alist, then \"gnu\" style is used.
911 The default style gets installed before your mode hooks run, so you
912 can always override the use of `c-default-style' by making calls to
913 `c-set-style' in the appropriate mode hook."
914 :type '(radio
915 (string :tag "Style in all modes")
916 (set :tag "Mode-specific styles"
917 (cons :format "%v"
918 (const :format "C " c-mode) (string :format "%v"))
919 (cons :format "%v"
920 (const :format "C++ " c++-mode) (string :format "%v"))
921 (cons :format "%v"
922 (const :format "ObjC " objc-mode) (string :format "%v"))
923 (cons :format "%v"
924 (const :format "Java " java-mode) (string :format "%v"))
925 (cons :format "%v"
926 (const :format "IDL " idl-mode) (string :format "%v"))
927 (cons :format "%v"
928 (const :format "Pike " pike-mode) (string :format "%v"))
929 (cons :format "%v"
930 (const :format "Other " other) (string :format "%v"))))
931 :group 'c)
933 ;; *) At the start of a statement or declaration means in more detail:
934 ;; At the closest preceding statement/declaration that starts at boi
935 ;; and doesn't have a label or comment at that position. If there's
936 ;; no such statement within the same block, then back up to the
937 ;; surrounding block or statement, add the appropriate
938 ;; statement-block-intro, defun-block-intro or substatement syntax
939 ;; symbol and continue searching.
940 (c-set-stylevar-fallback 'c-offsets-alist
941 '((string . c-lineup-dont-change)
942 ;; Relpos: Beg of previous line.
943 (c . c-lineup-C-comments)
944 ;; Relpos: Beg of the comment.
945 (defun-open . 0)
946 ;; Relpos: When inside a class: Boi at the func decl start.
947 ;; When at top level: Bol at the func decl start. When inside
948 ;; a code block (only possible in Pike): At the func decl
949 ;; start(*).
950 (defun-close . 0)
951 ;; Relpos: At the defun block open if it's at boi, otherwise
952 ;; boi at the func decl start.
953 (defun-block-intro . +)
954 ;; Relpos: At the block open(*).
955 (class-open . 0)
956 ;; Relpos: Boi at the class decl start.
957 (class-close . 0)
958 ;; Relpos: Boi at the class decl start.
959 (inline-open . +)
960 ;; Relpos: None for functions (inclass got the relpos then),
961 ;; boi at the lambda start for lambdas.
962 (inline-close . 0)
963 ;; Relpos: Inexpr functions: At the lambda block open if it's
964 ;; at boi, else at the statement(*) at boi of the start of the
965 ;; lambda construct. Otherwise: At the inline block open if
966 ;; it's at boi, otherwise boi at the func decl start.
967 (func-decl-cont . +)
968 ;; Relpos: Boi at the func decl start.
969 (knr-argdecl-intro . +)
970 ;; Relpos: Boi at the topmost intro line.
971 (knr-argdecl . 0)
972 ;; Relpos: At the beginning of the first K&R argdecl.
973 (topmost-intro . 0)
974 ;; Relpos: Bol at the last line of previous construct.
975 (topmost-intro-cont . c-lineup-topmost-intro-cont)
976 ;; Relpos: Boi at the topmost intro line.
977 (member-init-intro . +)
978 ;; Relpos: Boi at the func decl arglist open.
979 (member-init-cont . c-lineup-multi-inher)
980 ;; Relpos: Beg of the first member init.
981 (inher-intro . +)
982 ;; Relpos: Boi at the class decl start.
983 (inher-cont . c-lineup-multi-inher)
984 ;; Relpos: Java: At the implements/extends keyword start.
985 ;; Otherwise: At the inher start colon, or boi at the class
986 ;; decl start if the first inherit clause hangs and it's not a
987 ;; func-local inherit clause (when does that occur?).
988 (block-open . 0)
989 ;; Relpos: Inexpr statement: At the statement(*) at boi of the
990 ;; start of the inexpr construct. Otherwise: None.
991 (block-close . 0)
992 ;; Relpos: Inexpr statement: At the inexpr block open if it's
993 ;; at boi, else at the statement(*) at boi of the start of the
994 ;; inexpr construct. Block hanging on a case/default label: At
995 ;; the closest preceding label that starts at boi. Otherwise:
996 ;; At the block open(*).
997 (brace-list-open . 0)
998 ;; Relpos: Boi at the brace list decl start, but a starting
999 ;; "typedef" token is ignored.
1000 (brace-list-close . 0)
1001 ;; Relpos: At the brace list decl start(*).
1002 (brace-list-intro . +)
1003 ;; Relpos: At the brace list decl start(*).
1004 (brace-list-entry . 0)
1005 ;; Relpos: At the first non-ws char after the open paren if the
1006 ;; first token is on the same line, otherwise boi at that
1007 ;; token.
1008 (brace-entry-open . 0)
1009 ;; Relpos: Same as brace-list-entry.
1010 (statement . 0)
1011 ;; Relpos: After a `;' in the condition clause of a for
1012 ;; statement: At the first token after the starting paren.
1013 ;; Otherwise: At the preceding statement(*).
1014 (statement-cont . +)
1015 ;; Relpos: After the first token in the condition clause of a
1016 ;; for statement: At the first token after the starting paren.
1017 ;; Otherwise: At the containing statement(*).
1018 (statement-block-intro . +)
1019 ;; Relpos: In inexpr statement block: At the inexpr block open
1020 ;; if it's at boi, else at the statement(*) at boi of the start
1021 ;; of the inexpr construct. In a block hanging on a
1022 ;; case/default label: At the closest preceding label that
1023 ;; starts at boi. Otherwise: At the start of the containing
1024 ;; block(*).
1025 (statement-case-intro . +)
1026 ;; Relpos: At the case/default label(*).
1027 (statement-case-open . 0)
1028 ;; Relpos: At the case/default label(*).
1029 (substatement . +)
1030 ;; Relpos: At the containing statement(*).
1031 (substatement-open . +)
1032 ;; Relpos: At the containing statement(*).
1033 (substatement-label . 2)
1034 ;; Relpos: At the containing statement(*).
1035 (case-label . 0)
1036 ;; Relpos: At the start of the switch block(*).
1037 (access-label . -)
1038 ;; Relpos: Same as inclass.
1039 (label . 2)
1040 ;; Relpos: At the start of the containing block(*).
1041 (do-while-closure . 0)
1042 ;; Relpos: At the corresponding while statement(*).
1043 (else-clause . 0)
1044 ;; Relpos: At the corresponding if statement(*).
1045 (catch-clause . 0)
1046 ;; Relpos: At the previous try or catch statement clause(*).
1047 (comment-intro . (c-lineup-knr-region-comment c-lineup-comment))
1048 ;; Relpos: None.
1049 (arglist-intro . +)
1050 ;; Relpos: Boi at the open paren, or at the first non-ws after
1051 ;; the open paren of the surrounding sexp, whichever is later.
1052 (arglist-cont . (c-lineup-gcc-asm-reg 0))
1053 ;; Relpos: At the first token after the open paren.
1054 (arglist-cont-nonempty . (c-lineup-gcc-asm-reg c-lineup-arglist))
1055 ;; Relpos: At the containing statement(*).
1056 ;; 2nd pos: At the open paren.
1057 (arglist-close . +)
1058 ;; Relpos: At the containing statement(*).
1059 ;; 2nd pos: At the open paren.
1060 (stream-op . c-lineup-streamop)
1061 ;; Relpos: Boi at the first stream op in the statement.
1062 (inclass . +)
1063 ;; Relpos: At the class open brace if it's at boi, otherwise
1064 ;; boi at the class decl start.
1065 (cpp-macro . [0])
1066 ;; Relpos: None.
1067 (cpp-macro-cont . +)
1068 ;; Relpos: At the macro start (always at boi).
1069 (cpp-define-intro . (c-lineup-cpp-define +))
1070 ;; Relpos: None.
1071 (friend . 0)
1072 ;; Relpos: None.
1073 (objc-method-intro . [0])
1074 ;; Relpos: Boi.
1075 (objc-method-args-cont . c-lineup-ObjC-method-args)
1076 ;; Relpos: At the method start (always at boi).
1077 (objc-method-call-cont . c-lineup-ObjC-method-call)
1078 ;; Relpos: At the open bracket.
1079 (extern-lang-open . 0)
1080 (namespace-open . 0)
1081 (module-open . 0)
1082 (composition-open . 0)
1083 ;; Relpos: Boi at the extern/namespace/etc keyword.
1084 (extern-lang-close . 0)
1085 (namespace-close . 0)
1086 (module-close . 0)
1087 (composition-close . 0)
1088 ;; Relpos: Boi at the corresponding extern/namespace/etc keyword.
1089 (inextern-lang . +)
1090 (innamespace . +)
1091 (inmodule . +)
1092 (incomposition . +)
1093 ;; Relpos: At the extern/namespace/etc block open brace if it's
1094 ;; at boi, otherwise boi at the keyword.
1095 (template-args-cont . (c-lineup-template-args +))
1096 ;; Relpos: Boi at the decl start. This might be changed; the
1097 ;; logical position is clearly the opening '<'.
1098 (inlambda . c-lineup-inexpr-block)
1099 ;; Relpos: None.
1100 (lambda-intro-cont . +)
1101 ;; Relpos: Boi at the lambda start.
1102 (inexpr-statement . +)
1103 ;; Relpos: None.
1104 (inexpr-class . +)
1105 ;; Relpos: None.
1107 (defcustom c-offsets-alist nil
1108 "Association list of syntactic element symbols and indentation offsets.
1109 As described below, each cons cell in this list has the form:
1111 (SYNTACTIC-SYMBOL . OFFSET)
1113 When a line is indented, CC Mode first determines the syntactic
1114 context of it by generating a list of symbols called syntactic
1115 elements. This list can contain more than one syntactic element and
1116 the global variable `c-syntactic-context' contains the context list
1117 for the line being indented. Each element in this list is actually a
1118 cons cell of the syntactic symbol and a buffer position. This buffer
1119 position is called the relative indent point for the line. Some
1120 syntactic symbols may not have a relative indent point associated with
1121 them.
1123 After the syntactic context list for a line is generated, CC Mode
1124 calculates the absolute indentation for the line by looking at each
1125 syntactic element in the list. It compares the syntactic element
1126 against the SYNTACTIC-SYMBOL's in `c-offsets-alist'. When it finds a
1127 match, it adds the OFFSET to the column of the relative indent point.
1128 The sum of this calculation for each element in the syntactic list is
1129 the absolute offset for line being indented.
1131 If the syntactic element does not match any in the `c-offsets-alist',
1132 the element is ignored.
1134 If OFFSET is nil, the syntactic element is ignored in the offset
1135 calculation.
1137 If OFFSET is an integer, it's added to the relative indent.
1139 If OFFSET is one of the symbols `+', `-', `++', `--', `*', or `/', a
1140 positive or negative multiple of `c-basic-offset' is added; 1, -1, 2,
1141 -2, 0.5, and -0.5, respectively.
1143 If OFFSET is a vector, it's first element, which must be an integer,
1144 is used as an absolute indentation column. This overrides all
1145 relative offsets. If there are several syntactic elements which
1146 evaluates to absolute indentation columns, the first one takes
1147 precedence. You can see in which order CC Mode combines the syntactic
1148 elements in a certain context by using \\[c-show-syntactic-information] on the line.
1150 If OFFSET is a function, it's called with a single argument
1151 containing the cons of the syntactic element symbol and the relative
1152 indent point. The return value from the function is then
1153 reinterpreted as an OFFSET value.
1155 If OFFSET is a list, it's recursively evaluated using the semantics
1156 described above. The first element of the list to return a non-nil
1157 value succeeds. If none of the elements returns a non-nil value, the
1158 syntactic element is ignored.
1160 `c-offsets-alist' is a style variable. This means that the offsets on
1161 this variable are normally taken from the style system in CC Mode
1162 \(see `c-default-style' and `c-style-alist'). However, any offsets
1163 put explicitly on this list will override the style system when a CC
1164 Mode buffer is initialized \(there is a variable
1165 `c-old-style-variable-behavior' that changes this, though).
1167 Here is the current list of valid syntactic element symbols:
1169 string -- Inside multi-line string.
1170 c -- Inside a multi-line C style block comment.
1171 defun-open -- Brace that opens a function definition.
1172 defun-close -- Brace that closes a function definition.
1173 defun-block-intro -- The first line in a top-level defun.
1174 class-open -- Brace that opens a class definition.
1175 class-close -- Brace that closes a class definition.
1176 inline-open -- Brace that opens an in-class inline method.
1177 inline-close -- Brace that closes an in-class inline method.
1178 func-decl-cont -- The region between a function definition's
1179 argument list and the function opening brace
1180 (excluding K&R argument declarations). In C, you
1181 cannot put anything but whitespace and comments
1182 between them; in C++ and Java, throws declarations
1183 and other things can appear in this context.
1184 knr-argdecl-intro -- First line of a K&R C argument declaration.
1185 knr-argdecl -- Subsequent lines in a K&R C argument declaration.
1186 topmost-intro -- The first line in a topmost construct definition.
1187 topmost-intro-cont -- Topmost definition continuation lines.
1188 member-init-intro -- First line in a member initialization list.
1189 member-init-cont -- Subsequent member initialization list lines.
1190 inher-intro -- First line of a multiple inheritance list.
1191 inher-cont -- Subsequent multiple inheritance lines.
1192 block-open -- Statement block open brace.
1193 block-close -- Statement block close brace.
1194 brace-list-open -- Open brace of an enum or static array list.
1195 brace-list-close -- Close brace of an enum or static array list.
1196 brace-list-intro -- First line in an enum or static array list.
1197 brace-list-entry -- Subsequent lines in an enum or static array list.
1198 brace-entry-open -- Subsequent lines in an enum or static array
1199 list that start with an open brace.
1200 statement -- A C (or like) statement.
1201 statement-cont -- A continuation of a C (or like) statement.
1202 statement-block-intro -- The first line in a new statement block.
1203 statement-case-intro -- The first line in a case \"block\".
1204 statement-case-open -- The first line in a case block starting with brace.
1205 substatement -- The first line after an if/while/for/do/else.
1206 substatement-open -- The brace that opens a substatement block.
1207 substatement-label -- Labelled line after an if/while/for/do/else.
1208 case-label -- A \"case\" or \"default\" label.
1209 access-label -- C++ private/protected/public access label.
1210 label -- Any ordinary label.
1211 do-while-closure -- The \"while\" that ends a do/while construct.
1212 else-clause -- The \"else\" of an if/else construct.
1213 catch-clause -- The \"catch\" or \"finally\" of a try/catch construct.
1214 comment-intro -- A line containing only a comment introduction.
1215 arglist-intro -- The first line in an argument list.
1216 arglist-cont -- Subsequent argument list lines when no
1217 arguments follow on the same line as the
1218 arglist opening paren.
1219 arglist-cont-nonempty -- Subsequent argument list lines when at
1220 least one argument follows on the same
1221 line as the arglist opening paren.
1222 arglist-close -- The solo close paren of an argument list.
1223 stream-op -- Lines continuing a stream operator construct.
1224 inclass -- The construct is nested inside a class definition.
1225 Used together with e.g. `topmost-intro'.
1226 cpp-macro -- The start of a C preprocessor macro definition.
1227 cpp-macro-cont -- Inside a multi-line C preprocessor macro definition.
1228 friend -- A C++ friend declaration.
1229 objc-method-intro -- The first line of an Objective-C method definition.
1230 objc-method-args-cont -- Lines continuing an Objective-C method definition.
1231 objc-method-call-cont -- Lines continuing an Objective-C method call.
1232 extern-lang-open -- Brace that opens an \"extern\" block.
1233 extern-lang-close -- Brace that closes an \"extern\" block.
1234 inextern-lang -- Analogous to the `inclass' syntactic symbol,
1235 but used inside \"extern\" blocks.
1236 namespace-open, namespace-close, innamespace
1237 -- Similar to the three `extern-lang' symbols, but for
1238 C++ \"namespace\" blocks.
1239 module-open, module-close, inmodule
1240 -- Similar to the three `extern-lang' symbols, but for
1241 CORBA IDL \"module\" blocks.
1242 composition-open, composition-close, incomposition
1243 -- Similar to the three `extern-lang' symbols, but for
1244 CORBA CIDL \"composition\" blocks.
1245 template-args-cont -- C++ template argument list continuations.
1246 inlambda -- In the header or body of a lambda function.
1247 lambda-intro-cont -- Continuation of the header of a lambda function.
1248 inexpr-statement -- The statement is inside an expression.
1249 inexpr-class -- The class is inside an expression. Used e.g. for
1250 Java anonymous classes."
1251 :type
1252 `(set :format "%{%t%}:
1253 Override style setting
1254 | Syntax Offset
1256 ,@(mapcar
1257 (lambda (elt)
1258 `(cons :format "%v"
1259 :value ,elt
1260 (c-const-symbol :format "%v: "
1261 :size 25)
1262 (sexp :format "%v"
1263 :validate
1264 (lambda (widget)
1265 (unless (c-valid-offset (widget-value widget))
1266 (widget-put widget :error "Invalid offset")
1267 widget)))))
1268 (get 'c-offsets-alist 'c-stylevar-fallback)))
1269 :group 'c)
1271 ;; The syntactic symbols that can occur inside code blocks. Used by
1272 ;; `c-gnu-impose-minimum'.
1273 (defconst c-inside-block-syms
1274 '(defun-block-intro block-open block-close statement statement-cont
1275 statement-block-intro statement-case-intro statement-case-open
1276 substatement substatement-open substatement-label case-label label
1277 do-while-closure else-clause catch-clause inlambda))
1279 (defcustom c-style-variables-are-local-p t
1280 "*Whether style variables should be buffer local by default.
1281 If non-nil, then all indentation style related variables will be made
1282 buffer local by default. If nil, they will remain global. Variables
1283 are made buffer local when this file is loaded, and once buffer
1284 localized, they cannot be made global again.
1286 This variable must be set appropriately before CC Mode is loaded.
1288 The list of variables to buffer localize are:
1289 c-basic-offset
1290 c-comment-only-line-offset
1291 c-indent-comment-alist
1292 c-indent-comments-syntactically-p
1293 c-block-comment-prefix
1294 c-comment-prefix-regexp
1295 c-doc-comment-style
1296 c-cleanup-list
1297 c-hanging-braces-alist
1298 c-hanging-colons-alist
1299 c-hanging-semi&comma-criteria
1300 c-backslash-column
1301 c-backslash-max-column
1302 c-label-minimum-indentation
1303 c-offsets-alist
1304 c-special-indent-hook
1305 c-indentation-style"
1306 :type 'boolean
1307 :group 'c)
1309 (defcustom c-mode-hook nil
1310 "*Hook called by `c-mode'."
1311 :type 'hook
1312 :group 'c)
1314 (defcustom c++-mode-hook nil
1315 "*Hook called by `c++-mode'."
1316 :type 'hook
1317 :group 'c)
1319 (defcustom objc-mode-hook nil
1320 "*Hook called by `objc-mode'."
1321 :type 'hook
1322 :group 'c)
1324 (defcustom java-mode-hook nil
1325 "*Hook called by `java-mode'."
1326 :type 'hook
1327 :group 'c)
1329 (defcustom idl-mode-hook nil
1330 "*Hook called by `idl-mode'."
1331 :type 'hook
1332 :group 'c)
1334 (defcustom pike-mode-hook nil
1335 "*Hook called by `pike-mode'."
1336 :type 'hook
1337 :group 'c)
1339 (defcustom c-mode-common-hook nil
1340 "*Hook called by all CC Mode modes for common initializations."
1341 :type 'hook
1342 :group 'c)
1344 (defcustom c-initialization-hook nil
1345 "*Hook called when the CC Mode package gets initialized.
1346 This hook is only run once per Emacs session and can be used as a
1347 `load-hook' or in place of using `eval-after-load'."
1348 :type 'hook
1349 :group 'c)
1351 (defcustom c-enable-xemacs-performance-kludge-p nil
1352 "*Enables a XEmacs only hack that may improve speed for some coding styles.
1353 For styles that hang top-level opening braces (as is common with JDK
1354 Java coding styles) this can improve performance between 3 and 60
1355 times for core indentation functions (e.g. `c-parse-state'). For
1356 styles that conform to the Emacs recommendation of putting these
1357 braces in column zero, this can degrade performance about as much.
1358 This variable only has effect in XEmacs."
1359 :type 'boolean
1360 :group 'c)
1362 (defvar c-old-style-variable-behavior nil
1363 "*Enables the old style variable behavior when non-nil.
1365 Normally the values of the style variables will override the style
1366 settings specified by the variables `c-default-style' and
1367 `c-style-alist'. However, in CC Mode 5.25 and earlier, it was the
1368 other way around, meaning that changes made to the style variables
1369 from e.g. Customize would not take effect unless special precautions
1370 were taken. That was confusing, especially for novice users.
1372 It's believed that despite this change, the new behavior will still
1373 produce the same results for most old CC Mode configurations, since
1374 all style variables are per default set in a special non-override
1375 state. Set this variable only if your configuration has stopped
1376 working due to this change.")
1378 (define-widget 'c-extra-types-widget 'radio
1379 "Internal CC Mode widget for the `*-font-lock-extra-types' variables."
1380 :args '((const :tag "none" nil)
1381 (repeat :tag "types" regexp)))
1383 (eval-and-compile
1384 ;; XEmacs 19 evaluates this at compile time below, while most other
1385 ;; versions delays the evaluation until the package is loaded.
1386 (defun c-make-font-lock-extra-types-blurb (mode1 mode2 example)
1387 (concat "\
1388 *List of extra types (aside from the type keywords) to recognize in "
1389 mode1 " mode.
1390 Each list item should be a regexp matching a single identifier.
1391 " example "
1393 On decoration level 3 (and higher, where applicable), a method is used
1394 that finds most types and declarations by syntax alone. This variable
1395 is still used as a first step, but other types are recognized
1396 correctly anyway in most cases. Therefore this variable should be
1397 fairly restrictive and not contain patterns that are uncertain.
1399 Note that this variable is only consulted when the major mode is
1400 initialized. If you change it later you have to reinitialize CC Mode
1401 by doing \\[" mode2 "].
1403 Despite the name, this variable is not only used for font locking but
1404 also elsewhere in CC Mode to tell types from other identifiers.")))
1406 ;; Note: Most of the variables below are also defined in font-lock.el
1407 ;; in older versions in Emacs, so depending on the load order we might
1408 ;; not install the values below. There's no kludge to cope with this
1409 ;; (as opposed to the *-font-lock-keywords-* variables) since the old
1410 ;; values work fairly well anyway.
1412 (defcustom c-font-lock-extra-types
1413 '("FILE" "\\sw+_t"
1414 "bool" "complex" "imaginary" ; Defined in C99.
1415 ;; I do not appreciate the following very Emacs-specific luggage
1416 ;; in the default value, but otoh it can hardly get in the way for
1417 ;; other users, and removing it would cause unnecessary grief for
1418 ;; the old timers that are used to it. /mast
1419 "Lisp_Object")
1420 (c-make-font-lock-extra-types-blurb "C" "c-mode"
1421 "For example, a value of (\"FILE\" \"\\\\sw+_t\") means the word FILE
1422 and words ending in _t are treated as type names.")
1423 :type 'c-extra-types-widget
1424 :group 'c)
1426 (defcustom c++-font-lock-extra-types
1427 '("\\sw+_t"
1428 "\\([iof]\\|str\\)+stream\\(buf\\)?" "ios"
1429 "string" "rope"
1430 "list" "slist"
1431 "deque" "vector" "bit_vector"
1432 "set" "multiset"
1433 "map" "multimap"
1434 "hash\\(_\\(m\\(ap\\|ulti\\(map\\|set\\)\\)\\|set\\)\\)?"
1435 "stack" "queue" "priority_queue"
1436 "type_info"
1437 "iterator" "const_iterator" "reverse_iterator" "const_reverse_iterator"
1438 "reference" "const_reference")
1439 (c-make-font-lock-extra-types-blurb "C++" "c++-mode"
1440 "For example, a value of (\"string\") means the word string is treated
1441 as a type name.")
1442 :type 'c-extra-types-widget
1443 :group 'c)
1445 (defcustom objc-font-lock-extra-types
1446 (list (concat "[" c-upper "]\\sw*[" c-lower "]\\sw*"))
1447 (c-make-font-lock-extra-types-blurb "ObjC" "objc-mode" (concat
1448 "For example, a value of (\"[" c-upper "]\\\\sw*[" c-lower "]\\\\sw*\") means
1449 capitalized words are treated as type names (the requirement for a
1450 lower case char is to avoid recognizing all-caps macro and constant
1451 names)."))
1452 :type 'c-extra-types-widget
1453 :group 'c)
1455 (defcustom java-font-lock-extra-types
1456 (list (concat "[" c-upper "]\\sw*[" c-lower "]\\sw*"))
1457 (c-make-font-lock-extra-types-blurb "Java" "java-mode" (concat
1458 "For example, a value of (\"[" c-upper "]\\\\sw*[" c-lower "]\\\\sw*\") means
1459 capitalized words are treated as type names (the requirement for a
1460 lower case char is to avoid recognizing all-caps constant names)."))
1461 :type 'c-extra-types-widget
1462 :group 'c)
1464 (defcustom idl-font-lock-extra-types nil
1465 (c-make-font-lock-extra-types-blurb "IDL" "idl-mode" "")
1466 :type 'c-extra-types-widget
1467 :group 'c)
1469 (defcustom pike-font-lock-extra-types
1470 (list (concat "[" c-upper "]\\sw*[" c-lower "]\\sw*"))
1471 (c-make-font-lock-extra-types-blurb "Pike" "pike-mode" (concat
1472 "For example, a value of (\"[" c-upper "]\\\\sw*[" c-lower "]\\\\sw*\") means
1473 capitalized words are treated as type names (the requirement for a
1474 lower case char is to avoid recognizing all-caps macro and constant
1475 names)."))
1476 :type 'c-extra-types-widget
1477 :group 'c)
1480 ;; Non-customizable variables, still part of the interface to CC Mode
1481 (defvar c-file-style nil
1482 "Variable interface for setting style via File Local Variables.
1483 In a file's Local Variable section, you can set this variable to a
1484 string suitable for `c-set-style'. When the file is visited, CC Mode
1485 will set the style of the file to this value automatically.
1487 Note that file style settings are applied before file offset settings
1488 as designated in the variable `c-file-offsets'.")
1489 (make-variable-buffer-local 'c-file-style)
1491 (defvar c-file-offsets nil
1492 "Variable interface for setting offsets via File Local Variables.
1493 In a file's Local Variable section, you can set this variable to an
1494 association list similar to the values allowed in `c-offsets-alist'.
1495 When the file is visited, CC Mode will institute these offset settings
1496 automatically.
1498 Note that file offset settings are applied after file style settings
1499 as designated in the variable `c-file-style'.")
1500 (make-variable-buffer-local 'c-file-offsets)
1502 ;; It isn't possible to specify a docstring without specifying an
1503 ;; initial value with `defvar', so the following two variables have
1504 ;; only doc comments even though they are part of the API. It's
1505 ;; really good not to have an initial value for variables like these
1506 ;; that always should be dynamically bound, so it's worth the
1507 ;; inconvenience.
1509 (cc-bytecomp-defvar c-syntactic-context)
1510 (defvar c-syntactic-context)
1511 ;; Variable containing the syntactic analysis list during indentation.
1512 ;; It is a list with one element for each found syntactic symbol. See
1513 ;; `c-syntactic-element' for further info.
1515 ;; This is always bound dynamically. It should never be set
1516 ;; statically (e.g. with `setq').
1518 (cc-bytecomp-defvar c-syntactic-element)
1519 (defvar c-syntactic-element)
1520 ;; Variable containing the info regarding the current syntactic
1521 ;; element during calls to the lineup functions. The value is one of
1522 ;; the elements in the list in `c-syntactic-context' and is a list
1523 ;; with the symbol name in the first position, followed by zero or
1524 ;; more elements containing any additional info associated with the
1525 ;; syntactic symbol. There are accessor functions `c-langelem-sym',
1526 ;; `c-langelem-pos', `c-langelem-col', and `c-langelem-2nd-pos' to
1527 ;; access the list.
1529 ;; Specifically, the element returned by `c-langelem-pos' is the
1530 ;; relpos (a.k.a. anchor position), or nil if there isn't any. See
1531 ;; the comments in the `c-offsets-alist' variable for more detailed
1532 ;; info about the data each syntactic symbol provides.
1534 ;; This is always bound dynamically. It should never be set
1535 ;; statically (e.g. with `setq').
1537 (defvar c-indentation-style nil
1538 "Name of the currently installed style.
1539 Don't change this directly; call `c-set-style' instead.")
1541 (defvar c-current-comment-prefix nil
1542 "The current comment prefix regexp.
1543 Set from `c-comment-prefix-regexp' at mode initialization.")
1544 (make-variable-buffer-local 'c-current-comment-prefix)
1547 (cc-provide 'cc-vars)
1549 ;;; arch-tag: d62e9a55-c9fe-409b-b5b6-050b6aa202c9
1550 ;;; cc-vars.el ends here