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?

  • 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
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")))
  • 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... emacs.stackexchange.com/questions/2331/… – 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

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.