diff options
| author | Richard M. Stallman | 2002-12-23 18:40:24 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2002-12-23 18:40:24 +0000 |
| commit | c942535f88a7cb50e8df6795c7608c8a76df681b (patch) | |
| tree | 59696ee2bbef1df26422ae6e4459cacc7092ec7c | |
| parent | 31b0520f82b071e5c8a156fe4c08ad8d97d6a94d (diff) | |
| download | emacs-c942535f88a7cb50e8df6795c7608c8a76df681b.tar.gz emacs-c942535f88a7cb50e8df6795c7608c8a76df681b.zip | |
(customize-save-variable): Take themes into account.
(custom-variable-save): Take themes into account.
(custom-variable-reset-saved): Add comment-widget.
(custom-variable-reset-standard): Add comment-widget.
(custom-variable-reset-standard): Take themes into account.
(custom-face-save): Take themes into account.
(custom-face-reset-standard): Take themes into account.
(custom-save-variables): Take themes into account.
(custom-save-faces): Take themes into account.
(custom-save-faces): Take themes into account.
(custom-save-resets): New function.
(custom-save-loaded-themes): New function.
(customize-save-customized): Take themes into account.
| -rw-r--r-- | lisp/cus-edit.el | 131 |
1 files changed, 103 insertions, 28 deletions
diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el index c457d149d77..6d0b4225bf9 100644 --- a/lisp/cus-edit.el +++ b/lisp/cus-edit.el | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | ;; Copyright (C) 1996, 1997, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1996, 1997, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. |
| 4 | ;; | 4 | ;; |
| 5 | ;; Author: Per Abrahamsen <abraham@dina.kvl.dk> | 5 | ;; Author: Per Abrahamsen <abraham@dina.kvl.dk> |
| 6 | ;; Maintainer: FSF | ||
| 6 | ;; Keywords: help, faces | 7 | ;; Keywords: help, faces |
| 7 | 8 | ||
| 8 | ;; This file is part of GNU Emacs. | 9 | ;; This file is part of GNU Emacs. |
| @@ -25,7 +26,7 @@ | |||
| 25 | ;;; Commentary: | 26 | ;;; Commentary: |
| 26 | ;; | 27 | ;; |
| 27 | ;; This file implements the code to create and edit customize buffers. | 28 | ;; This file implements the code to create and edit customize buffers. |
| 28 | ;; | 29 | ;; |
| 29 | ;; See `custom.el'. | 30 | ;; See `custom.el'. |
| 30 | 31 | ||
| 31 | ;; No commands should have names starting with `custom-' because | 32 | ;; No commands should have names starting with `custom-' because |
| @@ -823,6 +824,7 @@ If given a prefix (or a COMMENT argument), also prompt for a comment." | |||
| 823 | current-prefix-arg)) | 824 | current-prefix-arg)) |
| 824 | (funcall (or (get variable 'custom-set) 'set-default) variable value) | 825 | (funcall (or (get variable 'custom-set) 'set-default) variable value) |
| 825 | (put variable 'saved-value (list (custom-quote value))) | 826 | (put variable 'saved-value (list (custom-quote value))) |
| 827 | (custom-push-theme 'theme-value variable 'user 'set (list (custom-quote value))) | ||
| 826 | (cond ((string= comment "") | 828 | (cond ((string= comment "") |
| 827 | (put variable 'variable-comment nil) | 829 | (put variable 'variable-comment nil) |
| 828 | (put variable 'saved-variable-comment nil)) | 830 | (put variable 'saved-variable-comment nil)) |
| @@ -1040,7 +1042,7 @@ version." | |||
| 1040 | (or (< major1 major2) | 1042 | (or (< major1 major2) |
| 1041 | (and (= major1 major2) | 1043 | (and (= major1 major2) |
| 1042 | (< minor1 minor2))))) | 1044 | (< minor1 minor2))))) |
| 1043 | 1045 | ||
| 1044 | ;;;###autoload | 1046 | ;;;###autoload |
| 1045 | (defalias 'customize-variable-other-window 'customize-option-other-window) | 1047 | (defalias 'customize-variable-other-window 'customize-option-other-window) |
| 1046 | 1048 | ||
| @@ -2430,6 +2432,8 @@ Optional EVENT is the location for the menu." | |||
| 2430 | ;; Make the comment invisible by hand if it's empty | 2432 | ;; Make the comment invisible by hand if it's empty |
| 2431 | (custom-comment-hide comment-widget)) | 2433 | (custom-comment-hide comment-widget)) |
| 2432 | (put symbol 'saved-value (list (widget-value child))) | 2434 | (put symbol 'saved-value (list (widget-value child))) |
| 2435 | (custom-push-theme 'theme-value symbol 'user | ||
| 2436 | 'set (list (widget-value child))) | ||
| 2433 | (funcall set symbol (eval (widget-value child))) | 2437 | (funcall set symbol (eval (widget-value child))) |
| 2434 | (put symbol 'variable-comment comment) | 2438 | (put symbol 'variable-comment comment) |
| 2435 | (put symbol 'saved-variable-comment comment)) | 2439 | (put symbol 'saved-variable-comment comment)) |
| @@ -2440,6 +2444,9 @@ Optional EVENT is the location for the menu." | |||
| 2440 | (custom-comment-hide comment-widget)) | 2444 | (custom-comment-hide comment-widget)) |
| 2441 | (put symbol 'saved-value | 2445 | (put symbol 'saved-value |
| 2442 | (list (custom-quote (widget-value child)))) | 2446 | (list (custom-quote (widget-value child)))) |
| 2447 | (custom-push-theme 'theme-value symbol 'user | ||
| 2448 | 'set (list (custom-quote (widget-value | ||
| 2449 | child)))) | ||
| 2443 | (funcall set symbol (widget-value child)) | 2450 | (funcall set symbol (widget-value child)) |
| 2444 | (put symbol 'variable-comment comment) | 2451 | (put symbol 'variable-comment comment) |
| 2445 | (put symbol 'saved-variable-comment comment))) | 2452 | (put symbol 'saved-variable-comment comment))) |
| @@ -2455,6 +2462,7 @@ The value that was current before this operation | |||
| 2455 | becomes the backup value, so you can get it again." | 2462 | becomes the backup value, so you can get it again." |
| 2456 | (let* ((symbol (widget-value widget)) | 2463 | (let* ((symbol (widget-value widget)) |
| 2457 | (set (or (get symbol 'custom-set) 'set-default)) | 2464 | (set (or (get symbol 'custom-set) 'set-default)) |
| 2465 | (comment-widget (widget-get widget :comment-widget)) | ||
| 2458 | (value (get symbol 'saved-value)) | 2466 | (value (get symbol 'saved-value)) |
| 2459 | (comment (get symbol 'saved-variable-comment))) | 2467 | (comment (get symbol 'saved-variable-comment))) |
| 2460 | (cond ((or value comment) | 2468 | (cond ((or value comment) |
| @@ -2478,7 +2486,8 @@ restoring it to the state of a variable that has never been customized. | |||
| 2478 | The value that was current before this operation | 2486 | The value that was current before this operation |
| 2479 | becomes the backup value, so you can get it again." | 2487 | becomes the backup value, so you can get it again." |
| 2480 | (let* ((symbol (widget-value widget)) | 2488 | (let* ((symbol (widget-value widget)) |
| 2481 | (set (or (get symbol 'custom-set) 'set-default))) | 2489 | (set (or (get symbol 'custom-set) 'set-default)) |
| 2490 | (comment-widget (widget-get widget :comment-widget))) | ||
| 2482 | (if (get symbol 'standard-value) | 2491 | (if (get symbol 'standard-value) |
| 2483 | (progn | 2492 | (progn |
| 2484 | (custom-variable-backup-value widget) | 2493 | (custom-variable-backup-value widget) |
| @@ -2489,6 +2498,11 @@ becomes the backup value, so you can get it again." | |||
| 2489 | (put symbol 'customized-variable-comment nil) | 2498 | (put symbol 'customized-variable-comment nil) |
| 2490 | (when (or (get symbol 'saved-value) (get symbol 'saved-variable-comment)) | 2499 | (when (or (get symbol 'saved-value) (get symbol 'saved-variable-comment)) |
| 2491 | (put symbol 'saved-value nil) | 2500 | (put symbol 'saved-value nil) |
| 2501 | (custom-push-theme 'theme-value symbol 'user 'reset 'standard) | ||
| 2502 | ;; As a special optimizations we do not (explictly) | ||
| 2503 | ;; save resets to standard when no theme set the value. | ||
| 2504 | (if (null (cdr (get symbol 'theme-value))) | ||
| 2505 | (put symbol 'theme-value nil)) | ||
| 2492 | (put symbol 'saved-variable-comment nil) | 2506 | (put symbol 'saved-variable-comment nil) |
| 2493 | (custom-save-all)) | 2507 | (custom-save-all)) |
| 2494 | (widget-put widget :custom-state 'unknown) | 2508 | (widget-put widget :custom-state 'unknown) |
| @@ -3073,6 +3087,7 @@ Optional EVENT is the location for the menu." | |||
| 3073 | (face-spec-set symbol '((t :foreground unspecified)))) | 3087 | (face-spec-set symbol '((t :foreground unspecified)))) |
| 3074 | (unless (eq (widget-get widget :custom-state) 'standard) | 3088 | (unless (eq (widget-get widget :custom-state) 'standard) |
| 3075 | (put symbol 'saved-face value)) | 3089 | (put symbol 'saved-face value)) |
| 3090 | (custom-push-theme 'theme-face symbol 'user 'set value) | ||
| 3076 | (put symbol 'customized-face nil) | 3091 | (put symbol 'customized-face nil) |
| 3077 | (put symbol 'face-comment comment) | 3092 | (put symbol 'face-comment comment) |
| 3078 | (put symbol 'customized-face-comment nil) | 3093 | (put symbol 'customized-face-comment nil) |
| @@ -3117,6 +3132,10 @@ restoring it to the state of a face that has never been customized." | |||
| 3117 | (put symbol 'customized-face-comment nil) | 3132 | (put symbol 'customized-face-comment nil) |
| 3118 | (when (or (get symbol 'saved-face) (get symbol 'saved-face-comment)) | 3133 | (when (or (get symbol 'saved-face) (get symbol 'saved-face-comment)) |
| 3119 | (put symbol 'saved-face nil) | 3134 | (put symbol 'saved-face nil) |
| 3135 | (custom-push-theme 'theme-face symbol 'user 'reset 'standard) | ||
| 3136 | ;; Do not explictly save resets to standards without themes. | ||
| 3137 | (if (null (cdr (get symbol 'theme-face))) | ||
| 3138 | (put symbol 'theme-face nil)) | ||
| 3120 | (put symbol 'saved-face-comment nil) | 3139 | (put symbol 'saved-face-comment nil) |
| 3121 | (custom-save-all)) | 3140 | (custom-save-all)) |
| 3122 | (face-spec-set symbol value) | 3141 | (face-spec-set symbol value) |
| @@ -3695,7 +3714,11 @@ or (if there were none) at the end of the buffer." | |||
| 3695 | (defun custom-save-variables () | 3714 | (defun custom-save-variables () |
| 3696 | "Save all customized variables in `custom-file'." | 3715 | "Save all customized variables in `custom-file'." |
| 3697 | (save-excursion | 3716 | (save-excursion |
| 3717 | (custom-save-delete 'custom-load-themes) | ||
| 3718 | (custom-save-delete 'custom-reset-variables) | ||
| 3698 | (custom-save-delete 'custom-set-variables) | 3719 | (custom-save-delete 'custom-set-variables) |
| 3720 | (custom-save-loaded-themes) | ||
| 3721 | (custom-save-resets 'theme-value 'custom-reset-variables nil) | ||
| 3699 | (let ((standard-output (current-buffer)) | 3722 | (let ((standard-output (current-buffer)) |
| 3700 | (saved-list (make-list 1 0)) | 3723 | (saved-list (make-list 1 0)) |
| 3701 | sort-fold-case) | 3724 | sort-fold-case) |
| @@ -3714,14 +3737,19 @@ or (if there were none) at the end of the buffer." | |||
| 3714 | ;; If there is more than one, they won't work right.\n") | 3737 | ;; If there is more than one, they won't work right.\n") |
| 3715 | (mapcar | 3738 | (mapcar |
| 3716 | (lambda (symbol) | 3739 | (lambda (symbol) |
| 3717 | (let ((value (get symbol 'saved-value)) | 3740 | (let ((spec (car-safe (get symbol 'theme-value))) |
| 3741 | (value (get symbol 'saved-value)) | ||
| 3718 | (requests (get symbol 'custom-requests)) | 3742 | (requests (get symbol 'custom-requests)) |
| 3719 | (now (not (or (get symbol 'standard-value) | 3743 | (now (not (or (get symbol 'standard-value) |
| 3720 | (and (not (boundp symbol)) | 3744 | (and (not (boundp symbol)) |
| 3721 | (not (get symbol 'force-value)))))) | 3745 | (not (eq (get symbol 'force-value) |
| 3746 | 'rogue)))))) | ||
| 3722 | (comment (get symbol 'saved-variable-comment)) | 3747 | (comment (get symbol 'saved-variable-comment)) |
| 3723 | sep) | 3748 | sep) |
| 3724 | (when (or value comment) | 3749 | (when (or (and spec |
| 3750 | (eq (nth 0 spec) 'user) | ||
| 3751 | (eq (nth 1 spec) 'set)) | ||
| 3752 | comment) | ||
| 3725 | (unless (bolp) | 3753 | (unless (bolp) |
| 3726 | (princ "\n")) | 3754 | (princ "\n")) |
| 3727 | (princ " '(") | 3755 | (princ " '(") |
| @@ -3758,7 +3786,9 @@ or (if there were none) at the end of the buffer." | |||
| 3758 | (defun custom-save-faces () | 3786 | (defun custom-save-faces () |
| 3759 | "Save all customized faces in `custom-file'." | 3787 | "Save all customized faces in `custom-file'." |
| 3760 | (save-excursion | 3788 | (save-excursion |
| 3789 | (custom-save-delete 'custom-reset-faces) | ||
| 3761 | (custom-save-delete 'custom-set-faces) | 3790 | (custom-save-delete 'custom-set-faces) |
| 3791 | (custom-save-resets 'theme-face 'custom-reset-faces '(default)) | ||
| 3762 | (let ((standard-output (current-buffer)) | 3792 | (let ((standard-output (current-buffer)) |
| 3763 | (saved-list (make-list 1 0)) | 3793 | (saved-list (make-list 1 0)) |
| 3764 | sort-fold-case) | 3794 | sort-fold-case) |
| @@ -3780,37 +3810,80 @@ or (if there were none) at the end of the buffer." | |||
| 3780 | ;; If there is more than one, they won't work right.\n") | 3810 | ;; If there is more than one, they won't work right.\n") |
| 3781 | (mapcar | 3811 | (mapcar |
| 3782 | (lambda (symbol) | 3812 | (lambda (symbol) |
| 3783 | (let ((value (get symbol 'saved-face)) | 3813 | (let ((theme-spec (car-safe (get symbol 'theme-face))) |
| 3814 | (value (get symbol 'saved-face)) | ||
| 3784 | (now (not (or (get symbol 'face-defface-spec) | 3815 | (now (not (or (get symbol 'face-defface-spec) |
| 3785 | (and (not (custom-facep symbol)) | 3816 | (and (not (custom-facep symbol)) |
| 3786 | (not (get symbol 'force-face)))))) | 3817 | (not (get symbol 'force-face)))))) |
| 3787 | (comment (get symbol 'saved-face-comment))) | 3818 | (comment (get symbol 'saved-face-comment))) |
| 3788 | ;; Don't print default face here. | 3819 | (when (or (and theme-spec |
| 3789 | (unless (bolp) | 3820 | (eq (nth 0 theme-spec) 'user) |
| 3790 | (princ "\n")) | 3821 | (eq (nth 1 theme-spec) 'set)) |
| 3791 | (princ " '(") | 3822 | comment) |
| 3792 | (prin1 symbol) | 3823 | ;; Don't print default face here. |
| 3793 | (princ " ") | 3824 | (unless (bolp) |
| 3794 | (prin1 value) | 3825 | (princ "\n")) |
| 3795 | (cond ((or now comment) | 3826 | (princ " '(") |
| 3796 | (princ " ") | 3827 | (prin1 symbol) |
| 3797 | (if now | 3828 | (princ " ") |
| 3798 | (princ "t") | 3829 | (prin1 value) |
| 3799 | (princ "nil")) | 3830 | (cond ((or now comment) |
| 3800 | (cond (comment | 3831 | (princ " ") |
| 3801 | (princ " ") | 3832 | (if now |
| 3802 | (prin1 comment) | 3833 | (princ "t") |
| 3803 | (princ ")")) | 3834 | (princ "nil")) |
| 3804 | (t | 3835 | (cond (comment |
| 3805 | (princ ")")))) | 3836 | (princ " ") |
| 3806 | (t | 3837 | (prin1 comment) |
| 3807 | (princ ")"))))) | 3838 | (princ ")")) |
| 3839 | (t | ||
| 3840 | (princ ")")))) | ||
| 3841 | (t | ||
| 3842 | (princ ")"))))))) | ||
| 3808 | saved-list) | 3843 | saved-list) |
| 3809 | (if (bolp) | 3844 | (if (bolp) |
| 3810 | (princ " ")) | 3845 | (princ " ")) |
| 3811 | (princ ")") | 3846 | (princ ")") |
| 3812 | (unless (looking-at "\n") | 3847 | (unless (looking-at "\n") |
| 3813 | (princ "\n"))))) | 3848 | (princ "\n")))) |
| 3849 | |||
| 3850 | (defun custom-save-resets (property setter special) | ||
| 3851 | (let (started-writing ignored-special) | ||
| 3852 | ;; (custom-save-delete setter) Done by caller | ||
| 3853 | (let ((standard-output (current-buffer)) | ||
| 3854 | (mapper `(lambda (object) | ||
| 3855 | (let ((spec (car-safe (get object (quote ,property))))) | ||
| 3856 | (when (and (not (memq object ignored-special)) | ||
| 3857 | (eq (nth 0 spec) 'user) | ||
| 3858 | (eq (nth 1 spec) 'reset)) | ||
| 3859 | ;; Do not write reset statements unless necessary. | ||
| 3860 | (unless started-writing | ||
| 3861 | (setq started-writing t) | ||
| 3862 | (unless (bolp) | ||
| 3863 | (princ "\n")) | ||
| 3864 | (princ "(") | ||
| 3865 | (princ (quote ,setter)) | ||
| 3866 | (princ "\n '(") | ||
| 3867 | (prin1 object) | ||
| 3868 | (princ " ") | ||
| 3869 | (prin1 (nth 3 spec)) | ||
| 3870 | (princ ")"))))))) | ||
| 3871 | (mapc mapper special) | ||
| 3872 | (setq ignored-special special) | ||
| 3873 | (mapatoms mapper) | ||
| 3874 | (when started-writing | ||
| 3875 | (princ ")\n"))))) | ||
| 3876 | |||
| 3877 | (defun custom-save-loaded-themes () | ||
| 3878 | (let ((themes (reverse (get 'user 'theme-loads-themes))) | ||
| 3879 | (standard-output (current-buffer))) | ||
| 3880 | (when themes | ||
| 3881 | (unless (bolp) (princ "\n")) | ||
| 3882 | (princ "(custom-load-themes") | ||
| 3883 | (mapc (lambda (theme) | ||
| 3884 | (princ "\n '") | ||
| 3885 | (prin1 theme)) themes) | ||
| 3886 | (princ " )\n")))) | ||
| 3814 | 3887 | ||
| 3815 | ;;;###autoload | 3888 | ;;;###autoload |
| 3816 | (defun customize-save-customized () | 3889 | (defun customize-save-customized () |
| @@ -3824,9 +3897,11 @@ or (if there were none) at the end of the buffer." | |||
| 3824 | (get symbol 'customized-variable-comment))) | 3897 | (get symbol 'customized-variable-comment))) |
| 3825 | (when face | 3898 | (when face |
| 3826 | (put symbol 'saved-face face) | 3899 | (put symbol 'saved-face face) |
| 3900 | (custom-push-theme 'theme-face symbol 'user 'set value) | ||
| 3827 | (put symbol 'customized-face nil)) | 3901 | (put symbol 'customized-face nil)) |
| 3828 | (when value | 3902 | (when value |
| 3829 | (put symbol 'saved-value value) | 3903 | (put symbol 'saved-value value) |
| 3904 | (custom-push-theme 'theme-value symbol 'user 'set value) | ||
| 3830 | (put symbol 'customized-value nil)) | 3905 | (put symbol 'customized-value nil)) |
| 3831 | (when variable-comment | 3906 | (when variable-comment |
| 3832 | (put symbol 'saved-variable-comment variable-comment) | 3907 | (put symbol 'saved-variable-comment variable-comment) |