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?

Drew
  • 75,699
  • 9
  • 109
  • 225
Łukasz Gruner
  • 1,008
  • 8
  • 16

1 Answers1

14

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.

Malabarba
  • 22,878
  • 6
  • 78
  • 163