I very much dislike the font faces I get for some modes. I know that I can customize them, but in some cases (e.g. org-mode
) this would require customizing dozens of faces.
Therefore, what I really want to determine is, for a given character, where is its face, as it appears on the screen, defined? I'm hoping that this would lead me to a more efficient and maintainable way to fix the problem.
EDIT:
Here's an example of an approach that does not get me what I'm after: determine the name of a character's face (e.g. through M-x describe-char
), and then invoke describe-face
to see where the face is defined (supposedly).
When I do this I often arrive at definitions that are entirely at odds with what I see on the screen. This is why the question title emphasizes as it appears on the screen.
For example, if I invoke M-x describe-char
when point is at an oversized orange character in my current buffer, the output I get tells me that its face is org-level-1
. (FWIW, I get exactly the same result if I use M-: (get-char-property (point) 'face)
or C-u C-x =
instead.)
Now, the output of M-x describe-face
for this face (org-level-1
) includes the following:
Defined in `org-faces.el'.
Family: Monaco
Foundry: unspecified
Width: unspecified
Height: 1.3
Weight: unspecified
Slant: unspecified
Foreground: #cb4b16
DistantForeground: unspecified
Background: unspecified
Underline: unspecified
Overline: unspecified
Strike-through: unspecified
Box: unspecified
Inverse: unspecified
Stipple: unspecified
Font: unspecified
Fontset: unspecified
Inherit: variable-pitch
This face specification, as far as it goes, pretty much matches what I see on the screen (though I don't know what variable-pitch
means when applied to a fixed-width font like Monaco).
But if I follow the reference to org-faces.el
, I find this
(defface org-level-1 ;; originally copied from font-lock-function-name-face
(org-compatible-face 'outline-1
'((((class color) (min-colors 88) (background light)) (:foreground "Blue1"))
(((class color) (min-colors 88) (background dark)) (:foreground "LightSkyBlue"))
(((class color) (min-colors 16) (background light)) (:foreground "Blue"))
(((class color) (min-colors 16) (background dark)) (:foreground "LightSkyBlue"))
(((class color) (min-colors 8)) (:foreground "blue" :bold t))
(t (:bold t))))
"Face used for level 1 headlines."
:group 'org-faces)
Note that this definition bears little relation to the specification listed by describe-face
. In particular, all the colors it mentions are shades of blue, nothing remotely like the color #cb4b16 reported by describe-face
. In addition, it says nothing about any of the other spec items (Family, Height, Inherit) given explicit values in the output of describe-face
.
This is why I emphasize that I'm not looking for the location of some "theoretical"/"nominal" definition of a named face, but the actual definition of the face that I'm seeing on the screen.
EDIT 2:
Digging deeper into the results described above, if I evaluate the following sub-expression in the definition of org-level-1
(org-compatible-face 'outline-1
'((((class color) (min-colors 88) (background light)) (:foreground "Blue1"))
(((class color) (min-colors 88) (background dark)) (:foreground "LightSkyBlue"))
(((class color) (min-colors 16) (background light)) (:foreground "Blue"))
(((class color) (min-colors 16) (background dark)) (:foreground "LightSkyBlue"))
(((class color) (min-colors 8)) (:foreground "blue" :bold t))
(t (:bold t))))
I get this
((t :inherit outline-1))
So I repeat the same wild-goose-chase with outline-1
in place of org-level-1
. I find that it is defined in outline.el
, as follows:
(defface outline-1
'((t :inherit font-lock-function-name-face))
"Level 1."
:group 'outlines)
So, one more time, now with font-lock-function-name-face
, defined in font-lock.el
:
(defface font-lock-function-name-face
'((((class color) (min-colors 88) (background light)) :foreground "Blue1")
(((class color) (min-colors 88) (background dark)) :foreground "LightSkyBlue")
(((class color) (min-colors 16) (background light)) :foreground "Blue")
(((class color) (min-colors 16) (background dark)) :foreground "LightSkyBlue")
(((class color) (min-colors 8)) :foreground "blue" :weight bold)
(t :inverse-video t :weight bold))
"Font Lock mode face used to highlight function names."
:group 'font-lock-faces)
This seems to be the end of this tedious line, but the final definition is no closer to what I see on the screen.
ido
, when I choose a command likemake-face-bold
, the first (default) completion is the face at the point. – asmeurer Feb 4 '15 at 20:26M-x describe-face
describes the current properties of the face. These can be adjusted by lots of factors, the most obvious one being your currently loaded theme (as seen withF1 v custom-enabled-themes
). What you have traced are definitions that make up most of their properties, but don't contain these other factors. – wasamasa Feb 5 '15 at 15:45