From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stephen Berman Newsgroups: gmane.emacs.help Subject: Re: Apply faces to string output to mini-buffer Date: Fri, 24 May 2013 09:40:50 +0200 Message-ID: <87sj1czuyl.fsf@rosalinde.fritz.box> References: <519df490$0$33340$862e30e2@ngroups.net> <519efa33$0$32272$862e30e2@ngroups.net> <519f0907$0$36255$862e30e2@ngroups.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1369381287 24446 80.91.229.3 (24 May 2013 07:41:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 24 May 2013 07:41:27 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri May 24 09:41:26 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Ufmcv-0005kP-Oi for geh-help-gnu-emacs@m.gmane.org; Fri, 24 May 2013 09:41:25 +0200 Original-Received: from localhost ([::1]:36787 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ufmcv-0006bB-E4 for geh-help-gnu-emacs@m.gmane.org; Fri, 24 May 2013 03:41:25 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:48953) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ufmcb-0006S5-D3 for help-gnu-emacs@gnu.org; Fri, 24 May 2013 03:41:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UfmcY-0007es-06 for help-gnu-emacs@gnu.org; Fri, 24 May 2013 03:41:05 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:40729) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfmcX-0007ea-IE for help-gnu-emacs@gnu.org; Fri, 24 May 2013 03:41:01 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1UfmcV-0005a2-Vr for help-gnu-emacs@gnu.org; Fri, 24 May 2013 09:40:59 +0200 Original-Received: from i59f575c8.versanet.de ([89.245.117.200]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 24 May 2013 09:40:59 +0200 Original-Received: from stephen.berman by i59f575c8.versanet.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 24 May 2013 09:40:59 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 40 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: i59f575c8.versanet.de User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:91018 Archived-At: On 24 May 2013 06:30:32 GMT Miguel Guedes 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