Subject: bug#23574: 24.5; Overzealous underlining in emacs-nox

From: martin rudalics <[email-masked]>
Date: Wed, 08 Jun 2016 08:33:30 +0200

> Talk about over-specification ;-)
 >
 > I hope you realize how some of that will make redisplay much more
 > expensive?

Yes.  But the only value I really care about is nil ;-)

 > How about the following more modest alternative?
 >
 > (defcustom face-extend-to-window-edge t
 >     "Non-nil means extend face of last character on line to window edge.
 >
 > Certain face attributes, if present in the face of the last character
 > of a line and different from those of the default face, cause the
 > empty space following the end of text on the line to be drawn with
 > those attributes, to give the empty space appearance similar to that
 > of the preceding text.  These attributes are those which affect the
 > background of a face: `:background', `:stipple', `:box', `:underline',
 > `:overline', and `:strike-through'.  By default, if the face of a
 > line's last character has any of these attributes, and the value is
 > different from that of the default face, the empty space following the
 > line's text will be drawn in the face of the last character.
 >
 > This variable allows fine-tuning which attributes trigger the face
 > extension.  The default value of t means any of the mentioned
 > attributes will cause face extension.  The value of nil means face
 > extension is turned off.  A value that is a list of attributes will
 > extend the face only if any of the attributes from the list are
 > present in the last character's face.  Note that only attributes from
 > the above list are meaningful in list values of this variable.")

This has the advantage of a much better doc-string.  The only details
missing are whether the last character of a line is the newline
character, whether a non-printable character's attributes count, how
invisible characters are treated and whether the :display attribute has
any impact.  Since I have no good idea about all of these I deliberately
did not try to cover them.

I'm not sure whether your proposal (it obviously was my first idea as
well) is less expensive, though.  If the value of our variable is a
list, the display engine has to go through the properties of the last
character and compare them against the members of this list.  Or go
through all members of the list and compare them against the character's
properties - neither of these approaches is cheap even if optimizations
are applied.

And then I thought about the - possibly silly idea - that a user might
want to put a property like :background on all lines displayed,
regardless of the last character's attributes.  Such a user would have
to, before displaying the relevant buffer parts, go through all these
lines and add that property to the newline (?) character of each line.
Now I bet that the greater part of such users would put the property on
all newline characters of the buffer instead of using something like
‘pre-redisplay-functions’ where even I couldn't tell whether it gets the
window's start and end positions always right.

martin