[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: preparing colored text
From: |
Jonathan Epstein |
Subject: |
Re: preparing colored text |
Date: |
3 Apr 2003 06:17:21 -0800 |
Thanks for all the responses ... sorry if I was unclear. I meant
doing this under program control. Here's what I came up with
(copy-hack from faces.el) ... thanks again.
Jonathan
(with-output-to-temp-buffer "*ColorExample*"
(save-excursion
(set-buffer standard-output)
(setq truncate-lines t)
(insert "here is some sample red text, green text, and flowery blue
prose")
(put-text-property 20 29 'face 'font-lock-warning-face)
(put-text-property 31 42 'face 'font-lock-type-face)
(put-text-property 47 65 'face 'font-lock-function-name-face)
))
jaepstein_63@yahoo.com (Jonathan Epstein) wrote in message
news:<27e4d2e8.0304020942.52ae37ad@posting.google.com>...
> I've read a lot about faces over the years, but there's something that
> I just don't get: how do I prepare some text which is colored in a
> specific way?
>
> E.g., suppose I have the following text in my Emacs buffer (say, the
> *Scratch* buffer):
> Here is some sample text colored in different ways
>
> How can I make "Here is" red, "some sample" blue, "text" green,
> "colored in" red, and "different ways" blue ?
>
> The specific colors aren't important; an example using commonly
> available faces such as:
> font-lock-comment-face
> font-lock-keyword-face
> font-lock-warning-face
>
> would be fine too.
>
> Oh, I'm sort of wedded to Emacs 20 (I use 20.6.1), if there's an Emacs
> 20-compatible solution, that would be great. Solutions that only work
> on MS Windows would be OK too, although not optimal.
>
> TIA,
>
> Jonathan