I have a UI element in my mode-line provided by which-func-mode. I also have it in my header-line, pictured below (the blue "render" text):
How can I find out which face this is so I can style it to make it easier to read?
M-x list-faces-display
shows you all of the faces currently defined, including those with names mode-line*
. It shows you the appearance of each face.
And it lets you customize any of them - just click the face name. (See @Zaile's nice answer about using Customize to customize a face.)
In sum, it gives you a WYSIWYG way to find out what faces are involved and customize them.
On your current buffer, make sure you have no text selected and issue M-x customize-face
.
If no faces are selected, it should prompt you with Customize face (default `all faces')
. Hit RET
and you will load the *Customize Faces*
buffer.
Your buffer will then list every single face used in your emacs config by every mode (I believe), including mode-line! Searching for faces related to "mode" with C-s
gave me the following:
There are quite a few faces in my emacs config, so I had to hit C-s
at least 10 or so times before I got to the actual mode-line faces, so make sure you check exhaustively if you don't see them at first.
From there, just click on the arrow for the face you'd like to edit and you'll see the current configurations displayed like so:
You can modify your faces in all sorts of ways besides just color/background by clicking show all attributes
, but be mindfull of how such changes can goof with other modes and customizations like your current theme.
I chose to edit the base Mode Line
face. Here's what it looked like after changing its color and saving the changes (I chose Magenta. It was previously white, which you can see in the previous screenshot):
You can make changes last only for the current session, the buffer, or permanently.
M-x customize-face mode-line TAB TAB
and pick any of the mode-line faces from the list of completions.
The fact pattern of this particular question is somewhat unique -- i.e., relating to changing a face from the built-in library which-func.el
. The author(s) of the library at issue chose to assign the which-func
face to :group 'which-func
. Neither the name of the face, nor the name of the group, contain the term mode-line
. If we knew the name of the group ahead of time, we could customize that group -- e.g., M-x customize-group RET which-func RET
. We can locate the library with M-x find-library RET which-func RET
. This particular library has only one face, so word-searching for the word defface
takes us directly to the face named which-func
.
M-x eval-expression RET (require 'which-func) RET
M-x customize-face RET which-func RET
Depending upon whether an author has endeavored to adhere to standard practices when defining faces and groups, it may be necessary in some cases to inspect the variables mode-line-format
or header-line-format
for additional clues.