1 |
;;; cc-vars.el --- user customization variables for CC Mode |
;;; cc-vars.el --- user customization variables for CC Mode |
2 |
|
|
3 |
;; Copyright (C) 1985,1987,1992-2001 Free Software Foundation, Inc. |
;; Copyright (C) 1985,1987,1992-2003 Free Software Foundation, Inc. |
4 |
|
|
5 |
;; Authors: 2000- Martin Stjernholm |
;; Authors: 1998- Martin Stjernholm |
6 |
;; 1998-1999 Barry A. Warsaw and Martin Stjernholm |
;; 1992-1999 Barry A. Warsaw |
|
;; 1992-1997 Barry A. Warsaw |
|
7 |
;; 1987 Dave Detlefs and Stewart Clamen |
;; 1987 Dave Detlefs and Stewart Clamen |
8 |
;; 1985 Richard M. Stallman |
;; 1985 Richard M. Stallman |
9 |
;; Maintainer: bug-cc-mode@gnu.org |
;; Maintainer: bug-cc-mode@gnu.org |
38 |
(stringp byte-compile-dest-file)) |
(stringp byte-compile-dest-file)) |
39 |
(cons (file-name-directory byte-compile-dest-file) load-path) |
(cons (file-name-directory byte-compile-dest-file) load-path) |
40 |
load-path))) |
load-path))) |
41 |
(require 'cc-bytecomp))) |
(load "cc-bytecomp" nil t))) |
42 |
|
|
43 |
(cc-require 'cc-defs) |
(cc-require 'cc-defs) |
44 |
|
|
49 |
|
|
50 |
;; Pull in custom if it exists and is recent enough (the one in Emacs |
;; Pull in custom if it exists and is recent enough (the one in Emacs |
51 |
;; 19.34 isn't). |
;; 19.34 isn't). |
52 |
(eval-when-compile |
(eval |
53 |
(require 'custom) |
(cc-eval-when-compile |
54 |
(require 'wid-edit)) |
(condition-case nil |
55 |
|
(progn |
56 |
|
(require 'custom) |
57 |
|
(or (fboundp 'defcustom) (error "")) |
58 |
|
(require 'widget) |
59 |
|
'(progn ; Compile in the require's. |
60 |
|
(require 'custom) |
61 |
|
(require 'widget))) |
62 |
|
(error |
63 |
|
(message "Warning: Compiling without Customize support \ |
64 |
|
since a (good enough) custom library wasn't found") |
65 |
|
(cc-bytecomp-defmacro define-widget (name class doc &rest args)) |
66 |
|
(cc-bytecomp-defmacro defgroup (symbol members doc &rest args)) |
67 |
|
(cc-bytecomp-defmacro defcustom (symbol value doc &rest args) |
68 |
|
`(defvar ,symbol ,value ,doc)) |
69 |
|
(cc-bytecomp-defmacro custom-declare-variable (symbol value doc |
70 |
|
&rest args) |
71 |
|
`(defvar ,(eval symbol) ,(eval value) ,doc)) |
72 |
|
nil)))) |
73 |
|
|
74 |
(cc-eval-when-compile |
(cc-eval-when-compile |
75 |
;; Need the function form of `backquote', which isn't standardized |
;; Need the function form of `backquote', which isn't standardized |
83 |
|
|
84 |
;;; Helpers |
;;; Helpers |
85 |
|
|
86 |
;; This widget will show up in newer versions of the Custom library |
;; This widget exists in newer versions of the Custom library |
87 |
(or (get 'other 'widget-type) |
(or (get 'other 'widget-type) |
88 |
(define-widget 'other 'sexp |
(define-widget 'other 'sexp |
89 |
"Matches everything, but doesn't let the user edit the value. |
"Matches everything, but doesn't let the user edit the value. |
121 |
:tag "Optional integer" |
:tag "Optional integer" |
122 |
:match (lambda (widget value) (or (integerp value) (null value)))) |
:match (lambda (widget value) (or (integerp value) (null value)))) |
123 |
|
|
124 |
|
(define-widget 'c-symbol-list 'sexp |
125 |
|
"A single symbol or a list of symbols." |
126 |
|
:tag "Symbols separated by spaces" |
127 |
|
:validate 'widget-field-validate |
128 |
|
:match |
129 |
|
(lambda (widget value) |
130 |
|
(or (symbolp value) |
131 |
|
(catch 'ok |
132 |
|
(while (listp value) |
133 |
|
(unless (symbolp (car value)) |
134 |
|
(throw 'ok nil)) |
135 |
|
(setq value (cdr value))) |
136 |
|
(null value)))) |
137 |
|
:value-to-internal |
138 |
|
(lambda (widget value) |
139 |
|
(cond ((null value) |
140 |
|
"") |
141 |
|
((symbolp value) |
142 |
|
(symbol-name value)) |
143 |
|
((consp value) |
144 |
|
(mapconcat (lambda (symbol) |
145 |
|
(symbol-name symbol)) |
146 |
|
value |
147 |
|
" ")) |
148 |
|
(t |
149 |
|
value))) |
150 |
|
:value-to-external |
151 |
|
(lambda (widget value) |
152 |
|
(if (stringp value) |
153 |
|
(let (list end) |
154 |
|
(while (string-match "\\S +" value end) |
155 |
|
(setq list (cons (intern (match-string 0 value)) list) |
156 |
|
end (match-end 0))) |
157 |
|
(if (and list (not (cdr list))) |
158 |
|
(car list) |
159 |
|
(nreverse list))) |
160 |
|
value))) |
161 |
|
|
162 |
(defvar c-style-variables |
(defvar c-style-variables |
163 |
'(c-basic-offset c-comment-only-line-offset c-indent-comment-alist |
'(c-basic-offset c-comment-only-line-offset c-indent-comment-alist |
164 |
c-indent-comments-syntactically-p c-block-comment-prefix |
c-indent-comments-syntactically-p c-block-comment-prefix |
165 |
c-comment-prefix-regexp c-cleanup-list c-hanging-braces-alist |
c-comment-prefix-regexp c-doc-comment-style c-cleanup-list |
166 |
c-hanging-colons-alist c-hanging-semi&comma-criteria c-backslash-column |
c-hanging-braces-alist c-hanging-colons-alist |
167 |
c-backslash-max-column c-special-indent-hook c-label-minimum-indentation |
c-hanging-semi&comma-criteria c-backslash-column c-backslash-max-column |
168 |
c-offsets-alist) |
c-special-indent-hook c-label-minimum-indentation c-offsets-alist) |
169 |
"List of the style variables.") |
"List of the style variables.") |
170 |
|
|
171 |
(defvar c-fallback-style nil) |
(defvar c-fallback-style nil) |
207 |
(defun c-valid-offset (offset) |
(defun c-valid-offset (offset) |
208 |
"Return non-nil iff OFFSET is a valid offset for a syntactic symbol. |
"Return non-nil iff OFFSET is a valid offset for a syntactic symbol. |
209 |
See `c-offsets-alist'." |
See `c-offsets-alist'." |
210 |
|
;; This function does not do any hidden buffer changes. |
211 |
(or (eq offset '+) |
(or (eq offset '+) |
212 |
(eq offset '-) |
(eq offset '-) |
213 |
(eq offset '++) |
(eq offset '++) |
324 |
of the macro content. The default context inside the macro is the |
of the macro content. The default context inside the macro is the |
325 |
same as the top level, so if it contains \"bare\" statements they |
same as the top level, so if it contains \"bare\" statements they |
326 |
might be indented wrongly, although there are special cases that |
might be indented wrongly, although there are special cases that |
327 |
handles this in most cases. If this problem occurs, it's usually |
handle this in most cases. If this problem occurs, it's usually |
328 |
countered easily by surrounding the statements by a block \(or even |
countered easily by surrounding the statements by a block \(or even |
329 |
better with the \"do { ... } while \(0)\" trick)." |
better with the \"do { ... } while \(0)\" trick)." |
330 |
:type 'boolean |
:type 'boolean |
490 |
should not match any surrounding whitespace. |
should not match any surrounding whitespace. |
491 |
|
|
492 |
Note that CC Mode uses this variable to set many other variables that |
Note that CC Mode uses this variable to set many other variables that |
493 |
handles the paragraph filling. That's done at mode initialization or |
handle the paragraph filling. That's done at mode initialization or |
494 |
when you switch to a style which sets this variable. Thus, if you |
when you switch to a style which sets this variable. Thus, if you |
495 |
change it in some other way, e.g. interactively in a CC Mode buffer, |
change it in some other way, e.g. interactively in a CC Mode buffer, |
496 |
you will need to do \\[c-mode] (or whatever mode you're currently |
you will need to do \\[c-setup-paragraph-variables] afterwards so that |
497 |
using) to reinitialize. |
the other variables are updated with the new value. |
498 |
|
|
499 |
Note also that when CC Mode starts up, the other variables are |
Note also that when CC Mode starts up, all variables are initialized |
500 |
modified before the mode hooks are run. If you change this variable |
before the mode hooks are run. It's therefore necessary to make a |
501 |
in a mode hook, you can call `c-setup-paragraph-variables' afterwards |
call to `c-setup-paragraph-variables' explicitly if you change this |
502 |
to redo it." |
variable in a mode hook." |
503 |
:type '(radio |
:type '(radio |
504 |
(regexp :tag "Regexp for all modes") |
(regexp :tag "Regexp for all modes") |
505 |
(list |
(list |
522 |
(const :format "Other " other) (regexp :format "%v")))) |
(const :format "Other " other) (regexp :format "%v")))) |
523 |
:group 'c) |
:group 'c) |
524 |
|
|
525 |
|
(defcustom-c-stylevar c-doc-comment-style |
526 |
|
'((java-mode . javadoc) |
527 |
|
(pike-mode . autodoc)) |
528 |
|
"*Specifies documentation comment style(s) to recognize. |
529 |
|
This is primarily used to fontify doc comments and the markup within |
530 |
|
them, e.g. Javadoc comments. |
531 |
|
|
532 |
|
The value can be any of the following symbols for various known doc |
533 |
|
comment styles: |
534 |
|
|
535 |
|
javadoc -- Javadoc style for \"/** ... */\" comments (default in Java mode). |
536 |
|
autodoc -- Pike autodoc style for \"//! ...\" comments (default in Pike mode). |
537 |
|
|
538 |
|
The value may also be a list of doc comment styles, in which case all |
539 |
|
of them are recognized simultaneously (presumably with markup cues |
540 |
|
that don't conflict). |
541 |
|
|
542 |
|
The value may also be an association list to specify different doc |
543 |
|
comment styles for different languages. The symbol for the major mode |
544 |
|
is then looked up in the alist, and the value of that element is |
545 |
|
interpreted as above if found. If it isn't found then the symbol |
546 |
|
`other' is looked up and its value is used instead. |
547 |
|
|
548 |
|
Note that CC Mode uses this variable to set other variables that |
549 |
|
handle fontification etc. That's done at mode initialization or when |
550 |
|
you switch to a style which sets this variable. Thus, if you change |
551 |
|
it in some other way, e.g. interactively in a CC Mode buffer, you will |
552 |
|
need to do \\[java-mode] (or whatever mode you're currently using) to |
553 |
|
reinitialize. |
554 |
|
|
555 |
|
Note also that when CC Mode starts up, the other variables are |
556 |
|
modified before the mode hooks are run. If you change this variable |
557 |
|
in a mode hook, you have to call `c-setup-doc-comment-style' |
558 |
|
afterwards to redo that work." |
559 |
|
;; Symbols other than those documented above may be used on this |
560 |
|
;; variable. If a variable exists that has that name with |
561 |
|
;; "-font-lock-keywords" appended, it's value is prepended to the |
562 |
|
;; font lock keywords list. If it's a function then it's called and |
563 |
|
;; the result is prepended. |
564 |
|
:type '(radio |
565 |
|
(c-symbol-list :tag "Doc style(s) in all modes") |
566 |
|
(list |
567 |
|
:tag "Mode-specific doc styles" |
568 |
|
(set |
569 |
|
:inline t :format "%v" |
570 |
|
(cons :format "%v" |
571 |
|
(const :format "C " c-mode) |
572 |
|
(c-symbol-list :format "%v")) |
573 |
|
(cons :format "%v" |
574 |
|
(const :format "C++ " c++-mode) |
575 |
|
(c-symbol-list :format "%v")) |
576 |
|
(cons :format "%v" |
577 |
|
(const :format "ObjC " objc-mode) |
578 |
|
(c-symbol-list :format "%v")) |
579 |
|
(cons :format "%v" |
580 |
|
(const :format "Java " java-mode) |
581 |
|
(c-symbol-list :format "%v")) |
582 |
|
(cons :format "%v" |
583 |
|
(const :format "IDL " idl-mode) |
584 |
|
(c-symbol-list :format "%v")) |
585 |
|
(cons :format "%v" |
586 |
|
(const :format "Pike " pike-mode) |
587 |
|
(c-symbol-list :format "%v")) |
588 |
|
(cons :format "%v" |
589 |
|
(const :format "Other " other) |
590 |
|
(c-symbol-list :format "%v"))))) |
591 |
|
:group 'c) |
592 |
|
|
593 |
(defcustom c-ignore-auto-fill '(string cpp code) |
(defcustom c-ignore-auto-fill '(string cpp code) |
594 |
"*List of contexts in which automatic filling never occurs. |
"*List of contexts in which automatic filling never occurs. |
595 |
If Auto Fill mode is active, it will be temporarily disabled if point |
If Auto Fill mode is active, it will be temporarily disabled if point |
683 |
|
|
684 |
(defcustom-c-stylevar c-hanging-braces-alist '((brace-list-open) |
(defcustom-c-stylevar c-hanging-braces-alist '((brace-list-open) |
685 |
(brace-entry-open) |
(brace-entry-open) |
686 |
|
(statement-cont) |
687 |
(substatement-open after) |
(substatement-open after) |
688 |
(block-close . c-snug-do-while) |
(block-close . c-snug-do-while) |
689 |
(extern-lang-open after) |
(extern-lang-open after) |
690 |
|
(namespace-open after) |
691 |
|
(module-open after) |
692 |
|
(composition-open after) |
693 |
(inexpr-class-open after) |
(inexpr-class-open after) |
694 |
(inexpr-class-close before)) |
(inexpr-class-close before)) |
695 |
"*Controls the insertion of newlines before and after braces |
"*Controls the insertion of newlines before and after braces |
703 |
If the context is not found, the default is to insert a newline both |
If the context is not found, the default is to insert a newline both |
704 |
before and after the brace. |
before and after the brace. |
705 |
|
|
706 |
SYNTACTIC-SYMBOL can be any of: defun-open, defun-close, class-open, |
SYNTACTIC-SYMBOL can be statement-cont, brace-list-intro, |
707 |
class-close, inline-open, inline-close, block-open, block-close, |
inexpr-class-open, inexpr-class-close, and any of the *-open and |
708 |
substatement-open, statement-case-open, extern-lang-open, |
*-close symbols. See `c-offsets-alist' for details, except for |
709 |
extern-lang-close, brace-list-open, brace-list-close, |
inexpr-class-open and inexpr-class-close, which doesn't have any |
710 |
brace-list-intro, brace-entry-open, namespace-open, namespace-close, |
corresponding symbols there. Those two symbols are used for the |
711 |
inexpr-class-open, or inexpr-class-close. See `c-offsets-alist' for |
opening and closing braces, respectively, of anonymous inner classes |
712 |
details, except for inexpr-class-open and inexpr-class-close, which |
in Java. |
|
doesn't have any corresponding symbols there. Those two symbols are |
|
|
used for the opening and closing braces, respectively, of anonymous |
|
|
inner classes in Java. |
|
713 |
|
|
714 |
ACTION can be either a function symbol or a list containing any |
ACTION can be either a function symbol or a list containing any |
715 |
combination of the symbols `before' or `after'. If the list is empty, |
combination of the symbols `before' or `after'. If the list is empty, |
741 |
class-open class-close |
class-open class-close |
742 |
inline-open inline-close |
inline-open inline-close |
743 |
block-open block-close |
block-open block-close |
744 |
substatement-open statement-case-open |
statement-cont substatement-open statement-case-open |
|
extern-lang-open extern-lang-close |
|
745 |
brace-list-open brace-list-close |
brace-list-open brace-list-close |
746 |
brace-list-intro brace-entry-open |
brace-list-intro brace-entry-open |
747 |
|
extern-lang-open extern-lang-close |
748 |
namespace-open namespace-close |
namespace-open namespace-close |
749 |
|
module-open module-close |
750 |
|
composition-open composition-close |
751 |
inexpr-class-open inexpr-class-close))) |
inexpr-class-open inexpr-class-close))) |
752 |
:group 'c) |
:group 'c) |
753 |
|
|
827 |
:group 'c) |
:group 'c) |
828 |
|
|
829 |
(defcustom c-delete-function 'delete-char |
(defcustom c-delete-function 'delete-char |
830 |
"*Function called by `c-electric-delete' when deleting forwards." |
"*Function called by `c-electric-delete-forward' when deleting forwards." |
831 |
:type 'function |
:type 'function |
832 |
:group 'c) |
:group 'c) |
833 |
|
|
1055 |
(arglist-cont . (c-lineup-gcc-asm-reg 0)) |
(arglist-cont . (c-lineup-gcc-asm-reg 0)) |
1056 |
;; Relpos: At the first token after the open paren. |
;; Relpos: At the first token after the open paren. |
1057 |
(arglist-cont-nonempty . (c-lineup-gcc-asm-reg c-lineup-arglist)) |
(arglist-cont-nonempty . (c-lineup-gcc-asm-reg c-lineup-arglist)) |
1058 |
;; Relpos: Boi at the open paren, or at the first non-ws after |
;; Relpos: At the containing statement(*). |
1059 |
;; the open paren of the surrounding sexp, whichever is later. |
;; 2nd pos: At the open paren. |
1060 |
(arglist-close . +) |
(arglist-close . +) |
1061 |
;; Relpos: Boi at the open paren, or at the first non-ws after |
;; Relpos: At the containing statement(*). |
1062 |
;; the open paren of the surrounding sexp, whichever is later. |
;; 2nd pos: At the open paren. |
1063 |
(stream-op . c-lineup-streamop) |
(stream-op . c-lineup-streamop) |
1064 |
;; Relpos: Boi at the first stream op in the statement. |
;; Relpos: Boi at the first stream op in the statement. |
1065 |
(inclass . +) |
(inclass . +) |
1080 |
(objc-method-call-cont . c-lineup-ObjC-method-call) |
(objc-method-call-cont . c-lineup-ObjC-method-call) |
1081 |
;; Relpos: At the open bracket. |
;; Relpos: At the open bracket. |
1082 |
(extern-lang-open . 0) |
(extern-lang-open . 0) |
|
;; Relpos: Boi at the extern keyword. |
|
|
(extern-lang-close . 0) |
|
|
;; Relpos: Boi at the corresponding extern keyword. |
|
|
(inextern-lang . +) |
|
|
;; Relpos: At the extern block open brace if it's at boi, |
|
|
;; otherwise boi at the extern keyword. |
|
1083 |
(namespace-open . 0) |
(namespace-open . 0) |
1084 |
;; Relpos: Boi at the namespace keyword. |
(module-open . 0) |
1085 |
|
(composition-open . 0) |
1086 |
|
;; Relpos: Boi at the extern/namespace/etc keyword. |
1087 |
|
(extern-lang-close . 0) |
1088 |
(namespace-close . 0) |
(namespace-close . 0) |
1089 |
;; Relpos: Boi at the corresponding namespace keyword. |
(module-close . 0) |
1090 |
|
(composition-close . 0) |
1091 |
|
;; Relpos: Boi at the corresponding extern/namespace/etc keyword. |
1092 |
|
(inextern-lang . +) |
1093 |
(innamespace . +) |
(innamespace . +) |
1094 |
;; Relpos: At the namespace block open brace if it's at boi, |
(inmodule . +) |
1095 |
;; otherwise boi at the namespace keyword. |
(incomposition . +) |
1096 |
|
;; Relpos: At the extern/namespace/etc block open brace if it's |
1097 |
|
;; at boi, otherwise boi at the keyword. |
1098 |
(template-args-cont . (c-lineup-template-args +)) |
(template-args-cont . (c-lineup-template-args +)) |
1099 |
;; Relpos: Boi at the decl start. This might be changed; the |
;; Relpos: Boi at the decl start. This might be changed; the |
1100 |
;; logical position is clearly the opening '<'. |
;; logical position is clearly the opening '<'. |
1143 |
positive or negative multiple of `c-basic-offset' is added; 1, -1, 2, |
positive or negative multiple of `c-basic-offset' is added; 1, -1, 2, |
1144 |
-2, 0.5, and -0.5, respectively. |
-2, 0.5, and -0.5, respectively. |
1145 |
|
|
1146 |
If OFFSET is a vector, its first element, which must be an integer, |
If OFFSET is a vector, it's first element, which must be an integer, |
1147 |
is used as an absolute indentation column. This overrides all |
is used as an absolute indentation column. This overrides all |
1148 |
relative offsets. If there are several syntactic elements which |
relative offsets. If there are several syntactic elements which |
1149 |
evaluates to absolute indentation columns, the first one takes |
evaluates to absolute indentation columns, the first one takes |
1232 |
objc-method-intro -- The first line of an Objective-C method definition. |
objc-method-intro -- The first line of an Objective-C method definition. |
1233 |
objc-method-args-cont -- Lines continuing an Objective-C method definition. |
objc-method-args-cont -- Lines continuing an Objective-C method definition. |
1234 |
objc-method-call-cont -- Lines continuing an Objective-C method call. |
objc-method-call-cont -- Lines continuing an Objective-C method call. |
1235 |
extern-lang-open -- Brace that opens an external language block. |
extern-lang-open -- Brace that opens an \"extern\" block. |
1236 |
extern-lang-close -- Brace that closes an external language block. |
extern-lang-close -- Brace that closes an \"extern\" block. |
1237 |
inextern-lang -- Analogous to the `inclass' syntactic symbol, |
inextern-lang -- Analogous to the `inclass' syntactic symbol, |
1238 |
but used inside extern constructs. |
but used inside \"extern\" blocks. |
1239 |
namespace-open -- Brace that opens a C++ namespace block. |
namespace-open, namespace-close, innamespace |
1240 |
namespace-close -- Brace that closes a C++ namespace block. |
-- Similar to the three `extern-lang' symbols, but for |
1241 |
innamespace -- Analogous to the `inextern-lang' syntactic |
C++ \"namespace\" blocks. |
1242 |
symbol, but used inside C++ namespace constructs. |
module-open, module-close, inmodule |
1243 |
|
-- Similar to the three `extern-lang' symbols, but for |
1244 |
|
CORBA IDL \"module\" blocks. |
1245 |
|
composition-open, composition-close, incomposition |
1246 |
|
-- Similar to the three `extern-lang' symbols, but for |
1247 |
|
CORBA CIDL \"composition\" blocks. |
1248 |
template-args-cont -- C++ template argument list continuations. |
template-args-cont -- C++ template argument list continuations. |
1249 |
inlambda -- In the header or body of a lambda function. |
inlambda -- In the header or body of a lambda function. |
1250 |
lambda-intro-cont -- Continuation of the header of a lambda function. |
lambda-intro-cont -- Continuation of the header of a lambda function. |
1278 |
are made buffer local when this file is loaded, and once buffer |
are made buffer local when this file is loaded, and once buffer |
1279 |
localized, they cannot be made global again. |
localized, they cannot be made global again. |
1280 |
|
|
1281 |
|
This variable must be set appropriately before CC Mode is loaded. |
1282 |
|
|
1283 |
The list of variables to buffer localize are: |
The list of variables to buffer localize are: |
|
c-offsets-alist |
|
1284 |
c-basic-offset |
c-basic-offset |
1285 |
c-comment-only-line-offset |
c-comment-only-line-offset |
1286 |
|
c-indent-comment-alist |
1287 |
|
c-indent-comments-syntactically-p |
1288 |
c-block-comment-prefix |
c-block-comment-prefix |
1289 |
c-comment-prefix-regexp |
c-comment-prefix-regexp |
1290 |
|
c-doc-comment-style |
1291 |
c-cleanup-list |
c-cleanup-list |
1292 |
c-hanging-braces-alist |
c-hanging-braces-alist |
1293 |
c-hanging-colons-alist |
c-hanging-colons-alist |
1294 |
c-hanging-semi&comma-criteria |
c-hanging-semi&comma-criteria |
1295 |
c-backslash-column |
c-backslash-column |
1296 |
|
c-backslash-max-column |
1297 |
c-label-minimum-indentation |
c-label-minimum-indentation |
1298 |
|
c-offsets-alist |
1299 |
c-special-indent-hook |
c-special-indent-hook |
1300 |
c-indentation-style" |
c-indentation-style" |
1301 |
:type 'boolean |
:type 'boolean |
1333 |
|
|
1334 |
(defcustom c-mode-common-hook nil |
(defcustom c-mode-common-hook nil |
1335 |
"*Hook called by all CC Mode modes for common initializations." |
"*Hook called by all CC Mode modes for common initializations." |
1336 |
:type '(hook :format "%{CC Mode Common Hook%}:\n%v") |
:type 'hook |
1337 |
:group 'c) |
:group 'c) |
1338 |
|
|
1339 |
(defcustom c-initialization-hook nil |
(defcustom c-initialization-hook nil |
1370 |
state. Set this variable only if your configuration has stopped |
state. Set this variable only if your configuration has stopped |
1371 |
working due to this change.") |
working due to this change.") |
1372 |
|
|
1373 |
|
(define-widget 'c-extra-types-widget 'radio |
1374 |
|
"Internal CC Mode widget for the `*-font-lock-extra-types' variables." |
1375 |
|
:args '((const :tag "none" nil) |
1376 |
|
(repeat :tag "types" regexp))) |
1377 |
|
|
1378 |
|
(eval-and-compile |
1379 |
|
;; XEmacs 19 evaluates this at compile time below, while most other |
1380 |
|
;; versions delays the evaluation until the package is loaded. |
1381 |
|
(defun c-make-font-lock-extra-types-blurb (mode1 mode2 example) |
1382 |
|
(concat "\ |
1383 |
|
*List of extra types (aside from the type keywords) to recognize in " |
1384 |
|
mode1 " mode. |
1385 |
|
Each list item should be a regexp matching a single identifier. |
1386 |
|
" example " |
1387 |
|
|
1388 |
|
On decoration level 3 (and higher, where applicable), a method is used |
1389 |
|
that finds most types and declarations by syntax alone. This variable |
1390 |
|
is still used as a first step, but other types are recognized |
1391 |
|
correctly anyway in most cases. Therefore this variable should be |
1392 |
|
fairly restrictive and not contain patterns that are uncertain. |
1393 |
|
|
1394 |
|
Note that this variable is only consulted when the major mode is |
1395 |
|
initialized. If you change it later you have to reinitialize CC Mode |
1396 |
|
by doing \\[" mode2 "]. |
1397 |
|
|
1398 |
|
Despite the name, this variable is not only used for font locking but |
1399 |
|
also elsewhere in CC Mode to tell types from other identifiers."))) |
1400 |
|
|
1401 |
|
;; Note: Most of the variables below are also defined in font-lock.el |
1402 |
|
;; in older versions in Emacs, so depending on the load order we might |
1403 |
|
;; not install the values below. There's no kludge to cope with this |
1404 |
|
;; (as opposed to the *-font-lock-keywords-* variables) since the old |
1405 |
|
;; values work fairly well anyway. |
1406 |
|
|
1407 |
|
(defcustom c-font-lock-extra-types |
1408 |
|
'("FILE" "\\sw+_t" |
1409 |
|
"bool" "complex" "imaginary" ; Defined in C99. |
1410 |
|
;; I do not appreciate the following very Emacs-specific luggage |
1411 |
|
;; in the default value, but otoh it can hardly get in the way for |
1412 |
|
;; other users, and removing it would cause unnecessary grief for |
1413 |
|
;; the old timers that are used to it. /mast |
1414 |
|
"Lisp_Object") |
1415 |
|
(c-make-font-lock-extra-types-blurb "C" "c-mode" |
1416 |
|
"For example, a value of (\"FILE\" \"\\\\sw+_t\") means the word FILE |
1417 |
|
and words ending in _t are treated as type names.") |
1418 |
|
:type 'c-extra-types-widget |
1419 |
|
:group 'c) |
1420 |
|
|
1421 |
|
(defcustom c++-font-lock-extra-types |
1422 |
|
'("\\sw+_t" |
1423 |
|
"\\([iof]\\|str\\)+stream\\(buf\\)?" "ios" |
1424 |
|
"string" "rope" |
1425 |
|
"list" "slist" |
1426 |
|
"deque" "vector" "bit_vector" |
1427 |
|
"set" "multiset" |
1428 |
|
"map" "multimap" |
1429 |
|
"hash\\(_\\(m\\(ap\\|ulti\\(map\\|set\\)\\)\\|set\\)\\)?" |
1430 |
|
"stack" "queue" "priority_queue" |
1431 |
|
"type_info" |
1432 |
|
"iterator" "const_iterator" "reverse_iterator" "const_reverse_iterator" |
1433 |
|
"reference" "const_reference") |
1434 |
|
(c-make-font-lock-extra-types-blurb "C++" "c++-mode" |
1435 |
|
"For example, a value of (\"string\") means the word string is treated |
1436 |
|
as a type name.") |
1437 |
|
:type 'c-extra-types-widget |
1438 |
|
:group 'c) |
1439 |
|
|
1440 |
|
(defcustom objc-font-lock-extra-types |
1441 |
|
(list (concat "[" c-upper "]\\sw*[" c-lower "]\\sw*")) |
1442 |
|
(c-make-font-lock-extra-types-blurb "ObjC" "objc-mode" (concat |
1443 |
|
"For example, a value of (\"[" c-upper "]\\\\sw*[" c-lower "]\\\\sw*\") means |
1444 |
|
capitalized words are treated as type names (the requirement for a |
1445 |
|
lower case char is to avoid recognizing all-caps macro and constant |
1446 |
|
names).")) |
1447 |
|
:type 'c-extra-types-widget |
1448 |
|
:group 'c) |
1449 |
|
|
1450 |
|
(defcustom java-font-lock-extra-types |
1451 |
|
(list (concat "[" c-upper "]\\sw*[" c-lower "]\\sw*")) |
1452 |
|
(c-make-font-lock-extra-types-blurb "Java" "java-mode" (concat |
1453 |
|
"For example, a value of (\"[" c-upper "]\\\\sw*[" c-lower "]\\\\sw*\") means |
1454 |
|
capitalized words are treated as type names (the requirement for a |
1455 |
|
lower case char is to avoid recognizing all-caps constant names).")) |
1456 |
|
:type 'c-extra-types-widget |
1457 |
|
:group 'c) |
1458 |
|
|
1459 |
|
(defcustom idl-font-lock-extra-types nil |
1460 |
|
(c-make-font-lock-extra-types-blurb "IDL" "idl-mode" "") |
1461 |
|
:type 'c-extra-types-widget |
1462 |
|
:group 'c) |
1463 |
|
|
1464 |
|
(defcustom pike-font-lock-extra-types |
1465 |
|
(list (concat "[" c-upper "]\\sw*[" c-lower "]\\sw*")) |
1466 |
|
(c-make-font-lock-extra-types-blurb "Pike" "pike-mode" (concat |
1467 |
|
"For example, a value of (\"[" c-upper "]\\\\sw*[" c-lower "]\\\\sw*\") means |
1468 |
|
capitalized words are treated as type names (the requirement for a |
1469 |
|
lower case char is to avoid recognizing all-caps macro and constant |
1470 |
|
names).")) |
1471 |
|
:type 'c-extra-types-widget |
1472 |
|
:group 'c) |
1473 |
|
|
1474 |
|
|
1475 |
;; Non-customizable variables, still part of the interface to CC Mode |
;; Non-customizable variables, still part of the interface to CC Mode |
1494 |
as designated in the variable `c-file-style'.") |
as designated in the variable `c-file-style'.") |
1495 |
(make-variable-buffer-local 'c-file-offsets) |
(make-variable-buffer-local 'c-file-offsets) |
1496 |
|
|
1497 |
(defvar c-syntactic-context nil |
;; It isn't possible to specify a docstring without specifying an |
1498 |
"Variable containing syntactic analysis list during indentation. |
;; initial value with `defvar', so the following two variables have |
1499 |
This is always bound dynamically. It should never be set statically |
;; only doc comments even though they are part of the API. It's |
1500 |
\(e.g. with `setq').") |
;; really good not to have an initial value for variables like these |
1501 |
|
;; that always should be dynamically bound, so it's worth the |
1502 |
|
;; inconvenience. |
1503 |
|
|
1504 |
|
(cc-bytecomp-defvar c-syntactic-context) |
1505 |
|
(defvar c-syntactic-context) |
1506 |
|
;; Variable containing the syntactic analysis list during indentation. |
1507 |
|
;; It is a list with one element for each found syntactic symbol. See |
1508 |
|
;; `c-syntactic-element' for further info. |
1509 |
|
;; |
1510 |
|
;; This is always bound dynamically. It should never be set |
1511 |
|
;; statically (e.g. with `setq'). |
1512 |
|
|
1513 |
|
(cc-bytecomp-defvar c-syntactic-element) |
1514 |
|
(defvar c-syntactic-element) |
1515 |
|
;; Variable containing the info regarding the current syntactic |
1516 |
|
;; element during calls to the lineup functions. The value is one of |
1517 |
|
;; the elements in the list in `c-syntactic-context' and is a list |
1518 |
|
;; with the symbol name in the first position, followed by zero or |
1519 |
|
;; more elements containing any additional info associated with the |
1520 |
|
;; syntactic symbol. There are accessor functions `c-langelem-sym', |
1521 |
|
;; `c-langelem-pos', `c-langelem-col', and `c-langelem-2nd-pos' to |
1522 |
|
;; access the list. |
1523 |
|
;; |
1524 |
|
;; Specifically, the element returned by `c-langelem-pos' is the |
1525 |
|
;; relpos (a.k.a. anchor position), or nil if there isn't any. See |
1526 |
|
;; the comments in the `c-offsets-alist' variable for more detailed |
1527 |
|
;; info about the data each syntactic symbol provides. |
1528 |
|
;; |
1529 |
|
;; This is always bound dynamically. It should never be set |
1530 |
|
;; statically (e.g. with `setq'). |
1531 |
|
|
1532 |
(defvar c-indentation-style nil |
(defvar c-indentation-style nil |
1533 |
"Name of the currently installed style. |
"Name of the currently installed style. |
1538 |
Set from `c-comment-prefix-regexp' at mode initialization.") |
Set from `c-comment-prefix-regexp' at mode initialization.") |
1539 |
(make-variable-buffer-local 'c-current-comment-prefix) |
(make-variable-buffer-local 'c-current-comment-prefix) |
1540 |
|
|
|
(defvar c-buffer-is-cc-mode nil |
|
|
"Non-nil for all buffers with a major mode derived from CC Mode. |
|
|
Otherwise, this variable is nil. I.e. this variable is non-nil for |
|
|
`c-mode', `c++-mode', `objc-mode', `java-mode', `idl-mode', |
|
|
`pike-mode', and any other non-CC Mode mode that calls |
|
|
`c-initialize-cc-mode' (e.g. `awk-mode'). The value is the mode |
|
|
symbol itself (i.e. `c-mode' etc) of the original CC Mode mode, or |
|
|
just t if it's not known.") |
|
|
(make-variable-buffer-local 'c-buffer-is-cc-mode) |
|
|
|
|
|
;; Have to make `c-buffer-is-cc-mode' permanently local so that it |
|
|
;; survives the initialization of the derived mode. |
|
|
(put 'c-buffer-is-cc-mode 'permanent-local t) |
|
|
|
|
1541 |
|
|
1542 |
;; Figure out what features this Emacs has |
;; Figure out what features this Emacs has |
1543 |
;;;###autoload |
|
1544 |
|
(cc-bytecomp-defvar open-paren-in-column-0-is-defun-start) |
1545 |
|
|
1546 |
(defconst c-emacs-features |
(defconst c-emacs-features |
1547 |
(let ((infodock-p (boundp 'infodock-version)) |
(let (list) |
1548 |
(comments |
|
1549 |
;; XEmacs 19 and beyond use 8-bit modify-syntax-entry flags. |
(if (boundp 'infodock-version) |
1550 |
;; Emacs 19 uses a 1-bit flag. We will have to set up our |
;; I've no idea what this actually is, but it's legacy. /mast |
1551 |
;; syntax tables differently to handle this. |
(setq list (cons 'infodock list))) |
1552 |
(let ((table (copy-syntax-table)) |
|
1553 |
entry) |
;; XEmacs 19 and beyond use 8-bit modify-syntax-entry flags. |
1554 |
(modify-syntax-entry ?a ". 12345678" table) |
;; Emacs 19 uses a 1-bit flag. We will have to set up our |
1555 |
(cond |
;; syntax tables differently to handle this. |
1556 |
;; XEmacs 19, and beyond Emacs 19.34 |
(let ((table (copy-syntax-table)) |
1557 |
((arrayp table) |
entry) |
1558 |
(setq entry (aref table ?a)) |
(modify-syntax-entry ?a ". 12345678" table) |
1559 |
;; In Emacs, table entries are cons cells |
(cond |
1560 |
(if (consp entry) (setq entry (car entry)))) |
;; XEmacs 19, and beyond Emacs 19.34 |
1561 |
;; XEmacs 20 |
((arrayp table) |
1562 |
((fboundp 'get-char-table) (setq entry (get-char-table ?a table))) |
(setq entry (aref table ?a)) |
1563 |
;; before and including Emacs 19.34 |
;; In Emacs, table entries are cons cells |
1564 |
((and (fboundp 'char-table-p) |
(if (consp entry) (setq entry (car entry)))) |
1565 |
(char-table-p table)) |
;; XEmacs 20 |
1566 |
(setq entry (car (char-table-range table [?a])))) |
((fboundp 'get-char-table) (setq entry (get-char-table ?a table))) |
1567 |
;; incompatible |
;; before and including Emacs 19.34 |
1568 |
(t (error "CC Mode is incompatible with this version of Emacs"))) |
((and (fboundp 'char-table-p) |
1569 |
(if (= (logand (lsh entry -16) 255) 255) |
(char-table-p table)) |
1570 |
'8-bit |
(setq entry (car (char-table-range table [?a])))) |
1571 |
'1-bit)))) |
;; incompatible |
1572 |
(if infodock-p |
(t (error "CC Mode is incompatible with this version of Emacs"))) |
1573 |
(list comments 'infodock) |
(setq list (cons (if (= (logand (lsh entry -16) 255) 255) |
1574 |
(list comments))) |
'8-bit |
1575 |
"A list of features extant in the Emacs you are using. |
'1-bit) |
1576 |
|
list))) |
1577 |
|
|
1578 |
|
(let ((buf (generate-new-buffer "test")) |
1579 |
|
parse-sexp-lookup-properties |
1580 |
|
parse-sexp-ignore-comments |
1581 |
|
lookup-syntax-properties) |
1582 |
|
(save-excursion |
1583 |
|
(set-buffer buf) |
1584 |
|
(set-syntax-table (make-syntax-table)) |
1585 |
|
|
1586 |
|
;; For some reason we have to set some of these after the |
1587 |
|
;; buffer has been made current. (Specifically, |
1588 |
|
;; `parse-sexp-ignore-comments' in Emacs 21.) |
1589 |
|
(setq parse-sexp-lookup-properties t |
1590 |
|
parse-sexp-ignore-comments t |
1591 |
|
lookup-syntax-properties t) |
1592 |
|
|
1593 |
|
;; Find out if the `syntax-table' text property works. |
1594 |
|
(modify-syntax-entry ?< ".") |
1595 |
|
(modify-syntax-entry ?> ".") |
1596 |
|
(insert "<()>") |
1597 |
|
(c-mark-<-as-paren 1) |
1598 |
|
(c-mark->-as-paren 4) |
1599 |
|
(goto-char 1) |
1600 |
|
(c-forward-sexp) |
1601 |
|
(if (= (point) 5) |
1602 |
|
(setq list (cons 'syntax-properties list))) |
1603 |
|
|
1604 |
|
;; Find out if generic comment delimiters work. |
1605 |
|
(c-safe |
1606 |
|
(modify-syntax-entry ?x "!") |
1607 |
|
(if (string-match "\\s!" "x") |
1608 |
|
(setq list (cons 'gen-comment-delim list)))) |
1609 |
|
|
1610 |
|
;; Find out if generic string delimiters work. |
1611 |
|
(c-safe |
1612 |
|
(modify-syntax-entry ?x "|") |
1613 |
|
(if (string-match "\\s|" "x") |
1614 |
|
(setq list (cons 'gen-string-delim list)))) |
1615 |
|
|
1616 |
|
;; See if `open-paren-in-column-0-is-defun-start' exists and |
1617 |
|
;; isn't buggy. |
1618 |
|
(when (boundp 'open-paren-in-column-0-is-defun-start) |
1619 |
|
(let ((open-paren-in-column-0-is-defun-start nil) |
1620 |
|
(parse-sexp-ignore-comments t)) |
1621 |
|
(set-syntax-table (make-syntax-table)) |
1622 |
|
(modify-syntax-entry ?\' "\"") |
1623 |
|
(cond |
1624 |
|
;; XEmacs. Afaik this is currently an Emacs-only |
1625 |
|
;; feature, but it's good to be prepared. |
1626 |
|
((memq '8-bit list) |
1627 |
|
(modify-syntax-entry ?/ ". 1456") |
1628 |
|
(modify-syntax-entry ?* ". 23")) |
1629 |
|
;; Emacs |
1630 |
|
((memq '1-bit list) |
1631 |
|
(modify-syntax-entry ?/ ". 124b") |
1632 |
|
(modify-syntax-entry ?* ". 23"))) |
1633 |
|
(modify-syntax-entry ?\n "> b") |
1634 |
|
(insert "/* '\n () */") |
1635 |
|
(backward-sexp) |
1636 |
|
(if (bobp) |
1637 |
|
(setq list (cons 'col-0-paren list)))) |
1638 |
|
(kill-buffer buf)) |
1639 |
|
|
1640 |
|
(set-buffer-modified-p nil)) |
1641 |
|
(kill-buffer buf)) |
1642 |
|
|
1643 |
|
;; See if `parse-partial-sexp' returns the eighth element. |
1644 |
|
(when (c-safe (>= (length (save-excursion (parse-partial-sexp 1 1))) 10)) |
1645 |
|
(setq list (cons 'pps-extended-state list))) |
1646 |
|
|
1647 |
|
;; See if POSIX char classes work. |
1648 |
|
(when (string-match "[[:alpha:]]" "a") |
1649 |
|
(setq list (cons 'posix-char-classes list))) |
1650 |
|
|
1651 |
|
list) |
1652 |
|
"A list of certain features in the (X)Emacs you are using. |
1653 |
There are many flavors of Emacs out there, each with different |
There are many flavors of Emacs out there, each with different |
1654 |
features supporting those needed by CC Mode. Here's the current |
features supporting those needed by CC Mode. The following values |
1655 |
supported list, along with the values for this variable: |
might be present: |
1656 |
|
|
1657 |
XEmacs 19, 20, 21: (8-bit) |
'8-bit 8 bit syntax entry flags (XEmacs style). |
1658 |
Emacs 19, 20: (1-bit) |
'1-bit 1 bit syntax entry flags (Emacs style). |
1659 |
|
'syntax-properties It works to override the syntax for specific characters |
1660 |
|
in the buffer with the 'syntax-table property. |
1661 |
|
'gen-comment-delim Generic comment delimiters work |
1662 |
|
(i.e. the syntax class `!'). |
1663 |
|
'gen-string-delim Generic string delimiters work |
1664 |
|
(i.e. the syntax class `|'). |
1665 |
|
'pps-extended-state `parse-partial-sexp' returns a list with at least 10 |
1666 |
|
elements, i.e. it contains the position of the |
1667 |
|
start of the last comment or string. |
1668 |
|
'posix-char-classes The regexp engine understands POSIX character classes. |
1669 |
|
'col-0-paren It's possible to turn off the ad-hoc rule that a paren |
1670 |
|
in column zero is the start of a defun. |
1671 |
|
'infodock This is Infodock (based on XEmacs). |
1672 |
|
|
1673 |
Infodock (based on XEmacs) has an additional symbol on this list: |
'8-bit and '1-bit are mutually exclusive.") |
|
`infodock'.") |
|
1674 |
|
|
1675 |
|
|
1676 |
(cc-provide 'cc-vars) |
(cc-provide 'cc-vars) |
1677 |
|
|
1678 |
|
;;; arch-tag: d62e9a55-c9fe-409b-b5b6-050b6aa202c9 |
1679 |
;;; cc-vars.el ends here |
;;; cc-vars.el ends here |