all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stephen Berman <stephen.berman@gmx.net>
To: help-gnu-emacs@gnu.org
Subject: Re: Apply faces to string output to mini-buffer
Date: Fri, 24 May 2013 09:40:50 +0200	[thread overview]
Message-ID: <87sj1czuyl.fsf@rosalinde.fritz.box> (raw)
In-Reply-To: 519f0907$0$36255$862e30e2@ngroups.net

On 24 May 2013 06:30:32 GMT Miguel Guedes <miguel.a.guedes@gmail.com> wrote:

> On Fri, 24 May 2013 05:27:15 +0000, Miguel Guedes wrote:
>
> For instance, the following doesn't work:
>
> Eval:
> (message "%s" (propertize "foo" 'face 'font-lock-variable-name-face))
>
> Echoes:
> #("foo" 0 3 (face font-lock-variable-name-face))
>
> Eval:
> (message "%s" (propertize "foo" 'face '(:foreground "red")))
>
> Echoes:
> #("foo" 0 3 (face (:foreground "red")))
>
>
> Also, eldoc seems to also make use of `message' to output propertized 
> strings (eldoc.el:206:0) so it (seems it) can be used for this purpose. 
> Question is what's wrong with my approach above?

The function `message' returns the printed representation of the
message, so when you evaluate it in the minibuffer, this return value
overwrites the propertized message, which is displayed in the echo area
(which coincides with the minibuffer) as a side effect (on my machine I
can see it briefly before it is overwritten).  If you embed the message
sexp in another function, it returns to the caller, so it doesn't
overwrite the propertized message in the echo area.  E.g., if you
evaluate this:

(defun my-foo ()
  (interactive)
  (message "%s" (propertize "foo" 'face '(:foreground "red"))))

and then type `M-x my-foo', you'll see a red "foo" (without quotes) in
the echo area.

Steve Berman




  reply	other threads:[~2013-05-24  7:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-23 10:50 Apply faces to string output to mini-buffer Miguel Guedes
2013-05-23 16:26 ` Eli Zaretskii
     [not found] ` <mailman.259.1369326384.22516.help-gnu-emacs@gnu.org>
2013-05-24  5:27   ` Miguel Guedes
2013-05-24  6:30     ` Miguel Guedes
2013-05-24  7:40       ` Stephen Berman [this message]
     [not found]       ` <mailman.301.1369381272.22516.help-gnu-emacs@gnu.org>
2013-05-24  8:38         ` Miguel Guedes
2013-05-24  6:40     ` Eli Zaretskii

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=87sj1czuyl.fsf@rosalinde.fritz.box \
    --to=stephen.berman@gmx.net \
    --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.