[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/lisp/cus-edit.el
From: |
Richard M. Stallman |
Subject: |
[Emacs-diffs] Changes to emacs/lisp/cus-edit.el |
Date: |
Mon, 16 Sep 2002 11:20:21 -0400 |
Index: emacs/lisp/cus-edit.el
diff -c emacs/lisp/cus-edit.el:1.161 emacs/lisp/cus-edit.el:1.162
*** emacs/lisp/cus-edit.el:1.161 Sun Sep 8 20:26:14 2002
--- emacs/lisp/cus-edit.el Mon Sep 16 11:20:20 2002
***************
*** 2303,2308 ****
--- 2303,2311 ----
(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,2374 ****
--- 2372,2378 ----
(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,2383 ****
--- 2382,2388 ----
(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,2438 ****
(custom-redraw-magic widget)))
(defun custom-variable-reset-saved (widget)
! "Restore the saved value for the variable being edited by WIDGET."
(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)
(condition-case nil
(funcall set symbol (eval (car value)))
(error nil)))
--- 2431,2446 ----
(custom-redraw-magic widget)))
(defun custom-variable-reset-saved (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,2457 ****
(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."
(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))))
(error "No standard setting known for %S" symbol))
(put symbol 'variable-comment nil)
(put symbol 'customized-value nil)
--- 2455,2469 ----
(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.
! 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)
! (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)
***************
*** 2461,2466 ****
--- 2473,2514 ----
(put symbol 'saved-variable-comment nil)
(custom-save-all))
(widget-put widget :custom-state 'unknown)
+ ;; 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)))