summaryrefslogtreecommitdiff
path: root/lisp/use-package/use-package-core.el
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2021-02-07 11:26:37 -0800
committerGitHub <noreply@github.com>2021-02-07 11:26:37 -0800
commita248658910204bb20b64eedba7d1c1f32bbaca94 (patch)
tree6b6457873ef6db4d878ea60a35273f53727f7e5f /lisp/use-package/use-package-core.el
parentc425e67a19526a0bda7bf52cdffde600c1696e01 (diff)
parent2b9536f242ab2c408b9e87a04c1e6aad3596a073 (diff)
downloademacs-a248658910204bb20b64eedba7d1c1f32bbaca94.tar.gz
emacs-a248658910204bb20b64eedba7d1c1f32bbaca94.tar.bz2
emacs-a248658910204bb20b64eedba7d1c1f32bbaca94.zip
Merge pull request from tzz/tzz/use-package-use-theme
Add use-package-use-theme and avoid missing theme errors GitHub-reference: https://github.com/jwiegley/use-package/issues/907
Diffstat (limited to 'lisp/use-package/use-package-core.el')
-rw-r--r--lisp/use-package/use-package-core.el47
1 files changed, 35 insertions, 12 deletions
diff --git a/lisp/use-package/use-package-core.el b/lisp/use-package/use-package-core.el
index 72e080001b2..28bc5a50ed0 100644
--- a/lisp/use-package/use-package-core.el
+++ b/lisp/use-package/use-package-core.el
@@ -135,6 +135,13 @@ arguments will be ignored in the `use-package' expansion."
:type 'boolean
:group 'use-package)
+(defcustom use-package-use-theme t
+ "If non-nil, use a custom theme to avoid saving :custom
+variables twice (once in the Custom file, once in the use-package
+call)."
+ :type 'boolean
+ :group 'use-package)
+
(defcustom use-package-verbose nil
"Whether to report about loading and configuration details.
If you customize this, then you should require the `use-package'
@@ -1397,18 +1404,34 @@ no keyword implies `:all'."
(defun use-package-handler/:custom (name _keyword args rest state)
"Generate use-package custom keyword code."
(use-package-concat
- `((let ((custom--inhibit-theme-enable nil))
- (custom-theme-set-variables
- 'use-package
- ,@(mapcar
- #'(lambda (def)
- (let ((variable (nth 0 def))
- (value (nth 1 def))
- (comment (nth 2 def)))
- (unless (and comment (stringp comment))
- (setq comment (format "Customized with use-package %s" name)))
- `'(,variable ,value nil () ,comment)))
- args))))
+ (if (bound-and-true-p use-package-use-theme)
+ `((let ((custom--inhibit-theme-enable nil))
+ ;; Declare the theme here so use-package can be required inside
+ ;; eval-and-compile without warnings about unknown theme.
+ (unless (memq 'use-package custom-known-themes)
+ (deftheme use-package)
+ (enable-theme 'use-package)
+ (setq custom-enabled-themes (remq 'use-package custom-enabled-themes)))
+ (custom-theme-set-variables
+ 'use-package
+ ,@(mapcar
+ #'(lambda (def)
+ (let ((variable (nth 0 def))
+ (value (nth 1 def))
+ (comment (nth 2 def)))
+ (unless (and comment (stringp comment))
+ (setq comment (format "Customized with use-package %s" name)))
+ `'(,variable ,value nil () ,comment)))
+ args))))
+ (mapcar
+ #'(lambda (def)
+ (let ((variable (nth 0 def))
+ (value (nth 1 def))
+ (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)))
+ args))
(use-package-process-keywords name rest state)))
;;;; :custom-face