Bugfixes for `customize-create-theme'.

* cus-theme.el (customize-create-theme): Delete overlays after
erasing.  If given a THEME arg, display only the faces of that arg
instead of custom-theme--listed-faces.
(custom-theme-variable-menu, custom-theme-variable-action)
(custom-variable-reset-theme, custom-theme-delete-variable): Deleted.
(custom-theme-add-variable, custom-theme-add-face): Apply value
from the theme settings, instead of the current value.
(custom-theme-add-var-1, custom-theme-add-face-1): New functions.
(custom-theme-visit-theme): Allow calling outside theme buffers.
(custom-theme-merge-theme): Don't enable the theme when merging.
(custom-theme-write-variables, custom-theme-write-faces): Use the
:shown-value properties to save buffer values, not global ones.
(customize-themes): Display a warning about user customizations.

* cus-edit.el (custom-variable-value-create)
(custom-face-value-create): Obey new special properties
:shown-value and :inhibit-magic.
This commit is contained in:
Chong Yidong 2010-10-15 20:16:34 -04:00
parent e3fc5b1907
commit da16abfc7e
3 changed files with 235 additions and 239 deletions

View file

@ -2460,7 +2460,13 @@ The following properties have special meanings for this widget:
:custom-form should be a symbol describing how to display and
edit the variable---either `edit' (using edit widgets),
`lisp' (as a Lisp sexp), or `mismatch' (should not happen);
if nil, use the return value of `custom-variable-default-form'."
if nil, use the return value of `custom-variable-default-form'.
:shown-value, if non-nil, should be a list whose `car' is the
variable value to display in place of the current value.
:inhibit-magic, if non-nil, inhibits creating the magic
custom-state widget."
:format "%v"
:help-echo "Set or reset this variable."
:documentation-property #'custom-variable-documentation
@ -2512,9 +2518,12 @@ try matching its doc string against `custom-guess-doc-alist'."
(get (or (get symbol 'custom-get) 'default-value))
(prefix (widget-get widget :custom-prefix))
(last (widget-get widget :custom-last))
(value (if (default-boundp symbol)
(funcall get symbol)
(widget-get conv :value)))
(value (let ((shown-value (widget-get widget :shown-value)))
(cond (shown-value
(car shown-value))
((default-boundp symbol)
(funcall get symbol))
(t (widget-get conv :value)))))
(state (or (widget-get widget :custom-state)
(if (memq (custom-variable-state symbol value)
(widget-get widget :hidden-states))
@ -2622,10 +2631,11 @@ try matching its doc string against `custom-guess-doc-alist'."
(unless (eq (preceding-char) ?\n)
(widget-insert "\n"))
;; Create the magic button.
(let ((magic (widget-create-child-and-convert
widget 'custom-magic nil)))
(widget-put widget :custom-magic magic)
(push magic buttons))
(unless (widget-get widget :inhibit-magic)
(let ((magic (widget-create-child-and-convert
widget 'custom-magic nil)))
(widget-put widget :custom-magic magic)
(push magic buttons)))
(widget-put widget :buttons buttons)
;; Insert documentation.
(widget-put widget :documentation-indent 3)
@ -3281,12 +3291,17 @@ The following properties have special meanings for this widget:
Lisp sexp), or `mismatch' (should not happen); if nil, use
the return value of `custom-face-default-form'.
:display-style, if non-nil, should be a symbol describing the
style of display to use. If the value is `concise', a more
concise interface is shown.
:display-style, if non-nil, describes the style of display to
use. If the value is `concise', a neater interface is shown.
:sample-indent, if non-nil, should be an integer; this is the
number of columns to which to indent the face sample."
:sample-indent, if non-nil, is the number of columns to which to
indent the face sample (an integer).
:shown-value, if non-nil, is the face spec to display as the value
of the widget, instead of the current face spec.
:inhibit-magic, if non-nil, inhibits creating the magic
custom-state widget."
:sample-face 'custom-face-tag
:help-echo "Set or reset this face."
:documentation-property #'face-doc-string
@ -3429,14 +3444,19 @@ WIDGET should be a `custom-face' widget."
(indent-to-column sample-indent)))
(push (widget-create-child-and-convert
widget 'item
:format "[%{%t%}]" :sample-face symbol :tag "sample")
:format "[%{%t%}]"
:sample-face (let ((spec (widget-get widget :shown-value)))
(if spec (face-spec-choose spec) symbol))
:tag "sample")
buttons)
;; Magic.
(insert "\n")
(let ((magic (widget-create-child-and-convert
widget 'custom-magic nil)))
(widget-put widget :custom-magic magic)
(push magic buttons))
;; Magic.
(unless (widget-get widget :inhibit-magic)
(let ((magic (widget-create-child-and-convert
widget 'custom-magic nil)))
(widget-put widget :custom-magic magic)
(push magic buttons)))
;; Update buttons.
(widget-put widget :buttons buttons)
@ -3465,7 +3485,8 @@ WIDGET should be a `custom-face' widget."
(unless (widget-get widget :custom-form)
(widget-put widget :custom-form custom-face-default-form))
(let* ((spec (custom-face-get-current-spec symbol))
(let* ((spec (or (widget-get widget :shown-value)
(custom-face-get-current-spec symbol)))
(form (widget-get widget :custom-form))
(indent (widget-get widget :indent))
face-alist face-entry spec-default spec-match editor)