Merge pull request from tzz/tzz/set-comment-and-synthetic-theme

GitHub-reference: https://github.com/jwiegley/use-package/issues/881
This commit is contained in:
John Wiegley 2021-01-06 13:45:39 -08:00 committed by GitHub
commit 3ffb662dcc
2 changed files with 23 additions and 8 deletions

View file

@ -43,6 +43,11 @@
(require 'cl-lib) (require 'cl-lib)
(require 'tabulated-list) (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)) (if (and (eq emacs-major-version 24) (eq emacs-minor-version 3))
(defsubst hash-table-keys (hash-table) (defsubst hash-table-keys (hash-table)
"Return a list of keys in HASH-TABLE." "Return a list of keys in HASH-TABLE."
@ -1394,9 +1399,9 @@ no keyword implies `:all'."
(comment (nth 2 def))) (comment (nth 2 def)))
(unless (and comment (stringp comment)) (unless (and comment (stringp comment))
(setq comment (format "Customized with use-package %s" name))) (setq comment (format "Customized with use-package %s" name)))
`(funcall (or (get (quote ,variable) 'custom-set) #'set-default) `(let ((custom--inhibit-theme-enable nil))
(quote ,variable) (custom-theme-set-variables 'use-package
,value))) '(,variable ,value nil () ,comment)))))
args) args)
(use-package-process-keywords name rest state))) (use-package-process-keywords name rest state)))

View file

@ -1129,15 +1129,25 @@
;; '((foo bar baz)))) ;; '((foo bar baz))))
)) ))
(ert-deftest use-package-test/:custom-1 () (ert-deftest use-package-test/:custom-1 ()
(match-expansion (match-expansion
(use-package foo :custom (foo bar)) (use-package foo :custom (foo bar))
`(progn `(progn
(funcall (let
(or ((custom--inhibit-theme-enable nil))
(get 'foo 'custom-set) (custom-theme-set-variables 'use-package
(function set-default)) '(foo bar nil nil "Customized with use-package foo")))
'foo bar) (require 'foo nil nil))))
(ert-deftest use-package-test/:custom-with-comment1 ()
(match-expansion
(use-package foo :custom (foo bar "commented"))
`(progn
(let
((custom--inhibit-theme-enable nil))
(custom-theme-set-variables 'use-package
'(foo bar nil nil "commented")))
(require 'foo nil nil)))) (require 'foo nil nil))))
(ert-deftest use-package-test/:custom-face-1 () (ert-deftest use-package-test/:custom-face-1 ()