;; Loop through theme settings, recalculating vars/faces.
(dolist (s settings)
(let* ((prop (car s))
- (symbol (cadr s)))
- (custom-push-theme prop symbol theme 'set (nth 3 s))
+ (symbol (cadr s))
+ (spec-list (get symbol prop))
+ (sv (get symbol 'standard-value))
+ (val (and (boundp symbol) (symbol-value symbol))))
+ ;; We can't call `custom-push-theme' when enabling the theme: it's not
+ ;; that the theme settings have changed, it's just that we want to
+ ;; enable those settings. But we might need to save a user setting
+ ;; outside of Customize, in order to get back to it when disabling
+ ;; the theme, just like in `custom-push-theme'.
+ (when (and (custom--should-apply-setting theme)
+ ;; Only do it for variables; for faces, using
+ ;; `face-new-frame-defaults' is enough.
+ (eq prop 'theme-value)
+ (boundp symbol)
+ (not (or spec-list
+ ;; Only if the current value is different from
+ ;; the standard value.
+ (and sv (equal (eval (car sv)) val))
+ ;; And only if the changed value is different
+ ;; from the new value under the user theme.
+ (and (eq theme 'user)
+ (equal (custom-quote val) (nth 3 s))))))
+ (setq spec-list `((changed ,(custom-quote val)))))
+ (put symbol prop (cons (cddr s) (assq-delete-all theme spec-list)))
(cond
((eq prop 'theme-face)
(custom-theme-recalc-face symbol))