diff options
| author | Chong Yidong | 2012-04-23 01:58:14 +0800 |
|---|---|---|
| committer | Chong Yidong | 2012-04-23 01:58:14 +0800 |
| commit | c2d1019e3540ffcace2cd72d46a1e85958c4d584 (patch) | |
| tree | 88ed67262d9ee0185045d5b9db8ce3ef78518066 | |
| parent | de85e130f59b5164e2150abda92316f3a07d82c0 (diff) | |
| download | emacs-c2d1019e3540ffcace2cd72d46a1e85958c4d584.tar.gz emacs-c2d1019e3540ffcace2cd72d46a1e85958c4d584.zip | |
Make the "reset-saved" Custom operation reset to default if there is no saved value.
* lisp/cus-edit.el (custom-variable-menu)
(custom-variable-reset-saved, custom-face-menu)
(custom-face-reset-saved): If there is no saved value, make the
"reset-saved" operation bring back the default.
(custom-face-state): Properly detect themed faces.
Fixes: debbugs:9509
| -rw-r--r-- | lisp/ChangeLog | 8 | ||||
| -rw-r--r-- | lisp/cus-edit.el | 90 |
2 files changed, 53 insertions, 45 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 334e34bb712..11cb03dea14 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2012-04-22 Chong Yidong <cyd@gnu.org> | ||
| 2 | |||
| 3 | * cus-edit.el (custom-variable-menu) | ||
| 4 | (custom-variable-reset-saved, custom-face-menu) | ||
| 5 | (custom-face-reset-saved): If there is no saved value, make the | ||
| 6 | "reset-saved" operation bring back the default (Bug#9509). | ||
| 7 | (custom-face-state): Properly detect themed faces. | ||
| 8 | |||
| 1 | 2012-04-22 Michael Albinus <michael.albinus@gmx.de> | 9 | 2012-04-22 Michael Albinus <michael.albinus@gmx.de> |
| 2 | 10 | ||
| 3 | Move functions from C to Lisp. Make non-blocking method calls | 11 | Move functions from C to Lisp. Make non-blocking method calls |
diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el index d20403ad341..924cbcddfc8 100644 --- a/lisp/cus-edit.el +++ b/lisp/cus-edit.el | |||
| @@ -2823,10 +2823,8 @@ If STATE is nil, the value is computed by `custom-variable-state'." | |||
| 2823 | (memq (widget-get widget :custom-state) '(modified changed))))) | 2823 | (memq (widget-get widget :custom-state) '(modified changed))))) |
| 2824 | ("Revert This Session's Customization" custom-variable-reset-saved | 2824 | ("Revert This Session's Customization" custom-variable-reset-saved |
| 2825 | (lambda (widget) | 2825 | (lambda (widget) |
| 2826 | (and (or (get (widget-value widget) 'saved-value) | 2826 | (memq (widget-get widget :custom-state) |
| 2827 | (get (widget-value widget) 'saved-variable-comment)) | 2827 | '(modified set changed rogue)))) |
| 2828 | (memq (widget-get widget :custom-state) | ||
| 2829 | '(modified set changed rogue))))) | ||
| 2830 | ,@(when (or custom-file init-file-user) | 2828 | ,@(when (or custom-file init-file-user) |
| 2831 | '(("Erase Customization" custom-variable-reset-standard | 2829 | '(("Erase Customization" custom-variable-reset-standard |
| 2832 | (lambda (widget) | 2830 | (lambda (widget) |
| @@ -2977,23 +2975,25 @@ Optional EVENT is the location for the menu." | |||
| 2977 | (custom-variable-state-set-and-redraw widget)) | 2975 | (custom-variable-state-set-and-redraw widget)) |
| 2978 | 2976 | ||
| 2979 | (defun custom-variable-reset-saved (widget) | 2977 | (defun custom-variable-reset-saved (widget) |
| 2980 | "Restore the saved value for the variable being edited by WIDGET. | 2978 | "Restore the value of the variable being edited by WIDGET. |
| 2981 | This also updates the buffer to show that value. | 2979 | If there is a saved value, restore it; otherwise reset to the |
| 2982 | The value that was current before this operation | 2980 | uncustomized (themed or standard) value. |
| 2983 | becomes the backup value, so you can get it again." | 2981 | |
| 2982 | Update the widget to show that value. The value that was current | ||
| 2983 | before this operation becomes the backup value." | ||
| 2984 | (let* ((symbol (widget-value widget)) | 2984 | (let* ((symbol (widget-value widget)) |
| 2985 | (set (or (get symbol 'custom-set) 'set-default)) | 2985 | (saved-value (get symbol 'saved-value)) |
| 2986 | (value (get symbol 'saved-value)) | ||
| 2987 | (comment (get symbol 'saved-variable-comment))) | 2986 | (comment (get symbol 'saved-variable-comment))) |
| 2988 | (cond ((or value comment) | 2987 | (custom-variable-backup-value widget) |
| 2989 | (put symbol 'variable-comment comment) | 2988 | (if (not (or saved-value comment)) |
| 2990 | (custom-variable-backup-value widget) | 2989 | ;; If there is no saved value, remove the setting. |
| 2991 | (custom-push-theme 'theme-value symbol 'user 'set (car-safe value)) | 2990 | (custom-push-theme 'theme-value symbol 'user 'reset) |
| 2992 | (condition-case nil | 2991 | ;; Otherwise, apply the saved value. |
| 2993 | (funcall set symbol (eval (car value))) | 2992 | (put symbol 'variable-comment comment) |
| 2994 | (error nil))) | 2993 | (custom-push-theme 'theme-value symbol 'user 'set (car-safe saved-value)) |
| 2995 | (t | 2994 | (ignore-errors |
| 2996 | (error "No saved value for %s" symbol))) | 2995 | (funcall (or (get symbol 'custom-set) 'set-default) |
| 2996 | symbol (eval (car saved-value))))) | ||
| 2997 | (put symbol 'customized-value nil) | 2997 | (put symbol 'customized-value nil) |
| 2998 | (put symbol 'customized-variable-comment nil) | 2998 | (put symbol 'customized-variable-comment nil) |
| 2999 | (widget-put widget :custom-state 'unknown) | 2999 | (widget-put widget :custom-state 'unknown) |
| @@ -3619,8 +3619,7 @@ the present value is saved to its :shown-value property instead." | |||
| 3619 | (memq (widget-get widget :custom-state) '(modified changed)))) | 3619 | (memq (widget-get widget :custom-state) '(modified changed)))) |
| 3620 | ("Revert This Session's Customization" custom-face-reset-saved | 3620 | ("Revert This Session's Customization" custom-face-reset-saved |
| 3621 | (lambda (widget) | 3621 | (lambda (widget) |
| 3622 | (or (get (widget-value widget) 'saved-face) | 3622 | (memq (widget-get widget :custom-state) '(modified set changed)))) |
| 3623 | (get (widget-value widget) 'saved-face-comment)))) | ||
| 3624 | ,@(when (or custom-file init-file-user) | 3623 | ,@(when (or custom-file init-file-user) |
| 3625 | '(("Erase Customization" custom-face-reset-standard | 3624 | '(("Erase Customization" custom-face-reset-standard |
| 3626 | (lambda (widget) | 3625 | (lambda (widget) |
| @@ -3675,18 +3674,17 @@ This is one of `set', `saved', `changed', `themed', or `rogue'." | |||
| 3675 | 'changed)) | 3674 | 'changed)) |
| 3676 | ((or (get face 'saved-face) | 3675 | ((or (get face 'saved-face) |
| 3677 | (get face 'saved-face-comment)) | 3676 | (get face 'saved-face-comment)) |
| 3678 | (if (equal (get face 'saved-face-comment) comment) | 3677 | (cond ((not (equal (get face 'saved-face-comment) comment)) |
| 3679 | (cond | 3678 | 'changed) |
| 3680 | ((eq 'user (caar (get face 'theme-face))) | 3679 | ((eq 'user (caar (get face 'theme-face))) |
| 3681 | 'saved) | 3680 | 'saved) |
| 3682 | ((eq 'changed (caar (get face 'theme-face))) | 3681 | ((eq 'changed (caar (get face 'theme-face))) |
| 3683 | 'changed) | 3682 | 'changed) |
| 3684 | (t 'themed)) | 3683 | (t 'themed))) |
| 3685 | 'changed)) | ||
| 3686 | ((get face 'face-defface-spec) | 3684 | ((get face 'face-defface-spec) |
| 3687 | (if (equal comment nil) | 3685 | (cond (comment 'changed) |
| 3688 | 'standard | 3686 | ((get face 'theme-face) 'themed) |
| 3689 | 'changed)) | 3687 | (t 'standard))) |
| 3690 | (t 'rogue)))) | 3688 | (t 'rogue)))) |
| 3691 | ;; If the user called set-face-attribute to change the default for | 3689 | ;; If the user called set-face-attribute to change the default for |
| 3692 | ;; new frames, this face is "set outside of Customize". | 3690 | ;; new frames, this face is "set outside of Customize". |
| @@ -3776,24 +3774,26 @@ Optional EVENT is the location for the menu." | |||
| 3776 | "22.1") | 3774 | "22.1") |
| 3777 | 3775 | ||
| 3778 | (defun custom-face-reset-saved (widget) | 3776 | (defun custom-face-reset-saved (widget) |
| 3779 | "Restore WIDGET to the face's default attributes." | 3777 | "Restore WIDGET to the face's default attributes. |
| 3780 | (let* ((symbol (widget-value widget)) | 3778 | If there is a saved face, restore it; otherwise reset to the |
| 3779 | uncustomized (themed or standard) face." | ||
| 3780 | (let* ((face (widget-value widget)) | ||
| 3781 | (child (car (widget-get widget :children))) | 3781 | (child (car (widget-get widget :children))) |
| 3782 | (value (get symbol 'saved-face)) | 3782 | (saved-face (get face 'saved-face)) |
| 3783 | (comment (get symbol 'saved-face-comment)) | 3783 | (comment (get face 'saved-face-comment)) |
| 3784 | (comment-widget (widget-get widget :comment-widget))) | 3784 | (comment-widget (widget-get widget :comment-widget))) |
| 3785 | (unless (or value comment) | 3785 | (put face 'customized-face nil) |
| 3786 | (error "No saved value for this face")) | 3786 | (put face 'customized-face-comment nil) |
| 3787 | (put symbol 'customized-face nil) | 3787 | (custom-push-theme 'theme-face face 'user |
| 3788 | (put symbol 'customized-face-comment nil) | 3788 | (if saved-face 'set 'reset) |
| 3789 | (custom-push-theme 'theme-face symbol 'user 'set value) | 3789 | saved-face) |
| 3790 | (face-spec-set symbol value t) | 3790 | (face-spec-set face saved-face t) |
| 3791 | (put symbol 'face-comment comment) | 3791 | (put face 'face-comment comment) |
| 3792 | (widget-value-set child value) | 3792 | (widget-value-set child saved-face) |
| 3793 | ;; This call manages the comment visibility | 3793 | ;; This call manages the comment visibility |
| 3794 | (widget-value-set comment-widget (or comment "")) | 3794 | (widget-value-set comment-widget (or comment "")) |
| 3795 | (custom-face-state-set widget) | 3795 | (custom-face-state-set widget) |
| 3796 | (custom-redraw-magic widget))) | 3796 | (custom-redraw widget))) |
| 3797 | 3797 | ||
| 3798 | (defun custom-face-standard-value (widget) | 3798 | (defun custom-face-standard-value (widget) |
| 3799 | (get (widget-value widget) 'face-defface-spec)) | 3799 | (get (widget-value widget) 'face-defface-spec)) |