Mercurial > emacs
comparison lisp/progmodes/cc-vars.el @ 91239:2fcaae6177a5
Merge from emacs--devo--0
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-300
author | Miles Bader <miles@gnu.org> |
---|---|
date | Sun, 16 Dec 2007 05:08:49 +0000 |
parents | 424b655804ca 8ced7f18a0a4 |
children | 56a72e2bd635 |
comparison
equal
deleted
inserted
replaced
91238:5cf14a2107b5 | 91239:2fcaae6177a5 |
---|---|
154 (defsubst c-set-stylevar-fallback (name val) | 154 (defsubst c-set-stylevar-fallback (name val) |
155 (put name 'c-stylevar-fallback val) | 155 (put name 'c-stylevar-fallback val) |
156 (setq c-fallback-style (cons (cons name val) c-fallback-style))) | 156 (setq c-fallback-style (cons (cons name val) c-fallback-style))) |
157 | 157 |
158 (defmacro defcustom-c-stylevar (name val doc &rest args) | 158 (defmacro defcustom-c-stylevar (name val doc &rest args) |
159 "Defines a style variable." | 159 "Define a style variable NAME with VAL and DOC. |
160 `(let ((-value- ,val)) | 160 More precisely, convert the given `:type FOO', mined out of ARGS, |
161 (c-set-stylevar-fallback ',name -value-) | 161 to an aggregate `:type (radio STYLE (PREAMBLE FOO))', append some |
162 (custom-declare-variable | 162 some boilerplate documentation to DOC, arrange for the fallback |
163 ',name ''set-from-style | 163 value of NAME to be VAL, and call `custom-declare-variable' to |
164 ,(concat doc " | 164 do the rest of the work. |
165 | |
166 STYLE stands for the choice where the value is taken from some | |
167 style setting. PREAMBLE is optionally prepended to FOO; that is, | |
168 if FOO contains :tag or :value, the respective two-element list | |
169 component is ignored." | |
170 (declare (debug (symbolp form stringp &rest))) | |
171 (let* ((expanded-doc (concat doc " | |
165 | 172 |
166 This is a style variable. Apart from the valid values described | 173 This is a style variable. Apart from the valid values described |
167 above, it can be set to the symbol `set-from-style'. In that case, it | 174 above, it can be set to the symbol `set-from-style'. In that case, |
168 takes its value from the style system (see `c-default-style' and | 175 it takes its value from the style system (see `c-default-style' and |
169 `c-style-alist') when a CC Mode buffer is initialized. Otherwise, | 176 `c-style-alist') when a CC Mode buffer is initialized. Otherwise, |
170 the value set here overrides the style system (there is a variable | 177 the value set here overrides the style system (there is a variable |
171 `c-old-style-variable-behavior' that changes this, though).") | 178 `c-old-style-variable-behavior' that changes this, though).")) |
172 ,@(plist-put | 179 (typ (eval (plist-get args :type))) |
173 args ':type | 180 (type (if (consp typ) typ (list typ))) |
174 `(` (radio | 181 (head (car type)) |
175 (const :tag "Use style settings" | 182 (tail (cdr type)) |
176 set-from-style) | 183 (newt (append (unless (plist-get tail :tag) |
177 ,(, (let ((type (eval (plist-get args ':type)))) | 184 '(:tag "Override style settings")) |
178 (unless (consp type) | 185 (unless (plist-get tail :value) |
179 (setq type (list type))) | 186 `(:value ,val)) |
180 (unless (c-safe (plist-get (cdr type) ':value)) | 187 tail)) |
181 (setcdr type (append '(:value (, -value-)) | 188 (aggregate `'(radio |
182 (cdr type)))) | 189 (const :tag "Use style settings" set-from-style) |
183 (unless (c-safe (plist-get (cdr type) ':tag)) | 190 ,(cons head newt)))) |
184 (setcdr type (append '(:tag "Override style settings") | 191 (message "aggregate: %S" aggregate) |
185 (cdr type)))) | 192 `(progn |
186 (bq-process type))))))))) | 193 (c-set-stylevar-fallback ',name ,val) |
194 (custom-declare-variable | |
195 ',name ''set-from-style | |
196 ,expanded-doc | |
197 ,@(plist-put args :type aggregate))))) | |
187 | 198 |
188 (defun c-valid-offset (offset) | 199 (defun c-valid-offset (offset) |
189 "Return non-nil if OFFSET is a valid offset for a syntactic symbol. | 200 "Return non-nil if OFFSET is a valid offset for a syntactic symbol. |
190 See `c-offsets-alist'." | 201 See `c-offsets-alist'." |
191 (or (eq offset '+) | 202 (or (eq offset '+) |