Function: c-lang-const
c-lang-const is a macro defined in cc-defs.el.gz.
Signature
(c-lang-const NAME &optional LANG)
Documentation
Get the mode specific value of the language constant NAME in language LANG.
LANG is the name of the language, i.e. the mode name without the
"-mode" suffix. If used inside c-lang-defconst or
c-lang-defvar, LANG may be left out to refer to the current
language. NAME and LANG are not evaluated so they should not be
quoted.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/cc-defs.el.gz
(defmacro c-lang-const (name &optional lang)
"Get the mode specific value of the language constant NAME in language LANG.
LANG is the name of the language, i.e. the mode name without the
\"-mode\" suffix. If used inside `c-lang-defconst' or
`c-lang-defvar', LANG may be left out to refer to the current
language. NAME and LANG are not evaluated so they should not be
quoted."
(declare (debug (name &optional symbolp)))
(or (symbolp name)
(error "Not a symbol: %S" name))
(or (symbolp lang)
(error "Not a symbol: %S" lang))
(let ((sym (intern (symbol-name name) c-lang-constants))
(mode (when lang (intern (concat (symbol-name lang) "-mode")))))
(or (get mode 'c-mode-prefix) (null mode)
(error "Unknown language %S: no `c-mode-prefix' property"
lang))
(if (eq c-lang-const-expansion 'immediate)
;; No need to find out the source file(s) when we evaluate
;; immediately since all the info is already there in the
;; `source' property.
`',(c-get-lang-constant name nil mode)
(let ((source-files
(let ((file (c-get-current-file)))
(if file (setq file (intern file)))
;; Get the source file(s) that must be loaded to get the value
;; of the constant. If the symbol isn't defined yet we assume
;; that its definition will come later in this file, and thus
;; are no file dependencies needed.
(nreverse
;; Reverse to get the right load order.
(c--mapcan (lambda (elem)
(if (eq file (car elem))
nil ; Exclude our own file.
(list (car elem))))
(get sym 'source)))))
;; Make some effort to do a compact call to
;; `c-get-lang-constant' since it will be compiled in.
(args (and mode `(',mode))))
(if (or source-files args)
(push (and source-files `',source-files) args))
(if (or (eq c-lang-const-expansion 'call)
(and (not c-lang-const-expansion)
(not mode))
(not (cc-bytecomp-is-compiling)))
;; Either a straight call is requested in the context, or
;; we're in an "uncontrolled" context and got no language,
;; or we're not being byte compiled so the compile time
;; stuff below is unnecessary.
`(c-get-lang-constant ',name ,@args)
;; Being compiled. If the loading and compiling version is
;; the same we use a value that is evaluated at compile time,
;; otherwise it's evaluated at runtime.
`(if (eq c-version-sym ',c-version-sym)
(cc-eval-when-compile
(c-get-lang-constant ',name ,@args))
(c-get-lang-constant ',name ,@args)))))))