* preparing colored text
@ 2003-04-02 17:42 Jonathan Epstein
2003-04-02 18:20 ` Kai Großjohann
` (4 more replies)
0 siblings, 5 replies; 12+ messages in thread
From: Jonathan Epstein @ 2003-04-02 17:42 UTC (permalink / raw)
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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: preparing colored text
2003-04-02 17:42 preparing colored text Jonathan Epstein
@ 2003-04-02 18:20 ` Kai Großjohann
2003-04-02 19:10 ` Kevin Rodgers
` (3 subsequent siblings)
4 siblings, 0 replies; 12+ messages in thread
From: Kai Großjohann @ 2003-04-02 18:20 UTC (permalink / raw)
jaepstein_63@yahoo.com (Jonathan Epstein) writes:
> 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?
Do you mean you want a mode where all occurrences of the word frumple
are in a specific color, or do you want something where you can point
at a word and say "make this blue"?
If the latter, investigate M-x enriched-mode RET. And the M-g key.
(And C-<down-mouse-2>.)
--
A preposition is not a good thing to end a sentence with.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: preparing colored text
2003-04-02 17:42 preparing colored text Jonathan Epstein
2003-04-02 18:20 ` Kai Großjohann
@ 2003-04-02 19:10 ` Kevin Rodgers
2003-04-02 19:18 ` Bijan Soleymani
` (2 subsequent siblings)
4 siblings, 0 replies; 12+ messages in thread
From: Kevin Rodgers @ 2003-04-02 19:10 UTC (permalink / raw)
Jonathan Epstein wrote:
> 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.
Global Bindings Starting With M-g:
key binding
--- -------
M-g d facemenu-set-default
M-g b facemenu-set-bold
M-g i facemenu-set-italic
M-g l facemenu-set-bold-italic
M-g u facemenu-set-underline
M-g o facemenu-set-face
And see the "Formatted Text" and "Format Colors" nodes of the Emacs manual.
--
<a href="mailto:<kevin.rodgers@ihs.com>">Kevin Rodgers</a>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: preparing colored text
2003-04-02 17:42 preparing colored text Jonathan Epstein
2003-04-02 18:20 ` Kai Großjohann
2003-04-02 19:10 ` Kevin Rodgers
@ 2003-04-02 19:18 ` Bijan Soleymani
2003-04-03 6:59 ` Colin Marquardt
2003-04-03 14:17 ` Jonathan Epstein
4 siblings, 0 replies; 12+ messages in thread
From: Bijan Soleymani @ 2003-04-02 19:18 UTC (permalink / raw)
jaepstein_63@yahoo.com (Jonathan Epstein) writes:
> 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 ?
If your version of emacs has it, you should probably try enriched-mode.
M-x enriched mode
Then select the text you want to be red.
Then from the menu go in Edit -> Text Properties -> Foreground Color
and enter red.
Repeat for all other colors.
Hope that helps,
Bijan
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: preparing colored text
2003-04-02 17:42 preparing colored text Jonathan Epstein
` (2 preceding siblings ...)
2003-04-02 19:18 ` Bijan Soleymani
@ 2003-04-03 6:59 ` Colin Marquardt
2003-04-03 14:17 ` Jonathan Epstein
4 siblings, 0 replies; 12+ messages in thread
From: Colin Marquardt @ 2003-04-03 6:59 UTC (permalink / raw)
jaepstein_63@yahoo.com (Jonathan Epstein) writes:
> 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?
Take a look at
http://www.emacswiki.org/cgi-bin/wiki.pl?CategoryFaces
enriched-mode has been mentioned, but maybe you want something like
http://www.emacswiki.org/cgi-bin/wiki.pl?HighlightTemporarily
HTH,
Colin
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: preparing colored text
2003-04-03 14:17 ` Jonathan Epstein
@ 2003-04-03 13:37 ` Kai Großjohann
2003-04-03 16:52 ` Matthew Kennedy
0 siblings, 1 reply; 12+ messages in thread
From: Kai Großjohann @ 2003-04-03 13:37 UTC (permalink / raw)
jaepstein_63@yahoo.com (Jonathan Epstein) writes:
> (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)
> ))
(insert (propertize "warning" 'face 'font-lock-warning-face))
... easier to maintain in case the strings change :-)
--
A preposition is not a good thing to end a sentence with.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: preparing colored text
2003-04-02 17:42 preparing colored text Jonathan Epstein
` (3 preceding siblings ...)
2003-04-03 6:59 ` Colin Marquardt
@ 2003-04-03 14:17 ` Jonathan Epstein
2003-04-03 13:37 ` Kai Großjohann
4 siblings, 1 reply; 12+ messages in thread
From: Jonathan Epstein @ 2003-04-03 14:17 UTC (permalink / raw)
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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: preparing colored text
2003-04-03 13:37 ` Kai Großjohann
@ 2003-04-03 16:52 ` Matthew Kennedy
2003-04-03 18:05 ` Oliver Scholz
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: Matthew Kennedy @ 2003-04-03 16:52 UTC (permalink / raw)
kai.grossjohann@gmx.net (Kai Großjohann) writes:
>
> (insert (propertize "warning" 'face 'font-lock-warning-face))
>
> ... easier to maintain in case the strings change :-)
>
Kai, this was my first attempt also. I copied this example into
*scratch* and evaluated it, it appears to just insert "warning"
without changing any text properties.
I ran M-: (get-text-property (point) 'face) with the point on the
inserted warning text. That expression returns nil. I'm confused
(like always)...
BTW, where'd you find Oort 0.18? :D
Matt
--
Matthew Kennedy
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: preparing colored text
2003-04-03 16:52 ` Matthew Kennedy
@ 2003-04-03 18:05 ` Oliver Scholz
2003-04-03 18:27 ` Matthew Kennedy
2003-04-04 7:00 ` Lee Sau Dan
2003-04-04 12:48 ` Kai Großjohann
2 siblings, 1 reply; 12+ messages in thread
From: Oliver Scholz @ 2003-04-03 18:05 UTC (permalink / raw)
Matthew Kennedy <mbkennedy@austin.rr.com> writes:
> kai.grossjohann@gmx.net (Kai Großjohann) writes:
>
>>
>> (insert (propertize "warning" 'face 'font-lock-warning-face))
>>
>> ... easier to maintain in case the strings change :-)
>>
>
> Kai, this was my first attempt also. I copied this example into
> *scratch* and evaluated it, it appears to just insert "warning"
> without changing any text properties.
[...]
Probably you have font-lock turned on. It removes all "foreign" text
properties. Try it in a buffer without font-lock, for example in
text-mode.
In CVS Emacs you can use something like this
(insert (propertize "lirum larum" 'font-lock-face
'font-lock-warning-face))
even in buffers with font-lock.
Oliver
--
14 Germinal an 211 de la Révolution
Liberté, Egalité, Fraternité!
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: preparing colored text
2003-04-03 18:05 ` Oliver Scholz
@ 2003-04-03 18:27 ` Matthew Kennedy
0 siblings, 0 replies; 12+ messages in thread
From: Matthew Kennedy @ 2003-04-03 18:27 UTC (permalink / raw)
Oliver Scholz <alkibiades@gmx.de> writes:
> Probably you have font-lock turned on. It removes all "foreign" text
> properties. Try it in a buffer without font-lock, for example in
> text-mode.
>
> In CVS Emacs you can use something like this
>
> (insert (propertize "lirum larum" 'font-lock-face
> 'font-lock-warning-face))
Ahhh... that was it! Thanks,
Matt
--
Matthew Kennedy
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: preparing colored text
2003-04-03 16:52 ` Matthew Kennedy
2003-04-03 18:05 ` Oliver Scholz
@ 2003-04-04 7:00 ` Lee Sau Dan
2003-04-04 12:48 ` Kai Großjohann
2 siblings, 0 replies; 12+ messages in thread
From: Lee Sau Dan @ 2003-04-04 7:00 UTC (permalink / raw)
>>>>> "Matthew" == Matthew Kennedy <mbkennedy@austin.rr.com> writes:
Matthew> Kai, this was my first attempt also. I copied this
Matthew> example into *scratch* and evaluated it, it appears to
Matthew> just insert "warning" without changing any text
Matthew> properties.
Did you disable font-lock-mode in *scratch* before trying it out?
--
Lee Sau Dan 李守敦(Big5) ~{@nJX6X~}(HZ)
E-mail: danlee@informatik.uni-freiburg.de
Home page: http://www.informatik.uni-freiburg.de/~danlee
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: preparing colored text
2003-04-03 16:52 ` Matthew Kennedy
2003-04-03 18:05 ` Oliver Scholz
2003-04-04 7:00 ` Lee Sau Dan
@ 2003-04-04 12:48 ` Kai Großjohann
2 siblings, 0 replies; 12+ messages in thread
From: Kai Großjohann @ 2003-04-04 12:48 UTC (permalink / raw)
Matthew Kennedy <mbkennedy@austin.rr.com> writes:
> BTW, where'd you find Oort 0.18? :D
It's the CVS version.
--
A preposition is not a good thing to end a sentence with.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2003-04-04 12:48 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-04-02 17:42 preparing colored text Jonathan Epstein
2003-04-02 18:20 ` Kai Großjohann
2003-04-02 19:10 ` Kevin Rodgers
2003-04-02 19:18 ` Bijan Soleymani
2003-04-03 6:59 ` Colin Marquardt
2003-04-03 14:17 ` Jonathan Epstein
2003-04-03 13:37 ` Kai Großjohann
2003-04-03 16:52 ` Matthew Kennedy
2003-04-03 18:05 ` Oliver Scholz
2003-04-03 18:27 ` Matthew Kennedy
2003-04-04 7:00 ` Lee Sau Dan
2003-04-04 12:48 ` Kai Großjohann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).