all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
To: "'Antis Lathoi'" <antis.lathoi@gmail.com>, <help-gnu-emacs@gnu.org>
Subject: RE: How to customize the face of echo area messages?
Date: Sun, 2 Jan 2011 10:08:00 -0800	[thread overview]
Message-ID: <923BF6AAACF240C8A46BF785C0D143A9@us.oracle.com> (raw)
In-Reply-To: <546808c5-7160-4732-b8f6-b1d0d5d5e4c3@j25g2000vbs.googlegroups.com>

> 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	other threads:[~2011-01-02 18:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-02 14:07 How to customize the face of echo area messages? Antis Lathoi
2011-01-02 18:08 ` Drew Adams [this message]
     [not found] ` <mailman.3.1293991776.23049.help-gnu-emacs@gnu.org>
2011-01-04 11:06   ` Antis Lathoi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=923BF6AAACF240C8A46BF785C0D143A9@us.oracle.com \
    --to=drew.adams@oracle.com \
    --cc=antis.lathoi@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.