128 |
;; (c-init-language-vars some-mode) |
;; (c-init-language-vars some-mode) |
129 |
;; (c-common-init 'some-mode) ; Or perhaps (c-basic-common-init 'some-mode) |
;; (c-common-init 'some-mode) ; Or perhaps (c-basic-common-init 'some-mode) |
130 |
;; |
;; |
131 |
|
;; If you're not writing a derived mode using the language variable |
132 |
|
;; system, then some-mode is one of the language modes directly |
133 |
|
;; supported by CC Mode. You can then use (c-init-language-vars-for |
134 |
|
;; 'some-mode) instead of `c-init-language-vars'. |
135 |
|
;; `c-init-language-vars-for' is a function that avoids the rather |
136 |
|
;; large expansion of `c-init-language-vars'. |
137 |
|
;; |
138 |
|
;; If you use `c-basic-common-init' then you might want to call |
139 |
|
;; `c-font-lock-init' too to set up CC Mode's font lock support. |
140 |
|
;; |
141 |
;; See cc-langs.el for further info. A small example of a derived mode |
;; See cc-langs.el for further info. A small example of a derived mode |
142 |
;; is also available at <http://cc-mode.sourceforge.net/ |
;; is also available at <http://cc-mode.sourceforge.net/ |
143 |
;; derived-mode-ex.el>. |
;; derived-mode-ex.el>. |
145 |
(defun c-leave-cc-mode-mode () |
(defun c-leave-cc-mode-mode () |
146 |
(setq c-buffer-is-cc-mode nil)) |
(setq c-buffer-is-cc-mode nil)) |
147 |
|
|
148 |
|
(defun c-init-language-vars-for (mode) |
149 |
|
"Initialize the language variables for one of the language modes |
150 |
|
directly supported by CC Mode. This can be used instead of the |
151 |
|
`c-init-language-vars' macro if the language you want to use is one of |
152 |
|
those, rather than a derived language defined through the language |
153 |
|
variable system (see \"cc-langs.el\")." |
154 |
|
;; This function does not do any hidden buffer changes. |
155 |
|
(cond ((eq mode 'c-mode) (c-init-language-vars c-mode)) |
156 |
|
((eq mode 'c++-mode) (c-init-language-vars c++-mode)) |
157 |
|
((eq mode 'objc-mode) (c-init-language-vars objc-mode)) |
158 |
|
((eq mode 'java-mode) (c-init-language-vars java-mode)) |
159 |
|
((eq mode 'idl-mode) (c-init-language-vars idl-mode)) |
160 |
|
((eq mode 'pike-mode) (c-init-language-vars pike-mode)) |
161 |
|
((eq mode 'awk-mode) (c-init-language-vars awk-mode)) |
162 |
|
(t (error "Unsupported mode %s" mode)))) |
163 |
|
|
164 |
;;;###autoload |
;;;###autoload |
165 |
(defun c-initialize-cc-mode (&optional new-style-init) |
(defun c-initialize-cc-mode (&optional new-style-init) |
166 |
"Initialize CC Mode for use in the current buffer. |
"Initialize CC Mode for use in the current buffer. |
167 |
If the optional NEW-STYLE-INIT is nil or left out then all necessary |
If the optional NEW-STYLE-INIT is nil or left out then all necessary |
168 |
initialization to run CC Mode for the C language is done. Otherwise |
initialization to run CC Mode for the C language is done. Otherwise |
169 |
only some basic setup is done, and a call to `c-init-language-vars', |
only some basic setup is done, and a call to `c-init-language-vars' or |
170 |
is necessary too (which gives more control). See \"cc-mode.el\" for |
`c-init-language-vars-for' is necessary too (which gives more |
171 |
more info." |
control). See \"cc-mode.el\" for more info." |
172 |
;; |
;; |
173 |
;; This function does not do any hidden buffer changes. |
;; This function does not do any hidden buffer changes. |
174 |
|
|
191 |
(put 'c-initialize-cc-mode initprop c-initialization-ok)))) |
(put 'c-initialize-cc-mode initprop c-initialization-ok)))) |
192 |
|
|
193 |
(unless new-style-init |
(unless new-style-init |
194 |
(c-init-c-language-vars))) |
(c-init-language-vars-for 'c-mode))) |
195 |
|
|
196 |
|
|
197 |
;;; Common routines. |
;;; Common routines. |
545 |
(unless mode |
(unless mode |
546 |
;; Called from an old third party package. The fallback is to |
;; Called from an old third party package. The fallback is to |
547 |
;; initialize for C. |
;; initialize for C. |
548 |
(c-init-c-language-vars)) |
(c-init-language-vars-for 'c-mode)) |
549 |
|
|
550 |
(c-basic-common-init mode c-default-style) |
(c-basic-common-init mode c-default-style) |
551 |
(when mode |
(when mode |
641 |
;;;###autoload (add-to-list 'auto-mode-alist '("\\.y\\(acc\\)?\\'" . c-mode)) |
;;;###autoload (add-to-list 'auto-mode-alist '("\\.y\\(acc\\)?\\'" . c-mode)) |
642 |
;;;###autoload (add-to-list 'auto-mode-alist '("\\.lex\\'" . c-mode)) |
;;;###autoload (add-to-list 'auto-mode-alist '("\\.lex\\'" . c-mode)) |
643 |
|
|
|
(defun c-init-c-language-vars () |
|
|
(c-init-language-vars c-mode)) |
|
|
|
|
644 |
;;;###autoload |
;;;###autoload |
645 |
(defun c-mode () |
(defun c-mode () |
646 |
"Major mode for editing K&R and ANSI C code. |
"Major mode for editing K&R and ANSI C code. |
665 |
local-abbrev-table c-mode-abbrev-table |
local-abbrev-table c-mode-abbrev-table |
666 |
abbrev-mode t) |
abbrev-mode t) |
667 |
(use-local-map c-mode-map) |
(use-local-map c-mode-map) |
668 |
(c-init-c-language-vars) |
(c-init-language-vars-for 'c-mode) |
669 |
(c-common-init 'c-mode) |
(c-common-init 'c-mode) |
670 |
(easy-menu-add c-c-menu) |
(easy-menu-add c-c-menu) |
671 |
(cc-imenu-init cc-imenu-c-generic-expression) |
(cc-imenu-init cc-imenu-c-generic-expression) |
729 |
local-abbrev-table c++-mode-abbrev-table |
local-abbrev-table c++-mode-abbrev-table |
730 |
abbrev-mode t) |
abbrev-mode t) |
731 |
(use-local-map c++-mode-map) |
(use-local-map c++-mode-map) |
732 |
(c-init-language-vars c++-mode) |
(c-init-language-vars-for 'c++-mode) |
733 |
(c-common-init 'c++-mode) |
(c-common-init 'c++-mode) |
734 |
(easy-menu-add c-c++-menu) |
(easy-menu-add c-c++-menu) |
735 |
(cc-imenu-init cc-imenu-c++-generic-expression) |
(cc-imenu-init cc-imenu-c++-generic-expression) |
794 |
;; end of the @-style directives. |
;; end of the @-style directives. |
795 |
(setq c-type-decl-end-used t) |
(setq c-type-decl-end-used t) |
796 |
(use-local-map objc-mode-map) |
(use-local-map objc-mode-map) |
797 |
(c-init-language-vars objc-mode) |
(c-init-language-vars-for 'objc-mode) |
798 |
(c-common-init 'objc-mode) |
(c-common-init 'objc-mode) |
799 |
(easy-menu-add c-objc-menu) |
(easy-menu-add c-objc-menu) |
800 |
(cc-imenu-init nil 'cc-imenu-objc-function) |
(cc-imenu-init nil 'cc-imenu-objc-function) |
865 |
local-abbrev-table java-mode-abbrev-table |
local-abbrev-table java-mode-abbrev-table |
866 |
abbrev-mode t) |
abbrev-mode t) |
867 |
(use-local-map java-mode-map) |
(use-local-map java-mode-map) |
868 |
(c-init-language-vars java-mode) |
(c-init-language-vars-for 'java-mode) |
869 |
(c-common-init 'java-mode) |
(c-common-init 'java-mode) |
870 |
(easy-menu-add c-java-menu) |
(easy-menu-add c-java-menu) |
871 |
(cc-imenu-init cc-imenu-java-generic-expression) |
(cc-imenu-init cc-imenu-java-generic-expression) |
924 |
mode-name "IDL" |
mode-name "IDL" |
925 |
local-abbrev-table idl-mode-abbrev-table) |
local-abbrev-table idl-mode-abbrev-table) |
926 |
(use-local-map idl-mode-map) |
(use-local-map idl-mode-map) |
927 |
(c-init-language-vars idl-mode) |
(c-init-language-vars-for 'idl-mode) |
928 |
(c-common-init 'idl-mode) |
(c-common-init 'idl-mode) |
929 |
(easy-menu-add c-idl-menu) |
(easy-menu-add c-idl-menu) |
930 |
;;(cc-imenu-init cc-imenu-idl-generic-expression) ;TODO |
;;(cc-imenu-init cc-imenu-idl-generic-expression) ;TODO |
987 |
local-abbrev-table pike-mode-abbrev-table |
local-abbrev-table pike-mode-abbrev-table |
988 |
abbrev-mode t) |
abbrev-mode t) |
989 |
(use-local-map pike-mode-map) |
(use-local-map pike-mode-map) |
990 |
(c-init-language-vars pike-mode) |
(c-init-language-vars-for 'pike-mode) |
991 |
(c-common-init 'pike-mode) |
(c-common-init 'pike-mode) |
992 |
(easy-menu-add c-pike-menu) |
(easy-menu-add c-pike-menu) |
993 |
;;(cc-imenu-init cc-imenu-pike-generic-expression) ;TODO |
;;(cc-imenu-init cc-imenu-pike-generic-expression) ;TODO |
1062 |
local-abbrev-table awk-mode-abbrev-table |
local-abbrev-table awk-mode-abbrev-table |
1063 |
abbrev-mode t) |
abbrev-mode t) |
1064 |
(use-local-map awk-mode-map) |
(use-local-map awk-mode-map) |
1065 |
(c-init-language-vars awk-mode) |
(c-init-language-vars-for 'awk-mode) |
1066 |
(c-common-init 'awk-mode) |
(c-common-init 'awk-mode) |
1067 |
;; The rest of CC Mode does not (yet) use `font-lock-syntactic-keywords', |
;; The rest of CC Mode does not (yet) use `font-lock-syntactic-keywords', |
1068 |
;; so it's not set by `c-font-lock-init'. |
;; so it's not set by `c-font-lock-init'. |