all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How to customize the face of echo area messages?
@ 2011-01-02 14:07 Antis Lathoi
  2011-01-02 18:08 ` Drew Adams
       [not found] ` <mailman.3.1293991776.23049.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 3+ messages in thread
From: Antis Lathoi @ 2011-01-02 14:07 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,

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?

Thanks

Antis


^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: How to customize the face of echo area messages?
  2011-01-02 14:07 How to customize the face of echo area messages? Antis Lathoi
@ 2011-01-02 18:08 ` Drew Adams
       [not found] ` <mailman.3.1293991776.23049.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 3+ messages in thread
From: Drew Adams @ 2011-01-02 18:08 UTC (permalink / raw)
  To: 'Antis Lathoi', help-gnu-emacs

> 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.




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to customize the face of echo area messages?
       [not found] ` <mailman.3.1293991776.23049.help-gnu-emacs@gnu.org>
@ 2011-01-04 11:06   ` Antis Lathoi
  0 siblings, 0 replies; 3+ messages in thread
From: Antis Lathoi @ 2011-01-04 11:06 UTC (permalink / raw)
  To: help-gnu-emacs

On 2 Jan., 19:08, "Drew Adams" <drew.ad...@oracle.com> wrote:

>
> (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)

Thanks Drew!

that indeed works nicely with the exceptions you mentioned.
Didn't think that this customization would be so complicated. As
messages in the echo area are ubiquitious and therefore do a good deal
for the visual side of the emacs experience, I'm suprised you cannot
"customize" them (when you can nearly everything else :-)

thanks again

Antis


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-01-04 11:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-02 14:07 How to customize the face of echo area messages? Antis Lathoi
2011-01-02 18:08 ` Drew Adams
     [not found] ` <mailman.3.1293991776.23049.help-gnu-emacs@gnu.org>
2011-01-04 11:06   ` Antis Lathoi

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.