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.
In Emacs, how do I display a message in the minibuffer with font face properties?
Asked Answered
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.
Is there a way that the color are preserved in the
*Messages*
buffer? –
Gorcock If you see the
#("foo" 0 3 (face (:foreground "red")))
, instead of showing a red foo
, see here for an explanation, 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. –
Ribble © 2022 - 2024 — McMap. All rights reserved.
(defun lawlist-message (input) (interactive) (message (propertize input 'face 'font-lock-warning-face)))
– Undry