tags:

views:

754

answers:

4

I've been developing my own custom color theme, and it'd be really useful if I could get a list of font-faces affecting the text under the cursor.

Something like Textmate's show current scope command.

That would save me the trouble of doing M-x customize-face and looking through available options, guessing at which one affects the current word I'm on.

Any ideas?

+1  A: 
M-x what-face

will print the face found at the current point. And the code for that is:

(defun what-face (pos)
  (interactive "d")
  (let ((face (or (get-char-property (point) 'read-face-name)
                  (get-char-property (point) 'face))))
    (if face (message "Face: %s" face) (message "No face at %d" pos))))

(thanks to thedz for pointing out it wasn't built in)

Trey Jackson
+1  A: 

Trey's what face is on the right track. It led me to an email on a mailing list that had this:

(defun what-face (pos)
    (interactive "d")
        (let ((face (or (get-char-property (point) 'read-face-name)
            (get-char-property (point) 'face))))
    (if face (message "Face: %s" face) (message "No face at %d" pos))))
thedz
Duh, forgot it wasn't bundled with Emacs. May I put the source in my answer w/attribution? :)
Trey Jackson
Go for it -- I'll give you answer credit, too.
thedz
+7  A: 

C-u C-x = shows the face under point, among other information.

jlf
Which invokes `what-cursor-position`.
Török Gábor
exactly what I where looking for, thanks
Joakim Elofsson
hmmm, sometimes it invokes what-cursor-position, sometimes it displays a list of buffer properties (including font). If I get the former behaviour, moving the cursor and repeating brings on the latter.
meowsqueak
+5  A: 

M-x describe-face

RamyenHead