]> git.eshelyaron.com Git - emacs.git/commitdiff
Create new "use-package" themse and use it for :custom with custom-theme-set-variables
authorTed Zlatanov <tzz@lifelogs.com>
Sun, 29 Nov 2020 12:23:02 +0000 (12:23 +0000)
committerTed Zlatanov <tzz@lifelogs.com>
Sun, 29 Nov 2020 14:56:10 +0000 (14:56 +0000)
lisp/use-package/use-package-core.el
test/lisp/use-package/use-package-tests.el

index 933e94aa2bd0351e38bfb332c00e641b89c08ec8..c44c36f77fd56c88237cb4d56d651dcfd0482079 100644 (file)
 (require 'cl-lib)
 (require 'tabulated-list)
 
+;; Declare a synthetic theme for :custom variables.
+;; Necessary in order to avoid having those variables saved by custom.el.
+(deftheme use-package)
+(enable-theme 'use-package)
+
 (if (and (eq emacs-major-version 24) (eq emacs-minor-version 3))
     (defsubst hash-table-keys (hash-table)
       "Return a list of keys in HASH-TABLE."
@@ -1394,8 +1399,9 @@ no keyword implies `:all'."
               (comment (nth 2 def)))
           (unless (and comment (stringp comment))
             (setq comment (format "Customized with use-package %s" name)))
-          `(customize-set-variable (quote ,variable) ,value ,comment)
-          `(put ',variable 'theme-value '((use-package-synthetic-theme ignore-just-for-saving)))))
+          `(let ((custom--inhibit-theme-enable nil))
+             (custom-theme-set-variables 'use-package
+                                        '(,variable ,value nil () ,comment)))))
     args)
    (use-package-process-keywords name rest state)))
 
index 38c2025cac6439b3f7e22a02383d1dc0dc729540..a68491cfb7b66d09068ea623682e2ef0b68a67e0 100644 (file)
     ;;                '((foo bar baz))))
     ))
 
+
 (ert-deftest use-package-test/:custom-1 ()
   (match-expansion
    (use-package foo :custom (foo bar))
    `(progn
-      (funcall
-       (or
-        (get 'foo 'custom-set)
-        (function set-default))
-       'foo bar)
-      (set 'foo 'saved-variable-comment "Customized with use-package foo")
+      (let
+          ((custom--inhibit-theme-enable nil))
+        (custom-theme-set-variables 'use-package
+                                    '(foo bar nil nil "Customized with use-package foo")))
       (require 'foo nil nil))))
 
 (ert-deftest use-package-test/:custom-with-comment1 ()
   (match-expansion
    (use-package foo :custom (foo bar "commented"))
    `(progn
-      (funcall
-       (or
-        (get 'foo 'custom-set)
-        (function set-default))
-       'foo bar)
-      (set 'foo 'saved-variable-comment "commented")
+      (let
+          ((custom--inhibit-theme-enable nil))
+        (custom-theme-set-variables 'use-package
+                                    '(foo bar nil nil "commented")))
       (require 'foo nil nil))))
 
 (ert-deftest use-package-test/:custom-face-1 ()