comparison lisp/cus-edit.el @ 67977:03ee9bccbfeb

* custom.el: Move Custom Themes commentary to start of theme code. (custom-known-themes): Rename `standard' theme to `changed'. (custom-push-theme): Caller no longer specifies what theme to use when doing `reset'---the setting is simply removed from the theme. Delete MODE from `theme-value' and `theme-settings' properties. (custom-declare-theme): Ignore &rest args since we don't use them. (custom-loaded-themes): Delete variable. (custom-theme-load-themes, custom-theme-loaded-p) (custom-theme-value): Delete functions. (custom-declare-theme): Signal error on invalid theme names. (provide-theme): custom-loaded-themes was deleted. (load-theme): Load the file unconditionally. (enable-theme): Call `load-theme' if theme is undefined. (custom-enabled-themes): Only update value for successful loads. (disable-theme): Complete from enabled themes when interactive. (custom-variable-theme-value): Calculate theme value directly. (custom-theme-reset-variables, custom-reset-variables): Mark as XEmacs compatibility functions. We don't actually use these. * cus-edit.el (custom-variable-state-set): Use custom-variable-theme-value instead of custom-theme-value. (custom-face-state-set): Rename `standard' theme to `changed'. (custom-save-variables, custom-save-faces): Delete unneeded references to custom-reset-variables. (custom-save-resets): Delete function. (custom-save-variables, custom-save-faces): MODE argument deleted. (custom-save-variables, custom-save-faces): Ignore theme values. * cus-face.el (custom-theme-reset-faces): Mark as XEmacs compatibility function.
author Chong Yidong <cyd@stupidchicken.com>
date Mon, 02 Jan 2006 15:11:14 +0000
parents 078134944b46
children eea3a49a9d6c
comparison
equal deleted inserted replaced
67976:11f1a38de9af 67977:03ee9bccbfeb
2576 (setq temp (get symbol 'saved-variable-comment)) 2576 (setq temp (get symbol 'saved-variable-comment))
2577 (or tmp temp)) 2577 (or tmp temp))
2578 (if (condition-case nil 2578 (if (condition-case nil
2579 (and (equal comment temp) 2579 (and (equal comment temp)
2580 (equal value 2580 (equal value
2581 (eval (car 2581 (eval
2582 (custom-theme-value 2582 (car (custom-variable-theme-value
2583 (caar tmp) tmp))))) 2583 symbol)))))
2584 (error nil)) 2584 (error nil))
2585 (cond 2585 (cond
2586 ((eq 'user (caar (get symbol 'theme-value))) 2586 ((eq (caar tmp) 'user) 'saved)
2587 'saved) 2587 ((eq (caar tmp) 'changed) 'changed)
2588 ((eq 'standard (caar (get symbol 'theme-value)))
2589 'changed)
2590 (t 'themed)) 2588 (t 'themed))
2591 'changed)) 2589 'changed))
2592 ((setq tmp (get symbol 'standard-value)) 2590 ((setq tmp (get symbol 'standard-value))
2593 (if (condition-case nil 2591 (if (condition-case nil
2594 (and (equal value (eval (car tmp))) 2592 (and (equal value (eval (car tmp)))
2770 (value (get symbol 'saved-value)) 2768 (value (get symbol 'saved-value))
2771 (comment (get symbol 'saved-variable-comment))) 2769 (comment (get symbol 'saved-variable-comment)))
2772 (cond ((or value comment) 2770 (cond ((or value comment)
2773 (put symbol 'variable-comment comment) 2771 (put symbol 'variable-comment comment)
2774 (custom-variable-backup-value widget) 2772 (custom-variable-backup-value widget)
2775 (custom-push-theme 'theme-value symbol 'user 'set value) 2773 (custom-push-theme 'theme-value symbol 'user 'set (car-safe value))
2776 (condition-case nil 2774 (condition-case nil
2777 (funcall set symbol (eval (car value))) 2775 (funcall set symbol (eval (car value)))
2778 (error nil))) 2776 (error nil)))
2779 (t 2777 (t
2780 (error "No saved value for %s" symbol))) 2778 (error "No saved value for %s" symbol)))
2788 "Restore the standard setting for the variable being edited by WIDGET. 2786 "Restore the standard setting for the variable being edited by WIDGET.
2789 This operation eliminates any saved setting for the variable, 2787 This operation eliminates any saved setting for the variable,
2790 restoring it to the state of a variable that has never been customized. 2788 restoring it to the state of a variable that has never been customized.
2791 The value that was current before this operation 2789 The value that was current before this operation
2792 becomes the backup value, so you can get it again." 2790 becomes the backup value, so you can get it again."
2793 (let* ((symbol (widget-value widget)) 2791 (let* ((symbol (widget-value widget)))
2794 (set (or (get symbol 'custom-set) 'set-default)))
2795 (if (get symbol 'standard-value) 2792 (if (get symbol 'standard-value)
2796 (custom-variable-backup-value widget) 2793 (custom-variable-backup-value widget)
2797 (error "No standard setting known for %S" symbol)) 2794 (error "No standard setting known for %S" symbol))
2798 (put symbol 'variable-comment nil) 2795 (put symbol 'variable-comment nil)
2799 (put symbol 'customized-value nil) 2796 (put symbol 'customized-value nil)
2800 (put symbol 'customized-variable-comment nil) 2797 (put symbol 'customized-variable-comment nil)
2801 (custom-push-theme 'theme-value symbol 'user 'reset nil) 2798 (custom-push-theme 'theme-value symbol 'user 'reset)
2802 (custom-theme-recalc-variable symbol) 2799 (custom-theme-recalc-variable symbol)
2803 (when (or (get symbol 'saved-value) (get symbol 'saved-variable-comment)) 2800 (when (or (get symbol 'saved-value) (get symbol 'saved-variable-comment))
2804 (put symbol 'saved-value nil) 2801 (put symbol 'saved-value nil)
2805 (put symbol 'saved-variable-comment nil) 2802 (put symbol 'saved-variable-comment nil)
2806 (custom-save-all)) 2803 (custom-save-all))
3343 (or tmp temp)) 3340 (or tmp temp))
3344 (if (equal temp comment) 3341 (if (equal temp comment)
3345 (cond 3342 (cond
3346 ((eq 'user (caar (get symbol 'theme-face))) 3343 ((eq 'user (caar (get symbol 'theme-face)))
3347 'saved) 3344 'saved)
3348 ((eq 'standard (caar (get symbol 'theme-face))) 3345 ((eq 'changed (caar (get symbol 'theme-face)))
3349 'changed) 3346 'changed)
3350 (t 'themed)) 3347 (t 'themed))
3351 'changed)) 3348 'changed))
3352 ((get symbol 'face-defface-spec) 3349 ((get symbol 'face-defface-spec)
3353 (if (equal comment nil) 3350 (if (equal comment nil)
3465 (comment-widget (widget-get widget :comment-widget))) 3462 (comment-widget (widget-get widget :comment-widget)))
3466 (unless value 3463 (unless value
3467 (error "No standard setting for this face")) 3464 (error "No standard setting for this face"))
3468 (put symbol 'customized-face nil) 3465 (put symbol 'customized-face nil)
3469 (put symbol 'customized-face-comment nil) 3466 (put symbol 'customized-face-comment nil)
3470 (custom-push-theme 'theme-face symbol 'user 'reset nil) 3467 (custom-push-theme 'theme-face symbol 'user 'reset)
3471 (custom-theme-recalc-face symbol) 3468 (custom-theme-recalc-face symbol)
3472 (when (or (get symbol 'saved-face) (get symbol 'saved-face-comment)) 3469 (when (or (get symbol 'saved-face) (get symbol 'saved-face-comment))
3473 (put symbol 'saved-face nil) 3470 (put symbol 'saved-face nil)
3474 (put symbol 'saved-face-comment nil) 3471 (put symbol 'saved-face-comment nil)
3475 (custom-save-all)) 3472 (custom-save-all))
4121 (goto-char pos))))) 4118 (goto-char pos)))))
4122 4119
4123 (defun custom-save-variables () 4120 (defun custom-save-variables ()
4124 "Save all customized variables in `custom-file'." 4121 "Save all customized variables in `custom-file'."
4125 (save-excursion 4122 (save-excursion
4126 (custom-save-delete 'custom-reset-variables)
4127 (custom-save-delete 'custom-set-variables) 4123 (custom-save-delete 'custom-set-variables)
4128 (custom-save-resets 'theme-value 'custom-reset-variables nil)
4129 (let ((standard-output (current-buffer)) 4124 (let ((standard-output (current-buffer))
4130 (saved-list (make-list 1 0)) 4125 (saved-list (make-list 1 0))
4131 sort-fold-case) 4126 sort-fold-case)
4132 ;; First create a sorted list of saved variables. 4127 ;; First create a sorted list of saved variables.
4133 (mapatoms 4128 (mapatoms
4134 (lambda (symbol) 4129 (lambda (symbol)
4135 (if (get symbol 'saved-value) 4130 (if (and (get symbol 'saved-value)
4131 (eq 'user (car (car-safe (get symbol 'theme-value)))))
4136 (nconc saved-list (list symbol))))) 4132 (nconc saved-list (list symbol)))))
4137 (setq saved-list (sort (cdr saved-list) 'string<)) 4133 (setq saved-list (sort (cdr saved-list) 'string<))
4138 (unless (bolp) 4134 (unless (bolp)
4139 (princ "\n")) 4135 (princ "\n"))
4140 (princ "(custom-set-variables 4136 (princ "(custom-set-variables
4154 ;; Check `requests'. 4150 ;; Check `requests'.
4155 (dolist (request requests) 4151 (dolist (request requests)
4156 (when (and (symbolp request) (not (featurep request))) 4152 (when (and (symbolp request) (not (featurep request)))
4157 (message "Unknown requested feature: %s" request) 4153 (message "Unknown requested feature: %s" request)
4158 (setq requests (delq request requests)))) 4154 (setq requests (delq request requests))))
4159 (when (or (and spec 4155 (when (or (and spec (eq (car spec) 'user))
4160 (eq (nth 0 spec) 'user)
4161 (eq (nth 1 spec) 'set))
4162 comment 4156 comment
4163 (and (null spec) (get symbol 'saved-value))) 4157 (and (null spec) (get symbol 'saved-value)))
4164 (unless (bolp) 4158 (unless (bolp)
4165 (princ "\n")) 4159 (princ "\n"))
4166 (princ " '(") 4160 (princ " '(")
4181 (princ " ")) 4175 (princ " "))
4182 (princ ")") 4176 (princ ")")
4183 (unless (looking-at "\n") 4177 (unless (looking-at "\n")
4184 (princ "\n"))))) 4178 (princ "\n")))))
4185 4179
4186 (defun custom-save-resets (property setter special)
4187 (let (started-writing ignored-special)
4188 ;; (custom-save-delete setter) Done by caller
4189 (let ((standard-output (current-buffer))
4190 (mapper `(lambda (object)
4191 (let ((spec (car-safe (get object (quote ,property)))))
4192 (when (and (not (memq object ignored-special))
4193 (eq (nth 0 spec) 'user)
4194 (eq (nth 1 spec) 'reset))
4195 ;; Do not write reset statements unless necessary.
4196 (unless started-writing
4197 (setq started-writing t)
4198 (unless (bolp)
4199 (princ "\n"))
4200 (princ "(")
4201 (princ (quote ,setter))
4202 (princ "\n '(")
4203 (prin1 object)
4204 (princ " ")
4205 (prin1 (nth 3 spec))
4206 (princ ")")))))))
4207 (mapc mapper special)
4208 (setq ignored-special special)
4209 (mapatoms mapper)
4210 (when started-writing
4211 (princ ")\n")))))
4212
4213 (defun custom-save-faces () 4180 (defun custom-save-faces ()
4214 "Save all customized faces in `custom-file'." 4181 "Save all customized faces in `custom-file'."
4215 (save-excursion 4182 (save-excursion
4216 (custom-save-delete 'custom-reset-faces) 4183 (custom-save-delete 'custom-reset-faces)
4217 (custom-save-delete 'custom-set-faces) 4184 (custom-save-delete 'custom-set-faces)
4218 (custom-save-resets 'theme-face 'custom-reset-faces '(default))
4219 (let ((standard-output (current-buffer)) 4185 (let ((standard-output (current-buffer))
4220 (saved-list (make-list 1 0)) 4186 (saved-list (make-list 1 0))
4221 sort-fold-case) 4187 sort-fold-case)
4222 ;; First create a sorted list of saved faces. 4188 ;; First create a sorted list of saved faces.
4223 (mapatoms 4189 (mapatoms
4224 (lambda (symbol) 4190 (lambda (symbol)
4225 (if (get symbol 'saved-face) 4191 (if (and (get symbol 'saved-face)
4192 (eq 'user (car (car-safe (get symbol 'theme-face)))))
4226 (nconc saved-list (list symbol))))) 4193 (nconc saved-list (list symbol)))))
4227 (setq saved-list (sort (cdr saved-list) 'string<)) 4194 (setq saved-list (sort (cdr saved-list) 'string<))
4228 ;; The default face must be first, since it affects the others. 4195 ;; The default face must be first, since it affects the others.
4229 (if (memq 'default saved-list) 4196 (if (memq 'default saved-list)
4230 (setq saved-list (cons 'default (delq 'default saved-list)))) 4197 (setq saved-list (cons 'default (delq 'default saved-list))))
4240 (value (get symbol 'saved-face)) 4207 (value (get symbol 'saved-face))
4241 (now (not (or (get symbol 'face-defface-spec) 4208 (now (not (or (get symbol 'face-defface-spec)
4242 (and (not (custom-facep symbol)) 4209 (and (not (custom-facep symbol))
4243 (not (get symbol 'force-face)))))) 4210 (not (get symbol 'force-face))))))
4244 (comment (get symbol 'saved-face-comment))) 4211 (comment (get symbol 'saved-face-comment)))
4245 (when (or (and spec 4212 (when (or (and spec (eq (nth 0 spec) 'user))
4246 (eq (nth 0 spec) 'user)
4247 (eq (nth 1 spec) 'set))
4248 comment 4213 comment
4249 (and (null spec) (get symbol 'saved-face))) 4214 (and (null spec) (get symbol 'saved-face)))
4250 ;; Don't print default face here. 4215 ;; Don't print default face here.
4251 (unless (bolp) 4216 (unless (bolp)
4252 (princ "\n")) 4217 (princ "\n"))