use-package
use-package copied to clipboard
[Question] How the custom-face keyword acts on the faces ?
Hello,
I think i don't understand how the :custom-face keyword works.
My goal
For Org, i would like to add a face attribute (height) to the org-level-1 face.
Initial configuration
Before using use-package, my configuration was
(set-face-attribute 'org-level-1 nil :height 1.4)
Result
The result was the org-level-1 face with the inherit face outline-1 and the height value set to 1.4.
New configuration
With use-package, i now use this configuration
(use-package org
:custom-face
(org-level-1 ((t (:height 1.4)))))
Result
The result is now the org-level-1 face WITHOUT the inherit face outline-1 but with the height value set to 1.4.
My questions
- Is this behavior intended ?
- If this is a normal behavior, how can i add the attribute i want with the
:custom-facekeyword without redefining the face ?
I know i can simply add :inherit outline-1 attribute+value in (org-level-1 ((t (:height 1.4))))) or simply put my old configuration in the :config keyword to fix this issue but i would like to know how the :custom-face keyword works in order to define what to do.
I also looked in the use-package source code but i'm fairly new to emacs/elisp so as you can guess, i didn't understand what i've seen in it.
use-package is not use set-face-attribute.
(setq use-package-expand-minimally t)
;;=> t
(macroexpand
'(use-package org
:custom-face
(org-level-1 ((t (:height 1.4))))))
;;=> (progn
;; (custom-set-faces
;; '(org-level-1 ((t (:height 1.4)))))
;; (require 'org nil nil))
so, the difference should come from set-face-attribute and custom-set-faces.
But I can configure face via :custom-face correctory...?
However, this information is the first step to investigate your issue.
I think @conao3 answered this question. You should use the following form:
(use-package org
:custom-face
(org-level-1 ((t (:height 1.4 :inherit outline-1)))))
Alternatively, I see nothing wrong with using this:
(use-package org
:config
(set-face-attribute 'org-level-1 nil :height 1.4))
For now, I don't see any strong reason to make any changes in use-package, as the above seems to cover this use case sufficiently well. We don't want to replace all types of customization with use-package, only some of the more tedious and common boiler-plate.
I hope that helps.