8

When I print messages using (message (propertize "text" 'face 'some-face)) properties get printed as text:

#("text" 0 4 (face some-face)) 

How can I have faces displayed properly?

1 Answer 1

15

No they don't get printed as text. :-)

Evaluate the following function, then call M-x mes. Doesn't it work?

(defun mes () "message me" (interactive) (message (propertize "text" 'face 'font-lock-warning-face))) 

The problem, I imagine, is that you're evaluating your snippet with something like eval-last-sexp (C-x C-e). This function (and its brethren) prints the form's return value on the echo area, which is what you're seeing (the message function also returns the string it prints).

Your test code is working, but the message in the mode-line is getting immediately replaced by the return value. That's why you can't see it.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.