Mercurial > emacs
annotate lisp/progmodes/cc-vars.el @ 44412:85a7b7660c2d
2002-04-06 Per Abrahamsen <abraham@dina.kvl.dk>
* progmodes/cc-vars.el (c-block-comment-prefix): Specify :value
for customization type.
Reported by Mattias Fredsberg <mattias.fredsberg@active-tv.com>.
author | Per Abrahamsen <abraham@dina.kvl.dk> |
---|---|
date | Sat, 06 Apr 2002 11:41:36 +0000 |
parents | be541feb06cc |
children | 7a3ac6c387fe |
rev | line source |
---|---|
18720 | 1 ;;; cc-vars.el --- user customization variables for CC Mode |
2 | |
36920 | 3 ;; Copyright (C) 1985,1987,1992-2001 Free Software Foundation, Inc. |
18720 | 4 |
30399
7b0a7b155fe2
(c-style-variables-are-local-p): Incompatible
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
5 ;; Authors: 2000- Martin Stjernholm |
7b0a7b155fe2
(c-style-variables-are-local-p): Incompatible
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
6 ;; 1998-1999 Barry A. Warsaw and Martin Stjernholm |
24282 | 7 ;; 1992-1997 Barry A. Warsaw |
18720 | 8 ;; 1987 Dave Detlefs and Stewart Clamen |
9 ;; 1985 Richard M. Stallman | |
24282 | 10 ;; Maintainer: bug-cc-mode@gnu.org |
18720 | 11 ;; Created: 22-Apr-1997 (split from cc-mode.el) |
20144
56d81cc7b4f5
(c-progress-interval): Document new semantics
Karl Heuer <kwzh@gnu.org>
parents:
20140
diff
changeset
|
12 ;; Version: See cc-mode.el |
18720 | 13 ;; Keywords: c languages oop |
14 | |
15 ;; This file is part of GNU Emacs. | |
16 | |
17 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
18 ;; it under the terms of the GNU General Public License as published by | |
19 ;; the Free Software Foundation; either version 2, or (at your option) | |
20 ;; any later version. | |
21 | |
22 ;; GNU Emacs is distributed in the hope that it will be useful, | |
23 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
24 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
25 ;; GNU General Public License for more details. | |
26 | |
27 ;; You should have received a copy of the GNU General Public License | |
36920 | 28 ;; along with this program; see the file COPYING. If not, write to |
29 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
18720 | 30 ;; Boston, MA 02111-1307, USA. |
31 | |
38422
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36920
diff
changeset
|
32 ;;; Commentary: |
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36920
diff
changeset
|
33 |
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36920
diff
changeset
|
34 ;;; Code: |
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36920
diff
changeset
|
35 |
24282 | 36 (eval-when-compile |
26817 | 37 (let ((load-path |
36920 | 38 (if (and (boundp 'byte-compile-dest-file) |
39 (stringp byte-compile-dest-file)) | |
40 (cons (file-name-directory byte-compile-dest-file) load-path) | |
26817 | 41 load-path))) |
36920 | 42 (require 'cc-bytecomp))) |
43 | |
44 (cc-require 'cc-defs) | |
45 | |
46 ;; Silence the compiler. | |
47 (cc-bytecomp-defun get-char-table) ; XEmacs 20+ | |
48 (cc-bytecomp-defun char-table-range) ; Emacs 19+ | |
49 (cc-bytecomp-defun char-table-p) ; Emacs 19+, XEmacs 20+ | |
24282 | 50 |
36920 | 51 ;; Pull in custom if it exists and is recent enough (the one in Emacs |
52 ;; 19.34 isn't). | |
53 (eval | |
54 (cc-eval-when-compile | |
55 (condition-case nil | |
56 (progn | |
57 (require 'custom) | |
58 (or (fboundp 'defcustom) (error "")) | |
59 (require 'wid-edit) | |
60 '(progn ; Compile in the require's. | |
61 (require 'custom) | |
62 (require 'wid-edit))) | |
63 (error | |
64 (message "Warning: Compiling without Customize support \ | |
65 since a (good enough) custom library wasn't found") | |
66 (cc-bytecomp-defmacro define-widget (name class doc &rest args)) | |
67 (cc-bytecomp-defmacro defcustom (symbol value doc &rest args) | |
68 `(defvar ,symbol ,value ,doc)) | |
69 nil)))) | |
18720 | 70 |
71 | |
26817 | 72 ;;; Helpers |
18720 | 73 |
24282 | 74 ;; This widget will show up in newer versions of the Custom library |
75 (or (get 'other 'widget-type) | |
76 (define-widget 'other 'sexp | |
77 "Matches everything, but doesn't let the user edit the value. | |
78 Useful as last item in a `choice' widget." | |
79 :tag "Other" | |
80 :format "%t%n" | |
81 :value 'other)) | |
82 | |
26817 | 83 (define-widget 'c-const-symbol 'item |
84 "An uneditable lisp symbol." | |
85 :value nil | |
86 :tag "Symbol" | |
87 :format "%t: %v\n%d" | |
88 :match (lambda (widget value) (symbolp value)) | |
89 :value-to-internal | |
90 (lambda (widget value) | |
91 (let ((s (if (symbolp value) | |
92 (symbol-name value) | |
93 value)) | |
94 (l (widget-get widget :size))) | |
95 (if l | |
96 (setq s (concat s (make-string (- l (length s)) ?\ )))) | |
97 s)) | |
98 :value-to-external | |
99 (lambda (widget value) | |
100 (if (stringp value) | |
101 (intern (progn | |
102 (string-match "\\`[^ ]*" value) | |
103 (match-string 0 value))) | |
104 value))) | |
105 | |
106 (defvar c-style-variables | |
107 '(c-basic-offset c-comment-only-line-offset c-block-comment-prefix | |
108 c-comment-prefix-regexp c-cleanup-list c-hanging-braces-alist | |
109 c-hanging-colons-alist c-hanging-semi&comma-criteria c-backslash-column | |
110 c-special-indent-hook c-label-minimum-indentation c-offsets-alist) | |
111 "List of the style variables.") | |
112 | |
113 (defmacro defcustom-c-stylevar (name val doc &rest args) | |
114 "Defines a style variable." | |
115 `(progn | |
36920 | 116 (put ',name 'c-stylevar-fallback ,val) |
26817 | 117 (defcustom ,name 'set-from-style |
118 ,(concat doc " | |
119 | |
120 This is a style variable. Apart from the valid values described | |
121 above, it can be set to the symbol `set-from-style'. In that case, it | |
122 takes its value from the style system (see `c-default-style' and | |
123 `c-styles-alist') when a CC Mode buffer is initialized. Otherwise, | |
124 the value set here overrides the style system (there is a variable | |
125 `c-old-style-variable-behavior' that changes this, though).") | |
126 ,@(plist-put | |
127 args ':type | |
128 `'(radio | |
129 (const :tag "Use style settings" | |
130 set-from-style) | |
131 ,(let ((type (eval (plist-get args ':type)))) | |
132 (unless (consp type) | |
133 (setq type (list type))) | |
134 (unless (c-safe (plist-get (cdr type) ':value)) | |
135 (setcdr type (append `(:value ,val) | |
136 (cdr type)))) | |
137 (unless (c-safe (plist-get (cdr type) ':tag)) | |
138 (setcdr type (append '(:tag "Override style settings") | |
139 (cdr type)))) | |
140 type)))))) | |
141 | |
142 (defun c-valid-offset (offset) | |
143 "Return non-nil iff OFFSET is a valid offset for a syntactic symbol. | |
144 See `c-offsets-alist'." | |
145 (or (eq offset '+) | |
146 (eq offset '-) | |
147 (eq offset '++) | |
148 (eq offset '--) | |
149 (eq offset '*) | |
150 (eq offset '/) | |
151 (integerp offset) | |
36920 | 152 (vectorp offset) |
26817 | 153 (functionp offset) |
154 (and (symbolp offset) | |
155 (or (boundp offset) | |
156 (fboundp offset))) | |
157 (progn | |
158 (while (and (consp offset) | |
159 (c-valid-offset (car offset))) | |
160 (setq offset (cdr offset))) | |
161 (null offset)))) | |
162 | |
163 | |
164 | |
165 ;;; User variables | |
166 | |
167 (defcustom c-strict-syntax-p nil | |
168 "*If non-nil, all syntactic symbols must be found in `c-offsets-alist'. | |
169 If the syntactic symbol for a particular line does not match a symbol | |
170 in the offsets alist, or if no non-nil offset value can be determined | |
171 for a symbol, an error is generated, otherwise no error is reported | |
172 and the syntactic symbol is ignored. | |
173 | |
174 This variable is considered obsolete; it doesn't work well with lineup | |
175 functions that return nil to support the feature of using lists on | |
176 syntactic symbols in `c-offsets-alist'. Please keep it set to nil." | |
177 :type 'boolean | |
178 :group 'c) | |
179 | |
180 (defcustom c-echo-syntactic-information-p nil | |
181 "*If non-nil, syntactic info is echoed when the line is indented." | |
182 :type 'boolean | |
183 :group 'c) | |
184 | |
185 (defcustom-c-stylevar c-basic-offset 4 | |
30399
7b0a7b155fe2
(c-style-variables-are-local-p): Incompatible
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
186 "*Amount of basic offset used by + and - symbols in `c-offsets-alist'. |
7b0a7b155fe2
(c-style-variables-are-local-p): Incompatible
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
187 Also used as the indentation step when `c-syntactic-indentation' is |
7b0a7b155fe2
(c-style-variables-are-local-p): Incompatible
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
188 nil." |
26817 | 189 :type 'integer |
190 :group 'c) | |
191 | |
18720 | 192 (defcustom c-tab-always-indent t |
193 "*Controls the operation of the TAB key. | |
194 If t, hitting TAB always just indents the current line. If nil, | |
195 hitting TAB indents the current line if point is at the left margin or | |
196 in the line's indentation, otherwise it insert a `real' tab character | |
24282 | 197 \(see note\). If the symbol `other', then tab is inserted only within |
198 literals -- defined as comments and strings -- and inside preprocessor | |
199 directives, but the line is always reindented. | |
18720 | 200 |
201 Note: The value of `indent-tabs-mode' will determine whether a real | |
26817 | 202 tab character will be inserted, or the equivalent number of spaces. |
18720 | 203 When inserting a tab, actually the function stored in the variable |
204 `c-insert-tab-function' is called. | |
205 | |
206 Note: indentation of lines containing only comments is also controlled | |
207 by the `c-comment-only-line-offset' variable." | |
208 :type '(radio | |
209 :extra-offset 8 | |
210 :format "%{C Tab Always Indent%}:\n The TAB key:\n%v" | |
211 (const :tag "always indents, never inserts TAB" t) | |
212 (const :tag "indents in left margin, otherwise inserts TAB" nil) | |
24282 | 213 (other :tag "inserts TAB in literals, otherwise indent" other)) |
18720 | 214 :group 'c) |
215 | |
216 (defcustom c-insert-tab-function 'insert-tab | |
30399
7b0a7b155fe2
(c-style-variables-are-local-p): Incompatible
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
217 "*Function used when inserting a tab for \\[c-indent-command]. |
18720 | 218 Only used when `c-tab-always-indent' indicates a `real' tab character |
219 should be inserted. Value must be a function taking no arguments." | |
220 :type 'function | |
221 :group 'c) | |
222 | |
30399
7b0a7b155fe2
(c-style-variables-are-local-p): Incompatible
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
223 (defcustom c-syntactic-indentation t |
36920 | 224 "*Whether the indentation should be controlled by the syntactic context. |
30399
7b0a7b155fe2
(c-style-variables-are-local-p): Incompatible
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
225 |
7b0a7b155fe2
(c-style-variables-are-local-p): Incompatible
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
226 If t, the indentation functions indents according to the syntactic |
7b0a7b155fe2
(c-style-variables-are-local-p): Incompatible
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
227 context, using the style settings specified by `c-offsets-alist'. |
7b0a7b155fe2
(c-style-variables-are-local-p): Incompatible
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
228 |
7b0a7b155fe2
(c-style-variables-are-local-p): Incompatible
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
229 If nil, every line is just indented to the same level as the previous |
7b0a7b155fe2
(c-style-variables-are-local-p): Incompatible
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
230 one, and the \\[c-indent-command] command adjusts the indentation in steps |
7b0a7b155fe2
(c-style-variables-are-local-p): Incompatible
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
231 specified by `c-basic-offset'. The indentation style have no effect |
7b0a7b155fe2
(c-style-variables-are-local-p): Incompatible
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
232 in this mode, nor any of the indentation associated variables, |
7b0a7b155fe2
(c-style-variables-are-local-p): Incompatible
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
233 e.g. `c-special-indent-hook'." |
7b0a7b155fe2
(c-style-variables-are-local-p): Incompatible
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
234 :type 'boolean |
7b0a7b155fe2
(c-style-variables-are-local-p): Incompatible
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
235 :group 'c) |
7b0a7b155fe2
(c-style-variables-are-local-p): Incompatible
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
236 |
26817 | 237 (defcustom-c-stylevar c-comment-only-line-offset 0 |
18720 | 238 "*Extra offset for line which contains only the start of a comment. |
239 Can contain an integer or a cons cell of the form: | |
240 | |
241 (NON-ANCHORED-OFFSET . ANCHORED-OFFSET) | |
242 | |
243 Where NON-ANCHORED-OFFSET is the amount of offset given to | |
244 non-column-zero anchored comment-only lines, and ANCHORED-OFFSET is | |
245 the amount of offset to give column-zero anchored comment-only lines. | |
26817 | 246 Just an integer as value is equivalent to (<val> . -1000). |
247 | |
248 Note that this variable only has effect when the `c-lineup-comment' | |
249 lineup function is used on the `comment-intro' syntactic symbol (the | |
250 default)." | |
251 :type '(choice (integer :tag "Non-anchored offset" 0) | |
18720 | 252 (cons :tag "Non-anchored & anchored offset" |
253 :value (0 . 0) | |
254 :extra-offset 8 | |
255 (integer :tag "Non-anchored offset") | |
256 (integer :tag "Anchored offset"))) | |
257 :group 'c) | |
258 | |
259 (defcustom c-indent-comments-syntactically-p nil | |
26817 | 260 "*Specifies how \\[indent-for-comment] should handle comment-only lines. |
18720 | 261 When this variable is non-nil, comment-only lines are indented |
26817 | 262 according to syntactic analysis via `c-offsets-alist'. Otherwise, the |
263 comment is indented as if it was preceded by code. Note that this | |
264 variable does not affect how the normal line indentation treats | |
265 comment-only lines." | |
18720 | 266 :type 'boolean |
267 :group 'c) | |
268 | |
36920 | 269 (make-obsolete-variable 'c-comment-continuation-stars |
270 'c-block-comment-prefix) | |
271 | |
272 ;; Although c-comment-continuation-stars is obsolete, we look at it in | |
273 ;; some places in CC Mode anyway, so make the compiler ignore it | |
274 ;; during our compilation. | |
275 (cc-bytecomp-obsolete-var c-comment-continuation-stars) | |
276 (cc-bytecomp-defvar c-comment-continuation-stars) | |
277 | |
26817 | 278 (defcustom-c-stylevar c-block-comment-prefix |
279 (if (boundp 'c-comment-continuation-stars) | |
280 c-comment-continuation-stars | |
281 "* ") | |
282 "*Specifies the line prefix of continued C-style block comments. | |
19298
4a99e63dc4a9
(c-buffer-is-cc-mode): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19255
diff
changeset
|
283 You should set this variable to the literal string that gets inserted |
4a99e63dc4a9
(c-buffer-is-cc-mode): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19255
diff
changeset
|
284 at the front of continued block style comment lines. This should |
26817 | 285 either be the empty string, or some characters without preceding |
286 spaces. To adjust the alignment under the comment starter, put an | |
287 appropriate value on the `c' syntactic symbol (see the | |
288 `c-offsets-alist' variable). | |
289 | |
290 It's only used when a one-line block comment is broken into two or | |
291 more lines for the first time; otherwise the appropriate prefix is | |
292 adapted from the comment. This variable is not used for C++ line | |
293 style comments." | |
44412
85a7b7660c2d
2002-04-06 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42706
diff
changeset
|
294 ;; We need to specify a :value to prevent `defcustom-c-stylevar' from |
85a7b7660c2d
2002-04-06 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42706
diff
changeset
|
295 ;; giving it an invalid value. Perhaps `defcustom-c-stylevar' |
85a7b7660c2d
2002-04-06 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42706
diff
changeset
|
296 ;; should evaluate the value first? |
85a7b7660c2d
2002-04-06 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42706
diff
changeset
|
297 ;; Per Abrahamsen <abraham@dina.kvl.dk> 2002-04-06. |
85a7b7660c2d
2002-04-06 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42706
diff
changeset
|
298 :type '(string :value "* ") |
19298
4a99e63dc4a9
(c-buffer-is-cc-mode): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19255
diff
changeset
|
299 :group 'c) |
4a99e63dc4a9
(c-buffer-is-cc-mode): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19255
diff
changeset
|
300 |
36920 | 301 (defcustom-c-stylevar c-comment-prefix-regexp |
302 '((pike-mode . "//+!?\\|\\**") | |
303 (other . "//+\\|\\**")) | |
26817 | 304 "*Regexp to match the line prefix inside comments. |
305 This regexp is used to recognize the fill prefix inside comments for | |
306 correct paragraph filling and other things. | |
307 | |
36920 | 308 If this variable is a string, it will be used in all CC Mode major |
309 modes. It can also be an association list, to associate specific | |
310 regexps to specific major modes. The symbol for the major mode is | |
311 looked up in the association list, and its value is used as the line | |
312 prefix regexp. If it's not found, then the symbol `other' is looked | |
313 up and its value is used instead. | |
314 | |
315 The regexp should match the prefix used in both C++ style line | |
316 comments and C style block comments, but it does not need to match a | |
317 block comment starter. In other words, it should at least match | |
318 \"//\" for line comments and the string in `c-block-comment-prefix', | |
319 which is sometimes inserted by CC Mode inside block comments. It | |
320 should not match any surrounding whitespace. | |
26817 | 321 |
322 Note that CC Mode modifies other variables from this one at mode | |
36920 | 323 initialization, so you will need to do \\[c-mode] (or whatever mode |
26817 | 324 you're currently using) if you change it in a CC Mode buffer." |
36920 | 325 :type '(radio |
326 (regexp :tag "Regexp for all modes") | |
327 (list | |
328 :tag "Mode-specific regexps" | |
329 (set | |
330 :inline t :format "%v" | |
331 (cons :format "%v" | |
332 (const :format "C " c-mode) (regexp :format "%v")) | |
333 (cons :format "%v" | |
334 (const :format "C++ " c++-mode) (regexp :format "%v")) | |
335 (cons :format "%v" | |
336 (const :format "ObjC " objc-mode) (regexp :format "%v")) | |
337 (cons :format "%v" | |
338 (const :format "Java " java-mode) (regexp :format "%v")) | |
339 (cons :format "%v" | |
340 (const :format "IDL " idl-mode) (regexp :format "%v")) | |
341 (cons :format "%v" | |
342 (const :format "Pike " pike-mode) (regexp :format "%v"))) | |
343 (cons :format " %v" | |
344 (const :format "Other " other) (regexp :format "%v")))) | |
26817 | 345 :group 'c) |
346 | |
347 (defcustom c-ignore-auto-fill '(string cpp code) | |
348 "*List of contexts in which automatic filling never occurs. | |
349 If Auto Fill mode is active, it will be temporarily disabled if point | |
350 is in any context on this list. It's e.g. useful to enable Auto Fill | |
351 in comments only, but not in strings or normal code. The valid | |
352 contexts are: | |
353 | |
354 string -- inside a string or character literal | |
355 c -- inside a C style block comment | |
356 c++ -- inside a C++ style line comment | |
357 cpp -- inside a preprocessor directive | |
358 code -- anywhere else, i.e. in normal code" | |
359 :type '(set | |
360 :extra-offset 8 | |
361 (const :tag "String literals" string) | |
362 (const :tag "C style block comments" c) | |
363 (const :tag "C++ style line comments" c++) | |
364 (const :tag "Preprocessor directives" cpp) | |
365 (const :tag "Normal code" code)) | |
366 :group 'c) | |
367 | |
368 (defcustom-c-stylevar c-cleanup-list '(scope-operator) | |
18720 | 369 "*List of various C/C++/ObjC constructs to \"clean up\". |
36920 | 370 The following clean ups only take place when the auto-newline feature |
371 is turned on, as evidenced by the `/a' or `/ah' appearing next to the | |
372 mode name: | |
18720 | 373 |
36920 | 374 brace-else-brace -- Clean up \"} else {\" constructs by placing |
375 entire construct on a single line. This clean | |
376 up only takes place when there is nothing but | |
18720 | 377 white space between the braces and the `else'. |
26817 | 378 Clean up occurs when the open brace after the |
18720 | 379 `else' is typed. |
36920 | 380 brace-elseif-brace -- Similar to brace-else-brace, but clean up |
381 \"} else if (...) {\" constructs. Clean up | |
382 occurs after the open parenthesis and the open | |
383 brace. | |
384 brace-catch-brace -- Similar to brace-elseif-brace, but clean up | |
385 \"} catch (...) {\" constructs. | |
386 empty-defun-braces -- Clean up empty defun braces by placing the | |
18720 | 387 braces on the same line. Clean up occurs when |
388 the defun closing brace is typed. | |
36920 | 389 defun-close-semi -- Clean up the terminating semi-colon on defuns |
18720 | 390 by placing the semi-colon on the same line as |
391 the closing brace. Clean up occurs when the | |
392 semi-colon is typed. | |
36920 | 393 list-close-comma -- Clean up commas following braces in array |
18720 | 394 and aggregate initializers. Clean up occurs |
395 when the comma is typed. | |
36920 | 396 scope-operator -- Clean up double colons which may designate |
18720 | 397 a C++ scope operator split across multiple |
36920 | 398 lines. Note that certain C++ constructs can |
18720 | 399 generate ambiguous situations. This clean up |
400 only takes place when there is nothing but | |
36920 | 401 whitespace between colons. Clean up occurs |
402 when the second colon is typed. | |
403 | |
404 The following clean ups always take place when they are on this list, | |
405 regardless of the auto-newline feature, since they typically don't | |
406 involve auto-newline inserted newlines: | |
407 | |
408 space-before-funcall -- Insert exactly one space before the opening | |
409 parenthesis of a function call. Clean up | |
410 occurs when the opening parenthesis is typed. | |
411 compact-empty-funcall -- Clean up any space before the function call | |
412 opening parenthesis if and only if the | |
413 argument list is empty. This is typically | |
414 useful together with `space-before-funcall' to | |
415 get the style \"foo (bar)\" and \"foo()\". | |
416 Clean up occurs when the closing parenthesis | |
417 is typed." | |
18720 | 418 :type '(set |
419 :extra-offset 8 | |
36920 | 420 (const :tag "Put \"} else {\" on one line" |
421 brace-else-brace) | |
422 (const :tag "Put \"} else if (...) {\" on one line" | |
423 brace-elseif-brace) | |
424 (const :tag "Put \"} catch (...) {\" on one line" | |
425 brace-catch-brace) | |
426 (const :tag "Put empty defun braces on one line" | |
427 empty-defun-braces) | |
428 (const :tag "Put \"};\" ending defuns on one line" | |
429 defun-close-semi) | |
430 (const :tag "Put \"},\" in aggregates on one line" | |
431 list-close-comma) | |
432 (const :tag "Put C++ style \"::\" on one line" | |
433 scope-operator) | |
434 (const :tag "Put a space before funcall parens, e.g. \"foo (bar)\"" | |
435 space-before-funcall) | |
436 (const :tag "Remove space before empty funcalls, e.g. \"foo()\"" | |
437 compact-empty-funcall)) | |
18720 | 438 :group 'c) |
439 | |
26817 | 440 (defcustom-c-stylevar c-hanging-braces-alist '((brace-list-open) |
441 (brace-entry-open) | |
442 (substatement-open after) | |
443 (block-close . c-snug-do-while) | |
444 (extern-lang-open after) | |
445 (inexpr-class-open after) | |
446 (inexpr-class-close before)) | |
447 "*Controls the insertion of newlines before and after braces | |
448 when the auto-newline feature is active. This variable contains an | |
449 association list with elements of the following form: | |
450 \(SYNTACTIC-SYMBOL . ACTION). | |
18720 | 451 |
452 When a brace (either opening or closing) is inserted, the syntactic | |
453 context it defines is looked up in this list, and if found, the | |
454 associated ACTION is used to determine where newlines are inserted. | |
455 If the context is not found, the default is to insert a newline both | |
456 before and after the brace. | |
457 | |
458 SYNTACTIC-SYMBOL can be any of: defun-open, defun-close, class-open, | |
459 class-close, inline-open, inline-close, block-open, block-close, | |
460 substatement-open, statement-case-open, extern-lang-open, | |
461 extern-lang-close, brace-list-open, brace-list-close, | |
26817 | 462 brace-list-intro, brace-entry-open, namespace-open, namespace-close, |
463 inexpr-class-open, or inexpr-class-close. See `c-offsets-alist' for | |
464 details, except for inexpr-class-open and inexpr-class-close, which | |
465 doesn't have any corresponding symbols there. Those two symbols are | |
466 used for the opening and closing braces, respectively, of anonymous | |
467 inner classes in Java. | |
18720 | 468 |
469 ACTION can be either a function symbol or a list containing any | |
470 combination of the symbols `before' or `after'. If the list is empty, | |
471 no newlines are inserted either before or after the brace. | |
472 | |
473 When ACTION is a function symbol, the function is called with a two | |
474 arguments: the syntactic symbol for the brace and the buffer position | |
475 at which the brace was inserted. The function must return a list as | |
476 described in the preceding paragraph. Note that during the call to | |
477 the function, the variable `c-syntactic-context' is set to the entire | |
478 syntactic context for the brace line." | |
26817 | 479 :type |
480 `(set ,@(mapcar | |
481 (lambda (elt) | |
482 `(cons :format "%v" | |
483 (c-const-symbol :format "%v: " | |
484 :size 20 | |
485 :value ,elt) | |
486 (choice :format "%[Choice%] %v" | |
487 :value (before after) | |
488 (set :menu-tag "Before/after" | |
489 :format "Newline %v brace\n" | |
490 (const :format "%v, " before) | |
491 (const :format "%v" after)) | |
492 (function :menu-tag "Function" | |
493 :format "Run function: %v" | |
494 :value c-)))) | |
495 '(defun-open defun-close | |
496 class-open class-close | |
497 inline-open inline-close | |
498 block-open block-close | |
499 substatement-open statement-case-open | |
500 extern-lang-open extern-lang-close | |
501 brace-list-open brace-list-close | |
502 brace-list-intro brace-entry-open | |
503 namespace-open namespace-close | |
504 inexpr-class-open inexpr-class-close))) | |
505 :group 'c) | |
18720 | 506 |
26817 | 507 (defcustom-c-stylevar c-hanging-colons-alist nil |
18720 | 508 "*Controls the insertion of newlines before and after certain colons. |
509 This variable contains an association list with elements of the | |
510 following form: (SYNTACTIC-SYMBOL . ACTION). | |
511 | |
512 SYNTACTIC-SYMBOL can be any of: case-label, label, access-label, | |
513 member-init-intro, or inher-intro. | |
514 | |
515 See the variable `c-hanging-braces-alist' for the semantics of this | |
516 variable. Note however that making ACTION a function symbol is | |
517 currently not supported for this variable." | |
26817 | 518 :type |
519 `(set ,@(mapcar | |
520 (lambda (elt) | |
521 `(cons :format "%v" | |
522 (c-const-symbol :format "%v: " | |
523 :size 20 | |
524 :value ,elt) | |
525 (set :format "Newline %v brace\n" | |
526 (const :format "%v, " before) | |
527 (const :format "%v" after)))) | |
528 '(case-label label access-label member-init-intro inher-intro))) | |
18720 | 529 :group 'c) |
530 | |
26817 | 531 (defcustom-c-stylevar c-hanging-semi&comma-criteria |
532 '(c-semi&comma-inside-parenlist) | |
18720 | 533 "*List of functions that decide whether to insert a newline or not. |
534 The functions in this list are called, in order, whenever the | |
535 auto-newline minor mode is activated (as evidenced by a `/a' or `/ah' | |
536 string in the mode line), and a semicolon or comma is typed (see | |
537 `c-electric-semi&comma'). Each function in this list is called with | |
538 no arguments, and should return one of the following values: | |
539 | |
540 nil -- no determination made, continue checking | |
541 'stop -- do not insert a newline, and stop checking | |
542 (anything else) -- insert a newline, and stop checking | |
543 | |
544 If every function in the list is called with no determination made, | |
545 then no newline is inserted." | |
546 :type '(repeat function) | |
547 :group 'c) | |
548 | |
26817 | 549 (defcustom-c-stylevar c-backslash-column 48 |
18720 | 550 "*Column to insert backslashes when macroizing a region." |
551 :type 'integer | |
552 :group 'c) | |
553 | |
554 (defcustom c-special-indent-hook nil | |
555 "*Hook for user defined special indentation adjustments. | |
556 This hook gets called after a line is indented by the mode." | |
557 :type 'hook | |
558 :group 'c) | |
559 | |
560 (defcustom c-backspace-function 'backward-delete-char-untabify | |
561 "*Function called by `c-electric-backspace' when deleting backwards." | |
562 :type 'function | |
563 :group 'c) | |
564 | |
565 (defcustom c-delete-function 'delete-char | |
566 "*Function called by `c-electric-delete' when deleting forwards." | |
567 :type 'function | |
568 :group 'c) | |
569 | |
570 (defcustom c-electric-pound-behavior nil | |
571 "*List of behaviors for electric pound insertion. | |
572 Only currently supported behavior is `alignleft'." | |
573 :type '(set :extra-offset 8 (const alignleft)) | |
574 :group 'c) | |
575 | |
26817 | 576 (defcustom-c-stylevar c-label-minimum-indentation 1 |
18720 | 577 "*Minimum indentation for lines inside of top-level constructs. |
578 This variable typically only affects code using the `gnu' style, which | |
579 mandates a minimum of one space in front of every line inside | |
580 top-level constructs. Specifically, the function | |
581 `c-gnu-impose-minimum' on your `c-special-indent-hook' is what | |
582 enforces this." | |
583 :type 'integer | |
584 :group 'c) | |
585 | |
586 (defcustom c-progress-interval 5 | |
587 "*Interval used to update progress status during long re-indentation. | |
588 If a number, percentage complete gets updated after each interval of | |
20144
56d81cc7b4f5
(c-progress-interval): Document new semantics
Karl Heuer <kwzh@gnu.org>
parents:
20140
diff
changeset
|
589 that many seconds. To inhibit all messages during indentation, set |
56d81cc7b4f5
(c-progress-interval): Document new semantics
Karl Heuer <kwzh@gnu.org>
parents:
20140
diff
changeset
|
590 this variable to nil." |
18720 | 591 :type 'integer |
592 :group 'c) | |
593 | |
36920 | 594 (defcustom c-default-style '((java-mode . "java") (other . "gnu")) |
24282 | 595 "*Style which gets installed by default when a file is visited. |
20919
9cffecf3b1ca
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20144
diff
changeset
|
596 |
9cffecf3b1ca
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20144
diff
changeset
|
597 The value of this variable can be any style defined in |
24282 | 598 `c-style-alist', including styles you add. The value can also be an |
599 association list of major mode symbols to style names. | |
600 | |
601 When the value is a string, all CC Mode major modes will install this | |
36920 | 602 style by default. |
20919
9cffecf3b1ca
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20144
diff
changeset
|
603 |
26817 | 604 When the value is an alist, the major mode symbol is looked up in it |
605 and the associated style is installed. If the major mode is not | |
606 listed in the alist, then the symbol `other' is looked up in it, and | |
607 if found, the style in that entry is used. If `other' is not found in | |
608 the alist, then \"gnu\" style is used. | |
609 | |
610 The default style gets installed before your mode hooks run, so you | |
611 can always override the use of `c-default-style' by making calls to | |
36920 | 612 `c-set-style' in the appropriate mode hook." |
26817 | 613 :type '(radio |
36920 | 614 (string :tag "Style in all modes") |
615 (set :tag "Mode-specific styles" | |
616 (cons :format "%v" | |
617 (const :format "C " c-mode) (string :format "%v")) | |
618 (cons :format "%v" | |
619 (const :format "C++ " c++-mode) (string :format "%v")) | |
620 (cons :format "%v" | |
621 (const :format "ObjC " objc-mode) (string :format "%v")) | |
622 (cons :format "%v" | |
623 (const :format "Java " java-mode) (string :format "%v")) | |
624 (cons :format "%v" | |
625 (const :format "IDL " idl-mode) (string :format "%v")) | |
626 (cons :format "%v" | |
627 (const :format "Pike " pike-mode) (string :format "%v")) | |
628 (cons :format "%v" | |
629 (const :format "Other " other) (string :format "%v")))) | |
26817 | 630 :group 'c) |
20919
9cffecf3b1ca
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20144
diff
changeset
|
631 |
26817 | 632 (put 'c-offsets-alist 'c-stylevar-fallback |
633 '((string . c-lineup-dont-change) | |
634 ;; Relpos: Beg of previous line. | |
635 (c . c-lineup-C-comments) | |
636 ;; Relpos: Beg of the comment. | |
637 (defun-open . 0) | |
638 ;; Relpos: Boi at the func decl start when inside classes, bol | |
639 ;; at the func decl start when at top level. | |
640 (defun-close . 0) | |
641 ;; Relpos: Boi at the func decl start. | |
642 (defun-block-intro . +) | |
643 ;; Relpos: Boi at the block open. | |
644 (class-open . 0) | |
645 ;; Relpos: Boi at the class decl start. | |
646 (class-close . 0) | |
647 ;; Relpos: Boi at the class decl start. | |
648 (inline-open . +) | |
649 ;; Relpos: None for functions (inclass got the relpos then), | |
650 ;; boi at the lambda start for lambdas. | |
651 (inline-close . 0) | |
652 ;; Relpos: For functions: Boi at the func decl start. For | |
653 ;; lambdas: At the block open if it's at boi, at the boi of the | |
654 ;; lambda start otherwise. | |
655 (func-decl-cont . +) | |
656 ;; Relpos: Boi at the func decl start. | |
657 (knr-argdecl-intro . +) | |
658 ;; Relpos: Boi at the current line. | |
659 (knr-argdecl . 0) | |
660 ;; Relpos: Boi at the argdecl intro line. | |
661 (topmost-intro . 0) | |
662 ;; Relpos: Bol at the last line of previous construct. | |
663 (topmost-intro-cont . 0) | |
664 ;; Relpos: Boi at the topmost intro line. | |
665 (member-init-intro . +) | |
666 ;; Relpos: Boi at the func decl arglist open. | |
30399
7b0a7b155fe2
(c-style-variables-are-local-p): Incompatible
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
667 (member-init-cont . c-lineup-multi-inher) |
26817 | 668 ;; Relpos: Beg of the first member init. |
669 (inher-intro . +) | |
670 ;; Relpos: Java: Boi at the class decl start. Otherwise: Boi | |
671 ;; of current line (a bug?), unless it begins with an inher | |
672 ;; start colon, in which case boi of previous line is used. | |
673 (inher-cont . c-lineup-multi-inher) | |
674 ;; Relpos: Java: At the implements/extends keyword start. | |
675 ;; Otherwise: At the inher start colon, or boi at the class | |
676 ;; decl start if the first inherit clause hangs and it's not a | |
677 ;; func-local inherit clause (when does that occur?). | |
678 (block-open . 0) | |
42706 | 679 ;; Relpos: Inexpr statement: Boi at the preceding |
26817 | 680 ;; paren. Otherwise: None. |
681 (block-close . 0) | |
682 ;; Relpos: At the open brace if it's at boi. Otherwise boi at | |
683 ;; the start of the statement the open brace hangs on, or boi | |
684 ;; at the preceding paren for inexpr statements. | |
685 (brace-list-open . 0) | |
686 ;; Relpos: Boi at the brace list decl start, but a starting | |
687 ;; "typedef" token is ignored. | |
688 (brace-list-close . 0) | |
689 ;; Relpos: Boi at the brace list open. | |
690 (brace-list-intro . +) | |
691 ;; Relpos: Boi at the brace list open. | |
692 (brace-list-entry . 0) | |
693 ;; Relpos: At the first non-ws char after the open paren if the | |
694 ;; first token is on the same line, otherwise boi at that | |
695 ;; token. | |
696 (brace-entry-open . 0) | |
697 ;; Relpos: Same as brace-list-entry. | |
698 (statement . 0) | |
699 ;; Relpos: After a ';' in the condition clause of a for | |
700 ;; statement: At the first token after the starting paren. | |
701 ;; Otherwise: Boi at the start of the closest non-hanging | |
702 ;; previous statement, but after any switch label. | |
703 (statement-cont . +) | |
704 ;; Relpos: After the first token in the condition clause of a | |
705 ;; for statement: At the first token after the starting paren. | |
706 ;; On the first line in a continued expression that starts with | |
707 ;; a stream op and there's no stream op on the previous line: | |
708 ;; Boi of previous line. Otherwise: Boi at the beginning of | |
709 ;; the statement, but after any type of label. | |
710 (statement-block-intro . +) | |
711 ;; Relpos: At the block start if it's at boi, otherwise boi at | |
712 ;; the start of the statement the open brace hangs on, or boi | |
713 ;; at the preceding paren for inexpr statements. | |
714 (statement-case-intro . +) | |
715 ;; Relpos: At the label keyword (always at boi). | |
716 (statement-case-open . 0) | |
717 ;; Relpos: At the label keyword (always at boi). | |
718 (substatement . +) | |
719 ;; Relpos: Boi at the containing statement or else clause. | |
720 (substatement-open . +) | |
721 ;; Relpos: Boi at the containing statement or else clause. | |
722 (case-label . 0) | |
723 ;; Relpos: At the switch block start if it's at boi, otherwise | |
724 ;; boi at the start of the switch condition clause. | |
725 (access-label . -) | |
726 ;; Relpos: Eol (a bug?). | |
727 (label . 2) | |
728 ;; Relpos: At the start of the containing block if it's at boi, | |
729 ;; otherwise boi at the start of the sexp before the block. | |
730 (do-while-closure . 0) | |
731 ;; Relpos: Boi at the corresponding while keyword. | |
732 (else-clause . 0) | |
733 ;; Relpos: Boi at the corresponding if keyword. | |
734 (catch-clause . 0) | |
735 ;; Relpos: Boi at the previous try or catch keyword in the try | |
736 ;; statement. | |
737 (comment-intro . c-lineup-comment) | |
738 ;; Relpos: None. | |
739 (arglist-intro . +) | |
30399
7b0a7b155fe2
(c-style-variables-are-local-p): Incompatible
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
740 ;; Relpos: Boi at the open paren, or at the first non-ws after |
7b0a7b155fe2
(c-style-variables-are-local-p): Incompatible
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
741 ;; the open paren of the surrounding sexp, whichever is later. |
26817 | 742 (arglist-cont . 0) |
743 ;; Relpos: At the first token after the open paren. | |
744 (arglist-cont-nonempty . c-lineup-arglist) | |
30399
7b0a7b155fe2
(c-style-variables-are-local-p): Incompatible
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
745 ;; Relpos: Boi at the open paren, or at the first non-ws after |
7b0a7b155fe2
(c-style-variables-are-local-p): Incompatible
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
746 ;; the open paren of the surrounding sexp, whichever is later. |
26817 | 747 (arglist-close . +) |
30399
7b0a7b155fe2
(c-style-variables-are-local-p): Incompatible
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
748 ;; Relpos: Boi at the open paren, or at the first non-ws after |
7b0a7b155fe2
(c-style-variables-are-local-p): Incompatible
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
749 ;; the open paren of the surrounding sexp, whichever is later. |
26817 | 750 (stream-op . c-lineup-streamop) |
751 ;; Relpos: Boi at the first stream op in the statement. | |
752 (inclass . +) | |
753 ;; Relpos: At the class open brace if it's at boi, otherwise | |
754 ;; boi at the class decl start. | |
36920 | 755 (cpp-macro . [0]) |
30399
7b0a7b155fe2
(c-style-variables-are-local-p): Incompatible
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
756 ;; Relpos: None. |
26817 | 757 (cpp-macro-cont . c-lineup-dont-change) |
758 ;; Relpos: At the macro start (always at boi). | |
759 (friend . 0) | |
760 ;; Relpos: None. | |
36920 | 761 (objc-method-intro . [0]) |
26817 | 762 ;; Relpos: Boi. |
763 (objc-method-args-cont . c-lineup-ObjC-method-args) | |
764 ;; Relpos: At the method start (always at boi). | |
765 (objc-method-call-cont . c-lineup-ObjC-method-call) | |
766 ;; Relpos: At the open bracket. | |
767 (extern-lang-open . 0) | |
768 ;; Relpos: Boi at the extern keyword. | |
769 (extern-lang-close . 0) | |
770 ;; Relpos: Boi at the corresponding extern keyword. | |
771 (inextern-lang . +) | |
772 ;; Relpos: At the extern block open brace if it's at boi, | |
773 ;; otherwise boi at the extern keyword. | |
774 (namespace-open . 0) | |
775 ;; Relpos: Boi at the namespace keyword. | |
776 (namespace-close . 0) | |
777 ;; Relpos: Boi at the corresponding namespace keyword. | |
778 (innamespace . +) | |
779 ;; Relpos: At the namespace block open brace if it's at boi, | |
780 ;; otherwise boi at the namespace keyword. | |
781 (template-args-cont . (c-lineup-template-args +)) | |
782 ;; Relpos: Boi at the decl start. | |
783 (inlambda . c-lineup-inexpr-block) | |
784 ;; Relpos: None. | |
785 (lambda-intro-cont . +) | |
786 ;; Relpos: Boi at the lambda start. | |
787 (inexpr-statement . 0) | |
788 ;; Relpos: None. | |
789 (inexpr-class . +) | |
790 ;; Relpos: None. | |
791 )) | |
792 (defcustom c-offsets-alist nil | |
793 "Association list of syntactic element symbols and indentation offsets. | |
794 As described below, each cons cell in this list has the form: | |
24282 | 795 |
26817 | 796 (SYNTACTIC-SYMBOL . OFFSET) |
797 | |
798 When a line is indented, CC Mode first determines the syntactic | |
799 context of it by generating a list of symbols called syntactic | |
800 elements. This list can contain more than one syntactic element and | |
801 the global variable `c-syntactic-context' contains the context list | |
802 for the line being indented. Each element in this list is actually a | |
803 cons cell of the syntactic symbol and a buffer position. This buffer | |
804 position is called the relative indent point for the line. Some | |
805 syntactic symbols may not have a relative indent point associated with | |
806 them. | |
807 | |
808 After the syntactic context list for a line is generated, CC Mode | |
809 calculates the absolute indentation for the line by looking at each | |
810 syntactic element in the list. It compares the syntactic element | |
811 against the SYNTACTIC-SYMBOL's in `c-offsets-alist'. When it finds a | |
812 match, it adds the OFFSET to the column of the relative indent point. | |
813 The sum of this calculation for each element in the syntactic list is | |
814 the absolute offset for line being indented. | |
815 | |
816 If the syntactic element does not match any in the `c-offsets-alist', | |
36920 | 817 the element is ignored. |
818 | |
819 If OFFSET is nil, the syntactic element is ignored in the offset | |
820 calculation. | |
821 | |
822 If OFFSET is an integer, it's added to the relative indent. | |
823 | |
824 If OFFSET is one of the symbols `+', `-', `++', `--', `*', or `/', a | |
825 positive or negative multiple of `c-basic-offset' is added; 1, -1, 2, | |
826 -2, 0.5, and -0.5, respectively. | |
26817 | 827 |
36920 | 828 If OFFSET is a vector, it's first element, which must be an integer, |
829 is used as an absolute indentation column. This overrides all | |
830 relative offsets. If there are several syntactic elements which | |
831 evaluates to absolute indentation columns, the first one takes | |
832 precedence. You can see in which order CC Mode combines the syntactic | |
833 elements in a certain context by using \\[c-show-syntactic-information] on the line. | |
26817 | 834 |
36920 | 835 If OFFSET is a function, it's called with a single argument |
836 containing the cons of the syntactic element symbol and the relative | |
837 indent point. The return value from the function is then | |
838 reinterpreted as an OFFSET value. | |
839 | |
840 If OFFSET is a list, it's recursively evaluated using the semantics | |
841 described above. The first element of the list to return a non-nil | |
842 value succeeds. If none of the elements returns a non-nil value, the | |
843 syntactic element is ignored. | |
26817 | 844 |
845 `c-offsets-alist' is a style variable. This means that the offsets on | |
846 this variable are normally taken from the style system in CC Mode | |
847 \(see `c-default-style' and `c-styles-alist'). However, any offsets | |
848 put explicitly on this list will override the style system when a CC | |
849 Mode buffer is initialized \(there is a variable | |
850 `c-old-style-variable-behavior' that changes this, though). | |
851 | |
852 Here is the current list of valid syntactic element symbols: | |
853 | |
854 string -- Inside multi-line string. | |
855 c -- Inside a multi-line C style block comment. | |
856 defun-open -- Brace that opens a function definition. | |
857 defun-close -- Brace that closes a function definition. | |
858 defun-block-intro -- The first line in a top-level defun. | |
859 class-open -- Brace that opens a class definition. | |
860 class-close -- Brace that closes a class definition. | |
861 inline-open -- Brace that opens an in-class inline method. | |
862 inline-close -- Brace that closes an in-class inline method. | |
863 func-decl-cont -- The region between a function definition's | |
864 argument list and the function opening brace | |
865 (excluding K&R argument declarations). In C, you | |
866 cannot put anything but whitespace and comments | |
867 between them; in C++ and Java, throws declarations | |
868 and other things can appear in this context. | |
869 knr-argdecl-intro -- First line of a K&R C argument declaration. | |
870 knr-argdecl -- Subsequent lines in a K&R C argument declaration. | |
871 topmost-intro -- The first line in a topmost construct definition. | |
872 topmost-intro-cont -- Topmost definition continuation lines. | |
873 member-init-intro -- First line in a member initialization list. | |
874 member-init-cont -- Subsequent member initialization list lines. | |
875 inher-intro -- First line of a multiple inheritance list. | |
876 inher-cont -- Subsequent multiple inheritance lines. | |
877 block-open -- Statement block open brace. | |
878 block-close -- Statement block close brace. | |
879 brace-list-open -- Open brace of an enum or static array list. | |
880 brace-list-close -- Close brace of an enum or static array list. | |
881 brace-list-intro -- First line in an enum or static array list. | |
882 brace-list-entry -- Subsequent lines in an enum or static array list. | |
883 brace-entry-open -- Subsequent lines in an enum or static array | |
884 list that start with an open brace. | |
885 statement -- A C (or like) statement. | |
886 statement-cont -- A continuation of a C (or like) statement. | |
887 statement-block-intro -- The first line in a new statement block. | |
888 statement-case-intro -- The first line in a case \"block\". | |
889 statement-case-open -- The first line in a case block starting with brace. | |
890 substatement -- The first line after an if/while/for/do/else. | |
891 substatement-open -- The brace that opens a substatement block. | |
892 case-label -- A `case' or `default' label. | |
893 access-label -- C++ private/protected/public access label. | |
894 label -- Any ordinary label. | |
895 do-while-closure -- The `while' that ends a do/while construct. | |
896 else-clause -- The `else' of an if/else construct. | |
897 catch-clause -- The `catch' or `finally' of a try/catch construct. | |
898 comment-intro -- A line containing only a comment introduction. | |
899 arglist-intro -- The first line in an argument list. | |
900 arglist-cont -- Subsequent argument list lines when no | |
901 arguments follow on the same line as the | |
902 arglist opening paren. | |
903 arglist-cont-nonempty -- Subsequent argument list lines when at | |
904 least one argument follows on the same | |
905 line as the arglist opening paren. | |
906 arglist-close -- The solo close paren of an argument list. | |
907 stream-op -- Lines continuing a stream operator construct. | |
908 inclass -- The construct is nested inside a class definition. | |
909 Used together with e.g. `topmost-intro'. | |
910 cpp-macro -- The start of a C preprocessor macro definition. | |
911 cpp-macro-cont -- Subsequent lines in a multi-line C preprocessor | |
912 macro definition. | |
913 friend -- A C++ friend declaration. | |
914 objc-method-intro -- The first line of an Objective-C method definition. | |
915 objc-method-args-cont -- Lines continuing an Objective-C method definition. | |
916 objc-method-call-cont -- Lines continuing an Objective-C method call. | |
917 extern-lang-open -- Brace that opens an external language block. | |
918 extern-lang-close -- Brace that closes an external language block. | |
919 inextern-lang -- Analogous to the `inclass' syntactic symbol, | |
920 but used inside extern constructs. | |
921 namespace-open -- Brace that opens a C++ namespace block. | |
922 namespace-close -- Brace that closes a C++ namespace block. | |
923 innamespace -- Analogous to the `inextern-lang' syntactic | |
924 symbol, but used inside C++ namespace constructs. | |
925 template-args-cont -- C++ template argument list continuations. | |
926 inlambda -- In the header or body of a lambda function. | |
927 lambda-intro-cont -- Continuation of the header of a lambda function. | |
928 inexpr-statement -- The statement is inside an expression. | |
929 inexpr-class -- The class is inside an expression. Used e.g. for | |
930 Java anonymous classes." | |
931 :type | |
932 `(set :format "%{%t%}: | |
933 Override style setting | |
934 | Syntax Offset | |
935 %v" | |
936 ,@(mapcar | |
937 (lambda (elt) | |
938 `(cons :format "%v" | |
939 :value ,elt | |
940 (c-const-symbol :format "%v: " | |
941 :size 25) | |
942 (sexp :format "%v" | |
943 :validate | |
944 (lambda (widget) | |
945 (unless (c-valid-offset (widget-value widget)) | |
946 (widget-put widget :error "Invalid offset") | |
947 widget))))) | |
948 (get 'c-offsets-alist 'c-stylevar-fallback))) | |
18720 | 949 :group 'c) |
950 | |
30399
7b0a7b155fe2
(c-style-variables-are-local-p): Incompatible
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
951 (defcustom c-style-variables-are-local-p t |
18720 | 952 "*Whether style variables should be buffer local by default. |
953 If non-nil, then all indentation style related variables will be made | |
954 buffer local by default. If nil, they will remain global. Variables | |
955 are made buffer local when this file is loaded, and once buffer | |
956 localized, they cannot be made global again. | |
957 | |
958 The list of variables to buffer localize are: | |
959 c-offsets-alist | |
960 c-basic-offset | |
961 c-comment-only-line-offset | |
26817 | 962 c-block-comment-prefix |
963 c-comment-prefix-regexp | |
18720 | 964 c-cleanup-list |
965 c-hanging-braces-alist | |
966 c-hanging-colons-alist | |
26817 | 967 c-hanging-semi&comma-criteria |
18720 | 968 c-backslash-column |
969 c-label-minimum-indentation | |
970 c-special-indent-hook | |
971 c-indentation-style" | |
972 :type 'boolean | |
973 :group 'c) | |
974 | |
975 (defcustom c-mode-hook nil | |
976 "*Hook called by `c-mode'." | |
26817 | 977 :type 'hook |
18720 | 978 :group 'c) |
979 | |
980 (defcustom c++-mode-hook nil | |
981 "*Hook called by `c++-mode'." | |
982 :type 'hook | |
983 :group 'c) | |
984 | |
985 (defcustom objc-mode-hook nil | |
986 "*Hook called by `objc-mode'." | |
987 :type 'hook | |
988 :group 'c) | |
989 | |
990 (defcustom java-mode-hook nil | |
991 "*Hook called by `java-mode'." | |
992 :type 'hook | |
993 :group 'c) | |
994 | |
19255
40a9475f22ea
(idl-mode-hook): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18848
diff
changeset
|
995 (defcustom idl-mode-hook nil |
40a9475f22ea
(idl-mode-hook): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18848
diff
changeset
|
996 "*Hook called by `idl-mode'." |
40a9475f22ea
(idl-mode-hook): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18848
diff
changeset
|
997 :type 'hook |
40a9475f22ea
(idl-mode-hook): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18848
diff
changeset
|
998 :group 'c) |
40a9475f22ea
(idl-mode-hook): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18848
diff
changeset
|
999 |
26817 | 1000 (defcustom pike-mode-hook nil |
1001 "*Hook called by `pike-mode'." | |
1002 :type 'hook | |
1003 :group 'c) | |
1004 | |
18720 | 1005 (defcustom c-mode-common-hook nil |
1006 "*Hook called by all CC Mode modes for common initializations." | |
1007 :type '(hook :format "%{CC Mode Common Hook%}:\n%v") | |
1008 :group 'c) | |
1009 | |
19255
40a9475f22ea
(idl-mode-hook): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18848
diff
changeset
|
1010 (defcustom c-initialization-hook nil |
40a9475f22ea
(idl-mode-hook): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18848
diff
changeset
|
1011 "*Hook called when the CC Mode package gets initialized. |
40a9475f22ea
(idl-mode-hook): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18848
diff
changeset
|
1012 This hook is only run once per Emacs session and can be used as a |
40a9475f22ea
(idl-mode-hook): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18848
diff
changeset
|
1013 `load-hook' or in place of using `eval-after-load'." |
40a9475f22ea
(idl-mode-hook): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18848
diff
changeset
|
1014 :type 'hook |
40a9475f22ea
(idl-mode-hook): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18848
diff
changeset
|
1015 :group 'c) |
40a9475f22ea
(idl-mode-hook): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18848
diff
changeset
|
1016 |
24282 | 1017 (defcustom c-enable-xemacs-performance-kludge-p nil |
20919
9cffecf3b1ca
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20144
diff
changeset
|
1018 "*Enables a XEmacs only hack that may improve speed for some coding styles. |
9cffecf3b1ca
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20144
diff
changeset
|
1019 For styles that hang top-level opening braces (as is common with JDK |
9cffecf3b1ca
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20144
diff
changeset
|
1020 Java coding styles) this can improve performance between 3 and 60 |
9cffecf3b1ca
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20144
diff
changeset
|
1021 times for core indentation functions (e.g. `c-parse-state'). For |
9cffecf3b1ca
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20144
diff
changeset
|
1022 styles that conform to the Emacs recommendation of putting these |
24282 | 1023 braces in column zero, this can degrade performance about as much. |
1024 This variable only has effect in XEmacs.") | |
18720 | 1025 |
26817 | 1026 (defcustom c-old-style-variable-behavior nil |
1027 "*Enables the old style variable behavior when non-nil. | |
1028 | |
1029 Normally the values of the style variables will override the style | |
1030 settings specified by the variables `c-default-style' and | |
1031 `c-styles-alist'. However, in CC Mode 5.25 and earlier, it was the | |
1032 other way around, meaning that changes made to the style variables | |
1033 from e.g. Customize would not take effect unless special precautions | |
1034 were taken. That was confusing, especially for novice users. | |
1035 | |
1036 It's believed that despite this change, the new behavior will still | |
1037 produce the same results for most old CC Mode configurations, since | |
1038 all style variables are per default set in a special non-override | |
1039 state. Set this variable only if your configuration has stopped | |
1040 working due to this change.") | |
1041 | |
1042 | |
18720 | 1043 |
1044 ;; Non-customizable variables, still part of the interface to CC Mode | |
1045 (defvar c-file-style nil | |
1046 "Variable interface for setting style via File Local Variables. | |
1047 In a file's Local Variable section, you can set this variable to a | |
1048 string suitable for `c-set-style'. When the file is visited, CC Mode | |
1049 will set the style of the file to this value automatically. | |
1050 | |
1051 Note that file style settings are applied before file offset settings | |
1052 as designated in the variable `c-file-offsets'.") | |
26817 | 1053 (make-variable-buffer-local 'c-file-style) |
18720 | 1054 |
1055 (defvar c-file-offsets nil | |
1056 "Variable interface for setting offsets via File Local Variables. | |
1057 In a file's Local Variable section, you can set this variable to an | |
1058 association list similar to the values allowed in `c-offsets-alist'. | |
1059 When the file is visited, CC Mode will institute these offset settings | |
1060 automatically. | |
1061 | |
1062 Note that file offset settings are applied after file style settings | |
1063 as designated in the variable `c-file-style'.") | |
26817 | 1064 (make-variable-buffer-local 'c-file-offsets) |
18720 | 1065 |
1066 (defvar c-syntactic-context nil | |
36920 | 1067 "Variable containing syntactic analysis list during indentation. |
1068 This is always bound dynamically. It should never be set statically | |
39834
0f64721b0bb8
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38422
diff
changeset
|
1069 \(e.g. with `setq').") |
18720 | 1070 |
26817 | 1071 (defvar c-indentation-style nil |
36920 | 1072 "Name of the currently installed style. |
1073 Don't change this directly; call `c-set-style' instead.") | |
18720 | 1074 |
36920 | 1075 (defvar c-current-comment-prefix nil |
1076 "The current comment prefix regexp. | |
1077 Set from `c-comment-prefix-regexp' at mode initialization.") | |
1078 (make-variable-buffer-local 'c-current-comment-prefix) | |
19298
4a99e63dc4a9
(c-buffer-is-cc-mode): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19255
diff
changeset
|
1079 |
18720 | 1080 |
21105
b40ae72a5b26
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20919
diff
changeset
|
1081 ;; Figure out what features this Emacs has |
b40ae72a5b26
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20919
diff
changeset
|
1082 ;;;###autoload |
b40ae72a5b26
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20919
diff
changeset
|
1083 (defconst c-emacs-features |
b40ae72a5b26
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20919
diff
changeset
|
1084 (let ((infodock-p (boundp 'infodock-version)) |
b40ae72a5b26
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20919
diff
changeset
|
1085 (comments |
b40ae72a5b26
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20919
diff
changeset
|
1086 ;; XEmacs 19 and beyond use 8-bit modify-syntax-entry flags. |
b40ae72a5b26
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20919
diff
changeset
|
1087 ;; Emacs 19 uses a 1-bit flag. We will have to set up our |
b40ae72a5b26
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20919
diff
changeset
|
1088 ;; syntax tables differently to handle this. |
b40ae72a5b26
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20919
diff
changeset
|
1089 (let ((table (copy-syntax-table)) |
b40ae72a5b26
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20919
diff
changeset
|
1090 entry) |
b40ae72a5b26
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20919
diff
changeset
|
1091 (modify-syntax-entry ?a ". 12345678" table) |
b40ae72a5b26
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20919
diff
changeset
|
1092 (cond |
b40ae72a5b26
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20919
diff
changeset
|
1093 ;; XEmacs 19, and beyond Emacs 19.34 |
b40ae72a5b26
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20919
diff
changeset
|
1094 ((arrayp table) |
b40ae72a5b26
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20919
diff
changeset
|
1095 (setq entry (aref table ?a)) |
b40ae72a5b26
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20919
diff
changeset
|
1096 ;; In Emacs, table entries are cons cells |
b40ae72a5b26
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20919
diff
changeset
|
1097 (if (consp entry) (setq entry (car entry)))) |
b40ae72a5b26
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20919
diff
changeset
|
1098 ;; XEmacs 20 |
b40ae72a5b26
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20919
diff
changeset
|
1099 ((fboundp 'get-char-table) (setq entry (get-char-table ?a table))) |
b40ae72a5b26
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20919
diff
changeset
|
1100 ;; before and including Emacs 19.34 |
b40ae72a5b26
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20919
diff
changeset
|
1101 ((and (fboundp 'char-table-p) |
b40ae72a5b26
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20919
diff
changeset
|
1102 (char-table-p table)) |
b40ae72a5b26
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20919
diff
changeset
|
1103 (setq entry (car (char-table-range table [?a])))) |
b40ae72a5b26
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20919
diff
changeset
|
1104 ;; incompatible |
b40ae72a5b26
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20919
diff
changeset
|
1105 (t (error "CC Mode is incompatible with this version of Emacs"))) |
b40ae72a5b26
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20919
diff
changeset
|
1106 (if (= (logand (lsh entry -16) 255) 255) |
b40ae72a5b26
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20919
diff
changeset
|
1107 '8-bit |
b40ae72a5b26
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20919
diff
changeset
|
1108 '1-bit)))) |
b40ae72a5b26
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20919
diff
changeset
|
1109 (if infodock-p |
b40ae72a5b26
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20919
diff
changeset
|
1110 (list comments 'infodock) |
b40ae72a5b26
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20919
diff
changeset
|
1111 (list comments))) |
b40ae72a5b26
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20919
diff
changeset
|
1112 "A list of features extant in the Emacs you are using. |
b40ae72a5b26
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20919
diff
changeset
|
1113 There are many flavors of Emacs out there, each with different |
b40ae72a5b26
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20919
diff
changeset
|
1114 features supporting those needed by CC Mode. Here's the current |
b40ae72a5b26
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20919
diff
changeset
|
1115 supported list, along with the values for this variable: |
b40ae72a5b26
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20919
diff
changeset
|
1116 |
26817 | 1117 XEmacs 19, 20, 21: (8-bit) |
1118 Emacs 19, 20: (1-bit) | |
21105
b40ae72a5b26
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20919
diff
changeset
|
1119 |
b40ae72a5b26
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20919
diff
changeset
|
1120 Infodock (based on XEmacs) has an additional symbol on this list: |
21111
dad4e4facdc0
(c-emacs-features): Var moved from cc-defs.el.
Richard M. Stallman <rms@gnu.org>
parents:
21105
diff
changeset
|
1121 `infodock'.") |
21105
b40ae72a5b26
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20919
diff
changeset
|
1122 |
b40ae72a5b26
(c-enable-xemacs-performance-kludge-p): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
20919
diff
changeset
|
1123 |
36920 | 1124 (cc-provide 'cc-vars) |
38422
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36920
diff
changeset
|
1125 |
18720 | 1126 ;;; cc-vars.el ends here |