Go back to not using custom-push-theme when enabling a theme

* lisp/custom.el (enable-theme): Relying on custom-push-theme to
handle theme settings and prior user settings was a mistake.  The
theme settings haven't changed between loading the theme and enabling
it, so we don't need all of what custom-push-theme does.  However, we
still need to save a user setting outside of Customize, in order to be
able to get back to it, so do that in enable-theme itself.
This commit is contained in:
Mauro Aranda 2020-11-06 09:34:08 -03:00
parent 291955a588
commit 527413fb2f

View file

@ -1385,8 +1385,30 @@ function runs. To disable other themes, use `disable-theme'."
;; 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))