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