(use-package example
:custom-face
(example-1-face ((t (:foreground "LightPink"))))
- (example-2-face ((t (:foreground "LightGreen"))) face-defspec-spec))
+ (example-2-face ((t (:foreground "LightGreen")))))
@end group
@group
@end group
@end lisp
+Similarly to @code{:custom} (@pxref{User options}), this allows
+configuring customizable faces outside of Customize (@pxref{Saving
+Customizations,,, emacs, GNU Emacs Manual}). Using both systems to
+configure the same face can lead to confusing results.
+
@node Hiding minor modes
@section Hiding minor modes with diminish and delight
@cindex hiding minor modes
(defun use-package-handler/:custom-face (name _keyword args rest state)
"Generate use-package custom-face keyword code."
(use-package-concat
- (mapcar #'(lambda (def) `(apply #'face-spec-set (backquote ,def))) args)
+ (mapcar #'(lambda (def)
+ `(progn
+ (apply #'face-spec-set (append (backquote ,def) '(face-defface-spec)))
+ (put ',(car def) 'face-modified t)))
+ args)
(use-package-process-keywords name rest state)))
;;;; :init
:custom Call `Custom-set' or `set-default' with each variable
definition without modifying the Emacs `custom-file'.
(compare with `custom-set-variables').
-:custom-face Call `custom-set-faces' with each face definition.
+:custom-face Call `face-spec-set' with each face definition.
:ensure Loads the package using package.el if necessary.
:pin Pin the package to an archive.
:vc Install the package directly from a version control system
(match-expansion
(use-package foo :custom-face (foo ((t (:background "#e4edfc")))))
`(progn
- (apply #'face-spec-set (backquote (foo ((t (:background "#e4edfc"))))))
+ (progn
+ (apply #'face-spec-set
+ (append (backquote (foo ((t (:background "#e4edfc")))))
+ '(face-defface-spec))
+ )
+ (put 'foo 'face-modified t))
(require 'foo nil nil))))
(ert-deftest use-package-test/:custom-face-2 ()
(example-1-face ((t (:foreground "LightPink"))))
(example-2-face ((t (:foreground "LightGreen")))))
`(progn
- (apply #'face-spec-set
- (backquote (example-1-face ((t (:foreground "LightPink"))))))
- (apply #'face-spec-set
- (backquote (example-2-face ((t (:foreground "LightGreen"))))))
+ (progn
+ (apply #'face-spec-set
+ (append (backquote (example-1-face ((t (:foreground "LightPink")))))
+ '(face-defface-spec)))
+ (put 'example-1-face 'face-modified t))
+ (progn
+ (apply #'face-spec-set
+ (append (backquote (example-2-face ((t (:foreground "LightGreen")))))
+ '(face-defface-spec)))
+ (put 'example-2-face 'face-modified t))
(require 'example nil nil))))
(ert-deftest use-package-test/:custom-face-3 ()
(match-expansion
(use-package foo :custom-face (foo ((t (:background "#e4edfc"))) face-defspec-spec))
`(progn
- (apply #'face-spec-set (backquote (foo ((t (:background "#e4edfc"))) face-defspec-spec)))
+ (progn
+ (apply #'face-spec-set
+ (append (backquote (foo ((t (:background "#e4edfc"))) face-defspec-spec))
+ '(face-defface-spec)))
+ (put 'foo 'face-modified t))
(require 'foo nil nil))))
+(ert-deftest use-package-test/:custom-face-4 ()
+ (defface use-package-test/base-face '((t (:background "green"))) "")
+ (defface use-package-test/face '((t (:inherit use-package-test/base-face))) "")
+ (use-package emacs
+ :custom-face
+ (use-package-test/face ((t (:foreground "blue")))))
+ (should (equal (face-foreground 'use-package-test/face nil t)
+ "blue"))
+ (should (equal (face-background 'use-package-test/face nil t)
+ nil))
+ (should (equal (get 'use-package-test/face 'face-modified)
+ t)))
+
(ert-deftest use-package-test/:init-1 ()
(match-expansion
(use-package foo :init (init))