* Q on multiple faces as text property `face'
@ 2006-02-18 18:10 Drew Adams
0 siblings, 0 replies; 2+ messages in thread
From: Drew Adams @ 2006-02-18 18:10 UTC (permalink / raw)
I have two faces:
(defface face1 '((t (:background "White"))) "Face 1")
(defface face2 '((t (:foreground "Blue"))) "Face 2")
Using `put-text-property' with the `face' property:
I put face2 on some text.
I put face1 on some text.
I would like the result to show, wherever both faces are applied to the same
text, both a Blue foreground and White background. However, what happens is
that the last face applied takes precedence - the other face contributes
nothing.
I also tried with definitions like this, also to no avail:
(defface face1 '((t (:background "White" :foreground unspecified))) "1")
(defface face2 '((t (:foreground "Blue" :backround unspecified))) "2")
What's the correct way to do what I want: accumulate (merge) properties from
different faces? (No, I don't want to use overlays here.)
I've consulted the Elisp manual, looked through the code in `faces.el', and
`grep'ed for occurrences of `unspecified' in the Emacs Lisp sources, but
it's still not clear to me how this is supposed to work.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Q on multiple faces as text property `face'
[not found] <mailman.665.1140286270.2856.help-gnu-emacs@gnu.org>
@ 2006-02-18 19:00 ` Johan Bockgård
0 siblings, 0 replies; 2+ messages in thread
From: Johan Bockgård @ 2006-02-18 19:00 UTC (permalink / raw)
"Drew Adams" <drew.adams@oracle.com> writes:
> I have two faces:
> (defface face1 '((t (:background "White"))) "Face 1")
> (defface face2 '((t (:foreground "Blue"))) "Face 2")
>
> Using `put-text-property' with the `face' property:
> I put face2 on some text.
> I put face1 on some text.
>
> I would like the result to show, wherever both faces are applied to
> the same text, both a Blue foreground and White background. However,
> what happens is that the last face applied takes precedence - the
> other face contributes nothing.
It doesn't "take precedence".
put-text-property is a built-in function in `C source code'.
(put-text-property START END PROPERTY VALUE &optional OBJECT)
Set one property of the text from START to END.
^^^
The value of the `face' property is replaced altogether.
> I also tried with definitions like this, also to no avail:
> (defface face1 '((t (:background "White" :foreground unspecified))) "1")
> (defface face2 '((t (:foreground "Blue" :backround unspecified))) "2")
Obviously changing the face definitions will make no difference.
> What's the correct way to do what I want: accumulate (merge) properties from
> different faces? (No, I don't want to use overlays here.)
The value of the face property may be a list. Use/see
`font-lock-prepend-text-property' or `font-lock-append-text-property'.
--
Johan Bockgård
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-02-18 19:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-18 18:10 Q on multiple faces as text property `face' Drew Adams
[not found] <mailman.665.1140286270.2856.help-gnu-emacs@gnu.org>
2006-02-18 19:00 ` Johan Bockgård
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).