Subject: Re: bug#38563: 27.0.50; Company popup renders with newlines (?) inheriting the bg properties of the character at next line's bol

From: Eli Zaretskii <[email-masked]>
Date: Sat, 14 Dec 2019 10:13:55 +0200

> Cc: [email-masked]
> From: Dmitry Gutov <[email-masked]>
> Date: Sat, 14 Dec 2019 01:10:13 +0200
> 
> On 13.12.2019 17:32, Eli Zaretskii wrote:
> 
> > ':extend nil' is "used" during merging in the sense that such a face
> > is skipped when we want a face for extending past EOL.  How else could
> > we implement that?  Setting :extend to nil means that _none_ of the
> > other attributes of the face are to be taken into account for merging.
> 
> We are talking about "merging" a list of faces applied to a 'face' text 
> property on a char, right? That kind of merging?

We are talking about face merging for displaying a character, yes.
That process merges face information from all the sources that are in
effect for that character.  See the description at the beginning of
the "Displaying Faces" node in the ELisp manual.

When we merge faces for display past EOL, we modify the face-merging
process such that faces whose :extend attribute is not t are not
merged.  "Not merged" means here that these faces are bypassed by the
merging process, so their attributes (not just the background color)
do not contribute anything to the result of the merge.

> If so, I would expect seeing ':extend nil' would mean not using any of 
> the face attributes on that char for extending past EOL.

Indeed, but only for the face whose :extend is not t.  Other faces do
contribute the attributes to the merge.

> If it's the last character on the line, using the default face's
> attributes instead.

Why default?  There could be several faces involved (e.g., some
font-lock face, plus region, plus the face from the overlay string at
that position).  Any of these faces whose :extend is t will get
merged for character past EOL, the rest of the faces will not.

> And if we see ':extend t', then we would use the background from the 
> first face in the list that has the :background attribute set. Is that 
> not how merging faces in a list value usually works?

No.  The :extend attribute affects only the face where that attribute
is set.  It doesn't affect other faces, and also it affects all the
attributes, not just the background color.

> > Inheritance just makes the inheriting face implicitly behave as if its
> > :extend attribute is the same as of the parent face, when the
> > inheriting face doesn't itself specify :extend, i.e. has it set to
> > 'unspecified'.
> 
> I think that's how inheritance for most attributes works, right?

Yes.