Skip to content

Commit

Permalink
Merge pull request #881 from tzz/tzz/set-comment-and-synthetic-theme
Browse files Browse the repository at this point in the history
  • Loading branch information
jwiegley committed Jan 6, 2021
2 parents caa92f1 + 4bbaf3b commit 365c73d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
11 changes: 8 additions & 3 deletions use-package-core.el
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down Expand Up @@ -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)))

Expand Down
20 changes: 15 additions & 5 deletions use-package-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
Expand Down

0 comments on commit 365c73d

Please sign in to comment.