Changeset 4131 for trunk/lisp/progmodes/cc-langs.el
- Timestamp:
- 07/29/06 07:48:34 (2 years ago)
- Files:
-
- trunk/lisp/progmodes/cc-langs.el (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lisp/progmodes/cc-langs.el
r4111 r4131 135 135 (eval-and-compile 136 136 ;; These are used to collect the init forms from the subsequent 137 ;; `c-lang-defvar'. They are used to build the lambda in 138 ;; `c-make-init-lang-vars-fun' below. 137 ;; `c-lang-defvar' and `c-lang-setvar'. They are used to build the 138 ;; lambda in `c-make-init-lang-vars-fun' below, and to build `defvar's 139 ;; and `make-variable-buffer-local's in cc-engine and 140 ;; `make-local-variable's in `c-init-language-vars-for'. 139 141 (defvar c-lang-variable-inits nil) 140 142 (defvar c-lang-variable-inits-tail nil) 141 143 (setq c-lang-variable-inits (list nil) 142 c-lang-variable-inits-tail c-lang-variable-inits)) 144 c-lang-variable-inits-tail c-lang-variable-inits) 145 (defvar c-emacs-variable-inits nil) 146 (defvar c-emacs-variable-inits-tail nil) 147 (setq c-emacs-variable-inits (list nil) 148 c-emacs-variable-inits-tail c-emacs-variable-inits)) 143 149 144 150 (defmacro c-lang-defvar (var val &optional doc) … … 169 175 (setcdr c-lang-variable-inits-tail (list (list var val doc))) 170 176 (setq c-lang-variable-inits-tail (cdr c-lang-variable-inits-tail)))) 177 178 ;; Return the symbol, like the other def* forms. 179 `',var) 180 181 (defmacro c-lang-setvar (var val) 182 "Causes the variable VAR to be made buffer local and to get set to the 183 value VAL. VAL is evaluated and assigned at mode initialization. More 184 precisely, VAL is evaluated and bound to VAR when the result from the 185 macro `c-init-language-vars' is evaluated. VAR is typically a standard 186 Emacs variable like `comment-start'. 187 188 `c-lang-const' is typically used in VAL to get the right value for the 189 language being initialized, and such calls will be macro expanded to 190 the evaluated constant value at compile time." 191 (let ((elem (assq var (cdr c-emacs-variable-inits)))) 192 (if elem 193 (setcdr elem (list val)) ; Maybe remove "list", sometime. 2006-07-19 194 (setcdr c-emacs-variable-inits-tail (list (list var val))) 195 (setq c-emacs-variable-inits-tail (cdr c-emacs-variable-inits-tail)))) 171 196 172 197 ;; Return the symbol, like the other def* forms. … … 1104 1129 ;; comments aren't entirely portable. 1105 1130 c "/* ") 1106 (c-lang-defvar comment-start (c-lang-const comment-start) 1107 'dont-doc) 1131 (c-lang-setvar comment-start (c-lang-const comment-start)) 1108 1132 1109 1133 (c-lang-defconst comment-end … … 1118 1142 (concat " " (c-lang-const c-block-comment-ender)) 1119 1143 "")) 1120 (c-lang-defvar comment-end (c-lang-const comment-end) 1121 'dont-doc) 1144 (c-lang-setvar comment-end (c-lang-const comment-end)) 1122 1145 1123 1146 (c-lang-defconst comment-start-skip … … 1135 1158 "\\|") 1136 1159 "\\)\\s *")) 1137 (c-lang-defvar comment-start-skip (c-lang-const comment-start-skip) 1138 'dont-doc) 1160 (c-lang-setvar comment-start-skip (c-lang-const comment-start-skip)) 1139 1161 1140 1162 (c-lang-defconst c-syntactic-ws-start … … 2807 2829 2808 2830 ;; Compile in the list of language variables that has been collected 2809 ;; with the `c-lang-defvar' macro. Note that the first element is2810 ;; nil.2831 ;; with the `c-lang-defvar' and `c-lang-setvar' macros. Note that the 2832 ;; first element of each is nil. 2811 2833 (defconst c-lang-variable-inits (cc-eval-when-compile c-lang-variable-inits)) 2834 (defconst c-emacs-variable-inits (cc-eval-when-compile c-emacs-variable-inits)) 2812 2835 2813 2836 (defun c-make-init-lang-vars-fun (mode) … … 2842 2865 ;; constant immediately in `cl-macroexpand-all' 2843 2866 ;; below. 2844 (mapcan 2845 (lambda (init) 2846 `(current-var ',(car init) 2847 ,(car init) ,(cl-macroexpand-all 2848 (elt init 1)))) 2849 (cdr c-lang-variable-inits)))) 2867 (mapcan 2868 (lambda (init) 2869 `(current-var ',(car init) 2870 ,(car init) ,(cl-macroexpand-all 2871 (elt init 1)))) 2872 ;; Note: The following `append' copies the 2873 ;; first argument. That list is small, so 2874 ;; this doesn't matter too much. 2875 (append (cdr c-emacs-variable-inits) 2876 (cdr c-lang-variable-inits))))) 2850 2877 2851 2878 ;; This diagnostic message isn't useful for end … … 2860 2887 (require 'cc-langs) 2861 2888 (setq source-eval t) 2862 (let ((init (cdr c-lang-variable-inits))) 2889 (let ((init (append (cdr c-emacs-variable-inits) 2890 (cdr c-lang-variable-inits)))) 2863 2891 (while init 2864 2892 (setq current-var (caar init)) … … 2868 2896 (error 2869 2897 (if current-var 2870 (message "Eval error in the `c-lang-defvar' for `%s'%s: %S"2898 (message "Eval error in the `c-lang-defvar' or `c-lang-setvar' for `%s'%s: %S" 2871 2899 current-var 2872 2900 (if source-eval … … 2884 2912 (require 'cc-langs) 2885 2913 (let ((c-buffer-is-cc-mode ',mode) 2886 (init (cdr c-lang-variable-inits)) 2914 (init (append (cdr c-emacs-variable-inits) 2915 (cdr c-lang-variable-inits))) 2887 2916 current-var) 2888 2917 (condition-case err … … 2896 2925 (if current-var 2897 2926 (message 2898 "Eval error in the `c-lang-defvar' for `%s' (source eval): %S"2927 "Eval error in the `c-lang-defvar' or `c-lang-setver' for `%s' (source eval): %S" 2899 2928 current-var err) 2900 2929 (signal (car err) (cdr err)))))))
