Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs: Find face definition (color, other styles, etc.) at point

I'm making a theme for Emacs based on the default themes, namely the GUI default theme (white background) and the theme that comes out of the --reverse-video flag (black background). Just going to provide more colors for plugin faces etc., so that they all have a more unified look.

In case you're interested: https://github.com/Greduan/emacs-theme-better-defaults

Now since I am going to be working off of already existing themes for which I am not entirely sure where I can find the source I thought I should ask here what the best way to go about this would be.

Let's say I have my point on top of a comment, is there a command or something of the sort that I can call so that I can find the colors etc. with which that certain face is defined?

I am aware of describe-face, what-cursor-position (C-x = or C-u C-x =) and of list-colors-display.

The first two don't provide the information I need, namely what color it's using (hex code or otherwise), or at least I couldn't find it. I could probably use list-colors-display but that would truly be a PITA to try to find the exact color it's using. lol

Any help is appreciated. Thanks. :)

like image 935
greduan Avatar asked Aug 16 '14 01:08

greduan


2 Answers

Actually, describe-face does provide the information you seem to be looking for. Place the cursor on a character with the face you're interested in. Do M-x describe-face. It will default to the face of the character at point. Hit enter: it will describe that face. Here's an example of what you get for the default face from the inkpot theme; notice the foreground and background hex values, which are the items you wanted:

Face: default (sample) (customize this face)

Documentation:
Basic default face.

Defined in `faces.el'.

        Family: DejaVu Sans Mono
       Foundry: unknown
         Width: normal
        Height: 150
        Weight: normal
         Slant: normal
    Foreground: #bdbdbd
    Background: #0d0d16
     Underline: nil
      Overline: nil
Strike-through: nil
           Box: nil
       Inverse: nil
       Stipple: nil
          Font: #<font-object -unknown-DejaVu Sans Mono-normal-normal-normal-*-26-*-*-*-m-0-iso10646-1>
       Fontset: -unknown-DejaVu Sans Mono-normal-normal-normal-*-26-*-*-*-m-0-fontset-auto1
       Inherit: nil
like image 98
Dan Avatar answered Sep 24 '22 23:09

Dan


You can use describe-char to do this. describe-char will show the text properties for the character the point is over, which will show you, among other things, the list of faces being used to decorate the character. You can go to the face properties directly from the character properties window or use describe-face.

like image 24
erikstokes Avatar answered Sep 21 '22 23:09

erikstokes