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