I want to display a colored string of text in the minibuffer, but when I use the 'message' function, the text-properties of are stripped.
Asked
Active
Viewed 5,053 times
1 Answers
30
Works for me:
(message "%s" (propertize "foo" 'face '(:foreground "red")))
You probably had (message (propertize ...))
, which interprets the propertized string as a format control string, hence stripped of its properties.

huaiyuan
- 26,129
- 5
- 57
- 63
-
1`(defun lawlist-message (input) (interactive) (message (propertize input 'face 'font-lock-warning-face)))` – lawlist Jan 25 '14 at 22:25
-
1Is there a way that the color are preserved in the `*Messages*` buffer? – AdrieanKhisbe Jul 16 '14 at 20:40
-
8If you see the `#("foo" 0 3 (face (:foreground "red")))`, instead of showing a red `foo`, see here for [an explanation](http://emacs.stackexchange.com/a/2332/11060), the reason is that the message is displayed, but then the result of the expression is printed, which hides the message. Putting it in an `(interactive)` makes it work as expected. – Suzanne Soy Feb 09 '16 at 11:36