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