emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 527413f: Go back to not using custom-push-theme when enabling a t


From: Mauro Aranda
Subject: master 527413f: Go back to not using custom-push-theme when enabling a theme
Date: Fri, 6 Nov 2020 07:36:11 -0500 (EST)

branch: master
commit 527413fb2ff8c073d89ee2d22d38a67c74678b27
Author: Mauro Aranda <maurooaranda@gmail.com>
Commit: Mauro Aranda <maurooaranda@gmail.com>

    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.
---
 lisp/custom.el | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/lisp/custom.el b/lisp/custom.el
index cee4589..3f1e8ca 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))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]