help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: How to customize the face of echo area messages?


From: Drew Adams
Subject: RE: How to customize the face of echo area messages?
Date: Sun, 2 Jan 2011 10:08:00 -0800

> I'm trying to change the appearance of messages that appear in the
> echo area when you perform certain actions in emacs (e.g. saving files
> --> "wrote FOOBAR", CTRL-g --> "quit"). By default these messages are
> printed exactly the same way as buffer text is. I'd like to change
> that (different foreground color), but didn't find anything within the
> emacs customize system to do that.  Ideas anyone?

(defun my-msg (msg &optional face)
  "`message', but with text using FACE (default `highlight')."
  (message (propertize msg 'face (or face 'highlight))))

M-: (progn (my-msg "HELLO") (sleep-for 3))
M-: (progn (my-msg "HELLO" 'font-lock-warning-face) (sleep-for 3))

Of course, that only works for calls to `my-msg', not calls to `message' (such
as what you described).  You could advise `message' to catch most of those.
Something like this:

(defadvice message (around my-message-advice activate)
  "Show the message using face `font-lock-warning-face'."
  (ad-set-args
    0 (list (propertize
              (apply #'format (ad-get-args 0))
                     'face 'font-lock-warning-face)))
  ad-do-it)

M-: (progn (message "Hello %s%s" 'there ", Antis") (sleep-for 3))

That works for the `message' calls from Lisp, but not for those from C.
Unfortunately, the "Wrote ..." message comes from C.  So you will see "Saving
file foobar.el..." in face `font-lock-warning-face' but just after that you will
see "Wrote foobar.el" with no special face.

(That might happen so quickly that you do not notice the "Saving" message.  To
see it, add this just after `ad-do-it': (sleep-for 2).)

Maybe someone else will have a better suggestion for you.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]