5

I couldn't find anything on this, so I'm asking it here. I can display a message in minibuffer with

(message "foo bar")

I would like to give only the message "foo bar" a red color in the minibuffer. Is that possible with Emacs?

Andrew Swann
  • 3,436
  • 2
  • 15
  • 43
ReneFroger
  • 3,855
  • 22
  • 63
  • If you use `M-x customiz-group RET minibuffer RET` you can customize various aspects of how things appear in the `minibuffer`. Not sure if it is what you want, but it would be a good place to start. I am not entirely sure if you want to do this as part of some commands that you are writing, or just a general way to customize the face of the text in the minibuffer. – elethan Dec 15 '15 at 15:15
  • No, I want to keep the default colorscheme of minibuffer, but for only specific messages I want to colorize them differently from the rest. – ReneFroger Dec 15 '15 at 19:42

1 Answers1

6

Just use a string with faces.

(message (propertize "foo bar" 'face 'highlight))

Or use a different face, which has a red foreground. Or use a face property list:

(message (propertize "foo bar" 'face '(:foreground "Red")))
Drew
  • 75,699
  • 9
  • 109
  • 225
  • When I tried this it showed `#("foo bar" 0 7 (face highlight))` in the echo area, but this answer explained why - you can't use C-x C-e to test it out... http://emacs.stackexchange.com/questions/2331/how-can-i-set-face-for-echo-area-message – Brian Burns Dec 15 '15 at 17:36
  • Thanks Drew! I was already looking why it didn't worked properly, until I noticed @bburns.km message.Thanks for sharing that link! – ReneFroger Dec 15 '15 at 19:47
  • Use `(defun foo () (interactive) (message...))` with `M-x foo`, to test. – Drew Dec 15 '15 at 21:16