Subject: Re: bug#30553: 26.0.91; underline appears beneath line-spacing rather than beneath text

From: Eli Zaretskii <[email-masked]>
Date: Mon, 26 Feb 2018 21:25:45 +0200

> From: Aaron Jensen <[email-masked]>
> Date: Mon, 26 Feb 2018 08:01:03 -0800
> Cc: Alp Aker <[email-masked]>, [email-masked]
> 
> > In general, you cannot assume in display code that buffer-local
> > variables have their expected values, because redisplay needs to
> > redraw windows other than the selected one, and when it does so, the
> > window's buffer is not made the current one in the full sense of the
> > word.  What you saw is the display engine using the value from the
> > last buffer that was current before a redisplay cycle.  So you need to
> > explicitly access buffer-local values by calling buffer_local_value;
> > see the examples of that in xdisp.c.
> 
> Ok, that makes sense. Would you like me to make that change for all of
> them given my description below?

"All" meaning the two involved in the underline position, right?  Yes,
that would be a good addition, I think.

> Is there some performance penalty to this?

Not really, no.  If the variable is buffer-local, it will incur a
small penalty, but we already have a couple of such variables
elsewhere in the display, so I doubt one more will make any tangible
difference.  And for the usual case of a global symbol, there's no
penalty beyond a function call.

> I briefly described this above, but here are some more details. Today,
> globally, I'm using:
> 
>             (setq x-underline-at-descent-line t)
> 
> This was the default in spacemacs and it's likely because of #30609
> (underlines drawn over descenders make text hard to read) and
> different colored underlines are used heavily with flycheck.

So it's spacemacs' fault, perhaps exasperated by choosing some font
and/or colors that make this issue more prominent.  Right?  Then how
about asking the spacemacs developers to improve the situation on
their end?

>             (setq-local line-spacing 1)
>             (setq-local x-underline-at-descent-line nil)
>             (setq-local x-use-underline-position-properties t)
> 
> For reasons that led me to create this initial bug report:
> x-underline-at-descent-line looks terrible when line-spacing > 0.
> 
> With this variable, you are right, I no longer need to use
> `setq-local`, I can just set this variable globally and it will look
> reasonable for code and prose.

Good, that's what I thought.

> That said, I'm not sure exactly what you meant by: "if you set these
> variables to ignore the line-spacing", are you referring to the new
> variable I introduced or are you OK with me making a change to
> x-underline-at-descent-line to ignore line spacing?

I meant to suggest what you did: customize x-underline-at-descent-line
such that it avoids the effect of line-spacing you didn't like.  I
assumed that such a setting will solve your problems everywhere.
Nonetheless, making it possible to customize those locally for one
buffer would be a good improvement, IMO.

Thanks.