comparison lisp/progmodes/cc-langs.el @ 78354:d80d780fd6b4

Fix problem with modes derived from CC Mode: Move macro `c-make-emacs-variables-local' from cc-mode.el to cc-langs.el. Call it from c-make-init-lang-vars-fun (cc-langs.el) instead of c-init-language-vars-for (cc-mode.el).
author Alan Mackenzie <acm@muc.de>
date Sat, 28 Jul 2007 11:45:55 +0000
parents c1ec1c8a8d2e
children d9f04596fa48 539530fa389c
comparison
equal deleted inserted replaced
78353:ab2c093f31f9 78354:d80d780fd6b4
2873 ;; with the `c-lang-defvar' and `c-lang-setvar' macros. Note that the 2873 ;; with the `c-lang-defvar' and `c-lang-setvar' macros. Note that the
2874 ;; first element of each is nil. 2874 ;; first element of each is nil.
2875 (defconst c-lang-variable-inits (cc-eval-when-compile c-lang-variable-inits)) 2875 (defconst c-lang-variable-inits (cc-eval-when-compile c-lang-variable-inits))
2876 (defconst c-emacs-variable-inits (cc-eval-when-compile c-emacs-variable-inits)) 2876 (defconst c-emacs-variable-inits (cc-eval-when-compile c-emacs-variable-inits))
2877 2877
2878 ;; Make the `c-lang-setvar' variables buffer local in the current buffer.
2879 ;; These are typically standard emacs variables such as `comment-start'.
2880 (defmacro c-make-emacs-variables-local ()
2881 `(progn
2882 ,@(mapcar (lambda (init)
2883 `(make-local-variable ',(car init)))
2884 (cdr c-emacs-variable-inits))))
2885
2878 (defun c-make-init-lang-vars-fun (mode) 2886 (defun c-make-init-lang-vars-fun (mode)
2879 "Create a function that initializes all the language dependent variables 2887 "Create a function that initializes all the language dependent variables
2880 for the given mode. 2888 for the given mode.
2881 2889
2882 This function should be evaluated at compile time, so that the 2890 This function should be evaluated at compile time, so that the
2896 2904
2897 ;; This let sets up the context for `c-mode-var' and similar 2905 ;; This let sets up the context for `c-mode-var' and similar
2898 ;; that could be in the result from `cl-macroexpand-all'. 2906 ;; that could be in the result from `cl-macroexpand-all'.
2899 (let ((c-buffer-is-cc-mode ',mode) 2907 (let ((c-buffer-is-cc-mode ',mode)
2900 current-var source-eval) 2908 current-var source-eval)
2909 (c-make-emacs-variables-local)
2901 (condition-case err 2910 (condition-case err
2902 2911
2903 (if (eq c-version-sym ',c-version-sym) 2912 (if (eq c-version-sym ',c-version-sym)
2904 (setq ,@(let ((c-buffer-is-cc-mode mode) 2913 (setq ,@(let ((c-buffer-is-cc-mode mode)
2905 (c-lang-const-expansion 'immediate)) 2914 (c-lang-const-expansion 'immediate))
2954 (require 'cc-langs) 2963 (require 'cc-langs)
2955 (let ((c-buffer-is-cc-mode ',mode) 2964 (let ((c-buffer-is-cc-mode ',mode)
2956 (init (append (cdr c-emacs-variable-inits) 2965 (init (append (cdr c-emacs-variable-inits)
2957 (cdr c-lang-variable-inits))) 2966 (cdr c-lang-variable-inits)))
2958 current-var) 2967 current-var)
2968 (c-make-emacs-variables-local)
2959 (condition-case err 2969 (condition-case err
2960 2970
2961 (while init 2971 (while init
2962 (setq current-var (caar init)) 2972 (setq current-var (caar init))
2963 (set (caar init) (eval (cadar init))) 2973 (set (caar init) (eval (cadar init)))