From a3c310c11a9ec311a4028d7ce8da4c2fd204a46b Mon Sep 17 00:00:00 2001 From: Ted Zlatanov Date: Sun, 29 Nov 2020 12:23:02 +0000 Subject: [PATCH] Create new "use-package" themse and use it for :custom with custom-theme-set-variables --- lisp/use-package/use-package-core.el | 10 ++++++++-- test/lisp/use-package/use-package-tests.el | 21 +++++++++------------ 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/lisp/use-package/use-package-core.el b/lisp/use-package/use-package-core.el index 933e94aa2bd..c44c36f77fd 100644 --- a/lisp/use-package/use-package-core.el +++ b/lisp/use-package/use-package-core.el @@ -43,6 +43,11 @@ (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))) diff --git a/test/lisp/use-package/use-package-tests.el b/test/lisp/use-package/use-package-tests.el index 38c2025cac6..a68491cfb7b 100644 --- a/test/lisp/use-package/use-package-tests.el +++ b/test/lisp/use-package/use-package-tests.el @@ -1129,28 +1129,25 @@ ;; '((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 () -- 2.39.2