Mercurial > emacs
changeset 47503:8b3fa993e0ad
(custom-variable-backup-value): New function.
(custom-variable-reset-backup): New function.
(custom-variable-menu): Add item for custom-variable-reset-backup.
(custom-variable-set, custom-variable-reset-saved)
(custom-variable-reset-standard): Call custom-variable-backup-value.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 16 Sep 2002 15:20:20 +0000 |
parents | e8faddf96f0f |
children | 77f6066f43b7 |
files | lisp/cus-edit.el |
diffstat | 1 files changed, 51 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/cus-edit.el Mon Sep 16 15:19:27 2002 +0000 +++ b/lisp/cus-edit.el Mon Sep 16 15:20:20 2002 +0000 @@ -2303,6 +2303,9 @@ (and (get (widget-value widget) 'standard-value) (memq (widget-get widget :custom-state) '(modified set changed saved rogue))))) + ("Use Backup Value" custom-variable-reset-backup + (lambda (widget) + (get (widget-value widget) 'backup-value))) ("---" ignore ignore) ("Add Comment" custom-comment-show custom-comment-invisible-p) ("---" ignore ignore) @@ -2369,6 +2372,7 @@ (setq comment nil) ;; Make the comment invisible by hand if it's empty (custom-comment-hide comment-widget)) + (custom-variable-backup-value widget) (funcall set symbol (eval (setq val (widget-value child)))) (put symbol 'customized-value (list val)) (put symbol 'variable-comment comment) @@ -2378,6 +2382,7 @@ (setq comment nil) ;; Make the comment invisible by hand if it's empty (custom-comment-hide comment-widget)) + (custom-variable-backup-value widget) (funcall set symbol (setq val (widget-value child))) (put symbol 'customized-value (list (custom-quote val))) (put symbol 'variable-comment comment) @@ -2426,13 +2431,16 @@ (custom-redraw-magic widget))) (defun custom-variable-reset-saved (widget) - "Restore the saved value for the variable being edited by WIDGET." + "Restore the saved value for the variable being edited by WIDGET. +The value that was current before this operation +becomes the backup value, so you can get it again." (let* ((symbol (widget-value widget)) (set (or (get symbol 'custom-set) 'set-default)) (value (get symbol 'saved-value)) (comment (get symbol 'saved-variable-comment))) (cond ((or value comment) (put symbol 'variable-comment comment) + (custom-variable-backup-value widget) (condition-case nil (funcall set symbol (eval (car value))) (error nil))) @@ -2447,11 +2455,15 @@ (defun custom-variable-reset-standard (widget) "Restore the standard setting for the variable being edited by WIDGET. This operation eliminates any saved setting for the variable, -restoring it to the state of a variable that has never been customized." +restoring it to the state of a variable that has never been customized. +The value that was current before this operation +becomes the backup value, so you can get it again." (let* ((symbol (widget-value widget)) (set (or (get symbol 'custom-set) 'set-default))) (if (get symbol 'standard-value) - (funcall set symbol (eval (car (get symbol 'standard-value)))) + (progn + (custom-variable-backup-value widget) + (funcall set symbol (eval (car (get symbol 'standard-value))))) (error "No standard setting known for %S" symbol)) (put symbol 'variable-comment nil) (put symbol 'customized-value nil) @@ -2464,6 +2476,42 @@ ;; This call will possibly make the comment invisible (custom-redraw widget))) +(defun custom-variable-backup-value (widget) + "Back up the current value for WIDGET's variable. +The backup value is kept in the car of the `backup-value' property." + (let* ((symbol (widget-value widget)) + (get (or (get symbol 'custom-get) 'default-value)) + (type (custom-variable-type symbol)) + (conv (widget-convert type)) + (value (if (default-boundp symbol) + (funcall get symbol) + (widget-get conv :value)))) + (put symbol 'backup-value (list value)))) + +(defun custom-variable-reset-backup (widget) + "Restore the backup value for the variable being edited by WIDGET. +The value that was current before this operation +becomes the backup value, so you can use this operation repeatedly +to switch between two values." + (let* ((symbol (widget-value widget)) + (set (or (get symbol 'custom-set) 'set-default)) + (value (get symbol 'backup-value)) + (comment-widget (widget-get widget :comment-widget)) + (comment (widget-value comment-widget))) + (if value + (progn + (custom-variable-backup-value widget) + (condition-case nil + (funcall set symbol (car value)) + (error nil))) + (error "No backup value for %s" symbol)) + (put symbol 'customized-value (list (car value))) + (put symbol 'variable-comment comment) + (put symbol 'customized-variable-comment comment) + (custom-variable-state-set widget) + ;; This call will possibly make the comment invisible + (custom-redraw widget))) + ;;; The `custom-face-edit' Widget. (define-widget 'custom-face-edit 'checklist