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 '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,9 +1399,9 @@ no keyword implies `:all'."
(comment (nth 2 def)))
(unless (and comment (stringp comment))
(setq comment (format "Customized with use-package %s" name)))
`(funcall (or (get (quote ,variable) 'custom-set) #'set-default)
(quote ,variable)
,value)))
`(let ((custom--inhibit-theme-enable nil))
(custom-theme-set-variables 'use-package
'(,variable ,value nil () ,comment)))))
args)
(use-package-process-keywords name rest state)))

View file

@ -1129,15 +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)
(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
(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 ()