6

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?

13

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.