Function: c-make-init-lang-vars-fun
c-make-init-lang-vars-fun is a byte-compiled function defined in
cc-langs.el.gz.
Signature
(c-make-init-lang-vars-fun MODE)
Documentation
Create a function that initializes all language dependent variables for MODE.
This function should be evaluated at compile time, so that the
function it returns is byte compiled with all the evaluated results
from the language constants. Use the c-init-language-vars macro to
accomplish that conveniently.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/cc-langs.el.gz
(defun c-make-init-lang-vars-fun (mode)
"Create a function that initializes all language dependent variables for MODE.
This function should be evaluated at compile time, so that the
function it returns is byte compiled with all the evaluated results
from the language constants. Use the `c-init-language-vars' macro to
accomplish that conveniently."
(if (cc-bytecomp-is-compiling)
;; No need to byte compile this lambda since the byte compiler is
;; smart enough to detect the `funcall' construct in the
;; `c-init-language-vars' macro below and compile it all straight
;; into the function that contains `c-init-language-vars'.
`(lambda ()
;; This let sets up the context for `c-mode-var' and similar
;; that could be in the result from `c--macroexpand-all'.
(let ((c-buffer-is-cc-mode ',mode)
current-var source-eval)
(c-make-emacs-variables-local)
(condition-case err
(if (eq c-version-sym ',c-version-sym)
(setq ,@(let ((c-buffer-is-cc-mode mode)
(c-lang-const-expansion 'immediate))
;; `c-lang-const' will expand to the evaluated
;; constant immediately in `c--macroexpand-all'
;; below.
(c--mapcan
(lambda (init)
`(current-var ',(car init)
,(car init) ,(c--macroexpand-all
(elt init 1))))
;; Note: The following `append' copies the
;; first argument. That list is small, so
;; this doesn't matter too much.
(append (cdr c-emacs-variable-inits)
(cdr c-lang-variable-inits)))))
;; This diagnostic message isn't useful for end
;; users, so it's disabled.
;;(unless (get ',mode 'c-has-warned-lang-consts)
;; (message ,(concat "%s compiled with CC Mode %s "
;; "but loaded with %s - evaluating "
;; "language constants from source")
;; ',mode ,c-version c-version)
;; (put ',mode 'c-has-warned-lang-consts t))
(setq source-eval t)
(let ((init ',(append (cdr c-emacs-variable-inits)
(cdr c-lang-variable-inits))))
(dolist (var-init init)
(setq current-var (car var-init))
(set (car var-init) (eval (cadr var-init))))))
(error
(if current-var
(message "Eval error in the `c-lang-defvar' or `c-lang-setvar' for `%s'%s: %S"
current-var
(if source-eval
(format "\
(fallback source eval - %s compiled with CC Mode %s but loaded with %s)"
',mode ,c-version c-version)
"")
err)
(signal (car err) (cdr err)))))))
;; Being evaluated from source. Always use the dynamic method to
;; work well when `c-lang-defvar's in this file are reevaluated
;; interactively.
`(lambda ()
(require 'cc-langs)
(let ((c-buffer-is-cc-mode ',mode)
(init (append (cdr c-emacs-variable-inits)
(cdr c-lang-variable-inits)))
current-var)
(c-make-emacs-variables-local)
(condition-case err
(dolist (var-init init)
(setq current-var (car var-init))
(set (car var-init) (eval (cadr var-init))))
(error
(if current-var
(message
"Eval error in the `c-lang-defvar' or `c-lang-setvar' for `%s' (source eval): %S"
current-var err)
(signal (car err) (cdr err)))))))
))