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

From: Eli Zaretskii <[email-masked]>
Date: Tue, 27 Feb 2018 18:18:18 +0200

> From: Aaron Jensen <[email-masked]>
> Date: Tue, 27 Feb 2018 06:19:00 -0800
> Cc: Alp Aker <[email-masked]>, [email-masked]
> 
> Patch for buffer local underline position variables. I ended up making
> underline-minimum-offset buffer local capable as well.

Does that mean that underline-minimum-offset allows you to avoid
problems with underline overwriting the descents?

> +              unsigned long minimum_offset =
> +                buffer_local_value (Qunderline_minimum_offset, s->w->contents);

This isn't right.  buffer_local_value returns a Lisp object, not an
integer, so you need to convert it to an integer (or a boolean for
other variables).  And it can also return the symbol Qunbound, in
which case we need a fallback.  So we need something like

    Lisp_Object val = buffer_local_value (Qunderline_minimum_offset,
                                          s->w->contents);
    if (INTEGERP (val))
      minimum_offset = XFASTINT (val);
    else
      minimum_offset = 1;

and similarly with other variables (except that a boolean variable
will return a value of Qt or Qnil, not a number).

> +  DEFSYM (Qunderline_minimum_offset, "underline-minimum-offset");

I think this symbol should be in xdisp.c, where the variable is
defined.