You can use the packate faceup to create a human readable text representation of a text, with face information. For example:
(defun foo (arg)
(if arg 1 2))
Run M-x faceup-vire-buffer RET
, and the following is shown:
(«k:defun» «f:foo» («v:arg»)
(«k:if» arg 1 2))
The standard font-lock faces are represented using short names, like k
for font-lock-keyword-face
, whereas non-standard faces are presented using their full name.
(Faceup is a regression test system for highlighting packages, e.g. font-lock keywords, the text representation is stored as a reference file.)
EDIT:
To answer the question in the comment: "If I'm trying to debug the faces used in a minibuffer display is this still going to give me the info?"
Yes, it does. However, you must bind the function to a key since running it using M-x
won't work when the minibuffer is in use. For example:
(global-set-key (kbd "<f6>") 'faceup-view-buffer)
If you by the "minibuffer" really meant the echo area -- that it, you would like to inspect the current message you will need a bit more. The following function will do this:
(defun my-faceup-view-current-message ()
(interactive)
(let ((msg (current-message)))
(unless msg
(error "Echo area is empty"))
(with-temp-buffer
(insert msg)
(faceup-view-buffer))))
For example, the following:
(let ((s "My Message"))
(add-text-properties 3 (length s) '(face font-lock-warning-face) s)
(message s)
(my-faceup-view-current-message))
Will show you:
My «w:Message»