# HG changeset patch # User Richard M. Stallman # Date 1026826641 0 # Node ID ccaa90ab16a3ffa1390480c63bf570b307df3795 # Parent 4c43982491087cf973c0e50b4ef6cde4a1f4e436 New operation :custom-standard-value. (Custom-reset-standard): Use it. (custom-variable, custom-face): Define it. (custom-variable-standard-value, custom-face-standard-value): New fns. (custom-face-save): Don't save a face whose value is standard. (custom-save-faces): Use SYMBOL, not 'default, to set NOW and COMMENT. (custom-face-edit-fix-value): If VALUE is not a list, pass it thru. diff -r 4c4398249108 -r ccaa90ab16a3 lisp/cus-edit.el --- a/lisp/cus-edit.el Tue Jul 16 13:37:15 2002 +0000 +++ b/lisp/cus-edit.el Tue Jul 16 13:37:21 2002 +0000 @@ -698,7 +698,7 @@ (interactive) (let ((children custom-options)) (mapc (lambda (widget) - (and (get (widget-value widget) 'standard-value) + (and (widget-apply widget :custom-standard-value) (if (memq (widget-get widget :custom-state) '(modified set changed saved rogue)) (widget-apply widget :custom-reset-standard)))) @@ -2051,7 +2051,8 @@ :custom-save 'custom-variable-save :custom-reset-current 'custom-redraw :custom-reset-saved 'custom-variable-reset-saved - :custom-reset-standard 'custom-variable-reset-standard) + :custom-reset-standard 'custom-variable-reset-standard + :custom-standard-value 'custom-variable-standard-value) (defun custom-variable-type (symbol) "Return a widget suitable for editing the value of SYMBOL. @@ -2269,6 +2270,9 @@ (t 'rogue)))) (widget-put widget :custom-state state))) +(defun custom-variable-standard-value (widget) + (get (widget-value widget) 'standard-value)) + (defvar custom-variable-menu '(("Set for Current Session" custom-variable-set (lambda (widget) @@ -2475,22 +2479,24 @@ (defun custom-face-edit-fix-value (widget value) "Ignoring WIDGET, convert :bold and :italic in VALUE to new form." - (let (result) - (while value - (let ((key (car value)) - (val (car (cdr value)))) - (cond ((eq key :italic) - (push :slant result) - (push (if val 'italic 'normal) result)) - ((eq key :bold) - (push :weight result) - (push (if val 'bold 'normal) result)) - (t - (push key result) - (push val result)))) - (setq value (cdr (cdr value)))) - (setq result (nreverse result)) - result)) + (if (listp value) + (let (result) + (while value + (let ((key (car value)) + (val (car (cdr value)))) + (cond ((eq key :italic) + (push :slant result) + (push (if val 'italic 'normal) result)) + ((eq key :bold) + (push :weight result) + (push (if val 'bold 'normal) result)) + (t + (push key result) + (push val result)))) + (setq value (cdr (cdr value)))) + (setq result (nreverse result)) + result) + value)) (defun custom-face-edit-convert-widget (widget) "Convert :args as widget types in WIDGET." @@ -2662,6 +2668,7 @@ :custom-reset-current 'custom-redraw :custom-reset-saved 'custom-face-reset-saved :custom-reset-standard 'custom-face-reset-standard + :custom-standard-value 'custom-face-standard-value :custom-menu 'custom-face-menu-create) (define-widget 'custom-face-all 'editable-list @@ -2979,7 +2986,8 @@ ;; face-set-spec ignores empty attribute lists, so just give it ;; something harmless instead. (face-spec-set symbol '((t :foreground unspecified)))) - (put symbol 'saved-face value) + (unless (eq (widget-get widget :custom-state) 'standard) + (put symbol 'saved-face value)) (put symbol 'customized-face nil) (put symbol 'face-comment comment) (put symbol 'customized-face-comment nil) @@ -3007,6 +3015,9 @@ (custom-face-state-set widget) (custom-redraw-magic widget))) +(defun custom-face-standard-value (widget) + (get (widget-value widget) 'face-defface-spec)) + (defun custom-face-reset-standard (widget) "Restore WIDGET to the face's standard settings. This operation eliminates any saved setting for the face, @@ -3681,11 +3692,10 @@ (mapcar (lambda (symbol) (let ((value (get symbol 'saved-face)) - (now (not (or (get 'default 'face-defface-spec) - (and (not (custom-facep 'default)) - (not (get 'default 'force-face)))))) - (comment (get 'default 'saved-face-comment))) - (unless (eq symbol 'default)) + (now (not (or (get symbol 'face-defface-spec) + (and (not (custom-facep symbol)) + (not (get symbol 'force-face)))))) + (comment (get symbol 'saved-face-comment))) ;; Don't print default face here. (unless (bolp) (princ "\n"))