diff options
author | Martin Stjernholm <mast@lysator.liu.se> | 2003-08-03 12:31:46 +0000 |
---|---|---|
committer | Martin Stjernholm <mast@lysator.liu.se> | 2003-08-03 12:31:46 +0000 |
commit | 28d88c16bfd9fed7f3fdaee1bd4d33e4974aad10 (patch) | |
tree | 881a5da99ac45add2cb6db09ebbc62c44c2cdc52 /lisp/progmodes/cc-mode.el | |
parent | ff959bab84b1b459473293120e953599182efa9d (diff) | |
download | emacs-28d88c16bfd9fed7f3fdaee1bd4d33e4974aad10.tar.gz |
2003-08-03 Martin Stjernholm <bug-cc-mode@gnu.org>
* cc-mode.el (c-init-language-vars-for): Add argument MODE.
Renamed from c-init-c-language-vars'.
(c-initialize-cc-mode): Change accordingly.
(c-common-init): Ditto.
(c-mode): Ditto.
(c++-mode): Use function.
(objc-mode): Ditto.
(java-mode): Ditto.
(idl-mode): Ditto.
(pike-mode): Ditto.
(awk-mode): Ditto.
Diffstat (limited to 'lisp/progmodes/cc-mode.el')
-rw-r--r-- | lisp/progmodes/cc-mode.el | 53 |
1 files changed, 38 insertions, 15 deletions
diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el index 69bf72b258e..67ec33defbf 100644 --- a/lisp/progmodes/cc-mode.el +++ b/lisp/progmodes/cc-mode.el @@ -128,6 +128,16 @@ ;; (c-init-language-vars some-mode) ;; (c-common-init 'some-mode) ; Or perhaps (c-basic-common-init 'some-mode) ;; +;; If you're not writing a derived mode using the language variable +;; system, then some-mode is one of the language modes directly +;; supported by CC Mode. You can then use (c-init-language-vars-for +;; 'some-mode) instead of `c-init-language-vars'. +;; `c-init-language-vars-for' is a function that avoids the rather +;; large expansion of `c-init-language-vars'. +;; +;; If you use `c-basic-common-init' then you might want to call +;; `c-font-lock-init' too to set up CC Mode's font lock support. +;; ;; See cc-langs.el for further info. A small example of a derived mode ;; is also available at <http://cc-mode.sourceforge.net/ ;; derived-mode-ex.el>. @@ -135,14 +145,30 @@ (defun c-leave-cc-mode-mode () (setq c-buffer-is-cc-mode nil)) +(defun c-init-language-vars-for (mode) + "Initialize the language variables for one of the language modes +directly supported by CC Mode. This can be used instead of the +`c-init-language-vars' macro if the language you want to use is one of +those, rather than a derived language defined through the language +variable system (see \"cc-langs.el\")." + ;; This function does not do any hidden buffer changes. + (cond ((eq mode 'c-mode) (c-init-language-vars c-mode)) + ((eq mode 'c++-mode) (c-init-language-vars c++-mode)) + ((eq mode 'objc-mode) (c-init-language-vars objc-mode)) + ((eq mode 'java-mode) (c-init-language-vars java-mode)) + ((eq mode 'idl-mode) (c-init-language-vars idl-mode)) + ((eq mode 'pike-mode) (c-init-language-vars pike-mode)) + ((eq mode 'awk-mode) (c-init-language-vars awk-mode)) + (t (error "Unsupported mode %s" mode)))) + ;;;###autoload (defun c-initialize-cc-mode (&optional new-style-init) "Initialize CC Mode for use in the current buffer. If the optional NEW-STYLE-INIT is nil or left out then all necessary initialization to run CC Mode for the C language is done. Otherwise -only some basic setup is done, and a call to `c-init-language-vars', -is necessary too (which gives more control). See \"cc-mode.el\" for -more info." +only some basic setup is done, and a call to `c-init-language-vars' or +`c-init-language-vars-for' is necessary too (which gives more +control). See \"cc-mode.el\" for more info." ;; ;; This function does not do any hidden buffer changes. @@ -165,7 +191,7 @@ more info." (put 'c-initialize-cc-mode initprop c-initialization-ok)))) (unless new-style-init - (c-init-c-language-vars))) + (c-init-language-vars-for 'c-mode))) ;;; Common routines. @@ -519,7 +545,7 @@ This function does not do any hidden buffer changes." (unless mode ;; Called from an old third party package. The fallback is to ;; initialize for C. - (c-init-c-language-vars)) + (c-init-language-vars-for 'c-mode)) (c-basic-common-init mode c-default-style) (when mode @@ -615,9 +641,6 @@ Note that the style variables are always made local to the buffer." ;;;###autoload (add-to-list 'auto-mode-alist '("\\.y\\(acc\\)?\\'" . c-mode)) ;;;###autoload (add-to-list 'auto-mode-alist '("\\.lex\\'" . c-mode)) -(defun c-init-c-language-vars () - (c-init-language-vars c-mode)) - ;;;###autoload (defun c-mode () "Major mode for editing K&R and ANSI C code. @@ -642,7 +665,7 @@ Key bindings: local-abbrev-table c-mode-abbrev-table abbrev-mode t) (use-local-map c-mode-map) - (c-init-c-language-vars) + (c-init-language-vars-for 'c-mode) (c-common-init 'c-mode) (easy-menu-add c-c-menu) (cc-imenu-init cc-imenu-c-generic-expression) @@ -706,7 +729,7 @@ Key bindings: local-abbrev-table c++-mode-abbrev-table abbrev-mode t) (use-local-map c++-mode-map) - (c-init-language-vars c++-mode) + (c-init-language-vars-for 'c++-mode) (c-common-init 'c++-mode) (easy-menu-add c-c++-menu) (cc-imenu-init cc-imenu-c++-generic-expression) @@ -771,7 +794,7 @@ Key bindings: ;; end of the @-style directives. (setq c-type-decl-end-used t) (use-local-map objc-mode-map) - (c-init-language-vars objc-mode) + (c-init-language-vars-for 'objc-mode) (c-common-init 'objc-mode) (easy-menu-add c-objc-menu) (cc-imenu-init nil 'cc-imenu-objc-function) @@ -842,7 +865,7 @@ Key bindings: local-abbrev-table java-mode-abbrev-table abbrev-mode t) (use-local-map java-mode-map) - (c-init-language-vars java-mode) + (c-init-language-vars-for 'java-mode) (c-common-init 'java-mode) (easy-menu-add c-java-menu) (cc-imenu-init cc-imenu-java-generic-expression) @@ -901,7 +924,7 @@ Key bindings: mode-name "IDL" local-abbrev-table idl-mode-abbrev-table) (use-local-map idl-mode-map) - (c-init-language-vars idl-mode) + (c-init-language-vars-for 'idl-mode) (c-common-init 'idl-mode) (easy-menu-add c-idl-menu) ;;(cc-imenu-init cc-imenu-idl-generic-expression) ;TODO @@ -964,7 +987,7 @@ Key bindings: local-abbrev-table pike-mode-abbrev-table abbrev-mode t) (use-local-map pike-mode-map) - (c-init-language-vars pike-mode) + (c-init-language-vars-for 'pike-mode) (c-common-init 'pike-mode) (easy-menu-add c-pike-menu) ;;(cc-imenu-init cc-imenu-pike-generic-expression) ;TODO @@ -1039,7 +1062,7 @@ Key bindings: local-abbrev-table awk-mode-abbrev-table abbrev-mode t) (use-local-map awk-mode-map) - (c-init-language-vars awk-mode) + (c-init-language-vars-for 'awk-mode) (c-common-init 'awk-mode) ;; The rest of CC Mode does not (yet) use `font-lock-syntactic-keywords', ;; so it's not set by `c-font-lock-init'. |