+;; The next two variables are bound to '(t) by `Custom-reset-standard'
+;; and `custom-group-reset-standard'. If these variables are nil, both
+;; `custom-variable-reset-standard' and `custom-face-reset-standard'
+;; save, reset and redraw the handled widget immediately. Otherwise,
+;; they add the widget to the corresponding list and leave it to
+;; `custom-reset-standard-save-and-update' to save, reset and redraw it.
+(defvar custom-reset-standard-variables-list nil)
+(defvar custom-reset-standard-faces-list nil)
+
+;; The next function was excerpted from `custom-variable-reset-standard'
+;; and `custom-face-reset-standard' and is used to avoid calling
+;; `custom-save-all' repeatedly (and thus saving settings to file one by
+;; one) when erasing all customizations.
+(defun custom-reset-standard-save-and-update ()
+ "Save settings and redraw after erasing customizations."
+ (when (or (and custom-reset-standard-variables-list
+ (not (eq custom-reset-standard-variables-list '(t))))
+ (and custom-reset-standard-faces-list
+ (not (eq custom-reset-standard-faces-list '(t)))))
+ ;; Save settings to file.
+ (custom-save-all)
+ ;; Set state of and redraw variables.
+ (dolist (widget custom-reset-standard-variables-list)
+ (unless (eq widget t)
+ (widget-put widget :custom-state 'unknown)
+ (custom-redraw widget)))
+ ;; Set state of and redraw faces.
+ (dolist (widget custom-reset-standard-faces-list)
+ (unless (eq widget t)
+ (let* ((symbol (widget-value widget))
+ (child (car (widget-get widget :children)))
+ (value (get symbol 'face-defface-spec))
+ (comment-widget (widget-get widget :comment-widget)))
+ (put symbol 'face-comment nil)
+ (widget-value-set child
+ (custom-pre-filter-face-spec
+ (list (list t (custom-face-attributes-get
+ symbol nil)))))
+ ;; This call manages the comment visibility
+ (widget-value-set comment-widget "")
+ (custom-face-state-set widget)
+ (custom-redraw-magic widget))))))
+