From: Mauro Aranda Date: Fri, 6 Nov 2020 12:34:08 +0000 (-0300) Subject: Go back to not using custom-push-theme when enabling a theme X-Git-Tag: emacs-28.0.90~5227 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=527413fb2ff8c073d89ee2d22d38a67c74678b27;p=emacs.git 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. --- diff --git a/lisp/custom.el b/lisp/custom.el index cee4589543e..3f1e8cacb28 100644 --- a/lisp/custom.el +++ b/lisp/custom.el @@ -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))