Function: c-add-language
c-add-language is a byte-compiled function defined in cc-defs.el.gz.
Signature
(c-add-language MODE BASE-MODE)
Documentation
Declare a new language in the language dependent variable system.
This is intended to be used by modes that inherit CC Mode to add new
languages. It should be used at the top level before any calls to
c-lang-defconst. MODE is the mode name symbol for the new language,
and BASE-MODE is the mode name symbol for the language in CC Mode that
is to be the template for the new mode.
The exact effect of BASE-MODE is to make all language constants that haven't got a setting in the new language fall back to their values in BASE-MODE. It does not have any effect outside the language constant system.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/cc-defs.el.gz
;;; System for handling language dependent constants.
;; This is used to set various language dependent data in a flexible
;; way: Language constants can be built from the values of other
;; language constants, also those for other languages. They can also
;; process the values of other language constants uniformly across all
;; the languages. E.g. one language constant can list all the type
;; keywords in each language, and another can build a regexp for each
;; language from those lists without code duplication.
;;
;; Language constants are defined with `c-lang-defconst', and their
;; value forms (referred to as source definitions) are evaluated only
;; on demand when requested for a particular language with
;; `c-lang-const'. It's therefore possible to refer to the values of
;; constants defined later in the file, or in another file, just as
;; long as all the relevant `c-lang-defconst' have been loaded when
;; `c-lang-const' is actually evaluated from somewhere else.
;;
;; `c-lang-const' forms are also evaluated at compile time and
;; replaced with the values they produce. Thus there's no overhead
;; for this system when compiled code is used - only the values
;; actually used in the code are present, and the file(s) containing
;; the `c-lang-defconst' forms don't need to be loaded at all then.
;; There are however safeguards to make sure that they can be loaded
;; to get the source definitions for the values if there's a mismatch
;; in compiled versions, or if `c-lang-const' is used uncompiled.
;;
;; Note that the source definitions in a `c-lang-defconst' form are
;; compiled into the .elc file where it stands; there's no need to
;; load the source file to get it.
;;
;; See cc-langs.el for more details about how this system is deployed
;; in CC Mode, and how the associated language variable system
;; (`c-lang-defvar') works. That file also contains a lot of
;; examples.
(defun c-add-language (mode base-mode)
"Declare a new language in the language dependent variable system.
This is intended to be used by modes that inherit CC Mode to add new
languages. It should be used at the top level before any calls to
`c-lang-defconst'. MODE is the mode name symbol for the new language,
and BASE-MODE is the mode name symbol for the language in CC Mode that
is to be the template for the new mode.
The exact effect of BASE-MODE is to make all language constants that
haven't got a setting in the new language fall back to their values in
BASE-MODE. It does not have any effect outside the language constant
system."
(unless (string-match "\\`\\(.*-\\)mode\\'" (symbol-name mode))
(error "The mode name symbol `%s' must end with \"-mode\"" mode))
(put mode 'c-mode-prefix (match-string 1 (symbol-name mode)))
(unless (get base-mode 'c-mode-prefix)
(error "Unknown base mode `%s'" base-mode))
(put mode 'c-fallback-mode base-mode))