Commit 6e4fcd29 authored by Glenn Morris's avatar Glenn Morris
Browse files

(defcustom-c-stylevar): Revert previous change (merge mistake).

parent 26dac56c
...@@ -156,34 +156,44 @@ Useful as last item in a `choice' widget." ...@@ -156,34 +156,44 @@ Useful as last item in a `choice' widget."
(setq c-fallback-style (cons (cons name val) c-fallback-style))) (setq c-fallback-style (cons (cons name val) c-fallback-style)))
(defmacro defcustom-c-stylevar (name val doc &rest args) (defmacro defcustom-c-stylevar (name val doc &rest args)
"Defines a style variable." "Define a style variable NAME with VAL and DOC.
`(let ((-value- ,val)) More precisely, convert the given `:type FOO', mined out of ARGS,
(c-set-stylevar-fallback ',name -value-) to an aggregate `:type (radio STYLE (PREAMBLE FOO))', append some
(custom-declare-variable some boilerplate documentation to DOC, arrange for the fallback
',name ''set-from-style value of NAME to be VAL, and call `custom-declare-variable' to
,(concat doc " do the rest of the work.
STYLE stands for the choice where the value is taken from some
style setting. PREAMBLE is optionally prepended to FOO; that is,
if FOO contains :tag or :value, the respective two-element list
component is ignored."
(declare (debug (symbolp form stringp &rest)))
(let* ((expanded-doc (concat doc "
This is a style variable. Apart from the valid values described This is a style variable. Apart from the valid values described
above, it can be set to the symbol `set-from-style'. In that case, it above, it can be set to the symbol `set-from-style'. In that case,
takes its value from the style system (see `c-default-style' and it takes its value from the style system (see `c-default-style' and
`c-style-alist') when a CC Mode buffer is initialized. Otherwise, `c-style-alist') when a CC Mode buffer is initialized. Otherwise,
the value set here overrides the style system (there is a variable the value set here overrides the style system (there is a variable
`c-old-style-variable-behavior' that changes this, though).") `c-old-style-variable-behavior' that changes this, though)."))
,@(plist-put (typ (eval (plist-get args :type)))
args ':type (type (if (consp typ) typ (list typ)))
`(` (radio (head (car type))
(const :tag "Use style settings" (tail (cdr type))
set-from-style) (newt (append (unless (plist-get tail :tag)
,(, (let ((type (eval (plist-get args ':type)))) '(:tag "Override style settings"))
(unless (consp type) (unless (plist-get tail :value)
(setq type (list type))) `(:value ,(eval val)))
(unless (c-safe (plist-get (cdr type) ':value)) tail))
(setcdr type (append '(:value (, -value-)) (aggregate `'(radio
(cdr type)))) (const :tag "Use style settings" set-from-style)
(unless (c-safe (plist-get (cdr type) ':tag)) ,(cons head newt))))
(setcdr type (append '(:tag "Override style settings") `(progn
(cdr type)))) (c-set-stylevar-fallback ',name ,val)
(bq-process type))))))))) (custom-declare-variable
',name ''set-from-style
,expanded-doc
,@(plist-put args :type aggregate)))))
(defun c-valid-offset (offset) (defun c-valid-offset (offset)
"Return non-nil if OFFSET is a valid offset for a syntactic symbol. "Return non-nil if OFFSET is a valid offset for a syntactic symbol.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment