help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Overriding inherited face attributes


From: Stephen Berman
Subject: Re: Overriding inherited face attributes
Date: Wed, 28 Nov 2018 13:24:51 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

On Wed, 28 Nov 2018 08:19:20 +0200 Eli Zaretskii <eliz@gnu.org> wrote:

>> From: Stephen Berman <stephen.berman@gmx.net>
>> Date: Tue, 27 Nov 2018 22:33:23 +0100
>> Cc: help-gnu-emacs@gnu.org
>> 
>> In (info "(elisp) Special Properties") it says this: "The value of the
>> [`face'] property can be... A list of faces... Faces occurring earlier
>> in the list have higher priority."  And in (info "(elisp) Face
>> Attributes") it says: "Attributes from inherited faces are merged into
>> the face like an underlying face would be, with higher priority than
>> underlying faces."  Whether this implies the above observed behavior is
>> not clear to me.
>
> Is it really not clear?  What part(s) make(s) the above text not
> clear about the order in which the face attributes are applied?

The text itself is clear in the abstract, and when I apply it to the
example Boris gave, it seems to explain the observed result.  That is,
given this form:

(insert (propertize "hello" 'face '(:foreground "red" :inherit
(:foreground "orange"))))

and given that "Faces occurring earlier in the list have higher
priority", I would expect the displayed face to be red, as Boris did.
But it's different with the `inherit' property: "Attributes from
inherited faces are merged into the face like an underlying face would
be, with higher priority than underlying faces".  So that explains why
the face is displayed as orange.  But then I observed that merely
switching the order:

(insert (propertize "hello" 'face '(:inherit (:foreground "orange")
:foreground "red")))

makes the face display as red, and this seems to conflict with the above
documentation.  Maybe I'm misunderstanding the doc, but in any case,
because of the difference from switching the order of the properties,
it's not clear to me.

(The same seems to go for form Boris gave in his followup, which you
suggested is syntactically incorrect, but does evaluate without error
and displays a red face; as Boris noted, that syntax is the same as the
result of applying add-face-text-property.)

Steve Berman



reply via email to

[Prev in Thread] Current Thread [Next in Thread]