unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Aaron Jensen <aaronjensen@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Alp Aker <alptekin.aker@gmail.com>, 30553@debbugs.gnu.org
Subject: bug#30553: 26.0.91; underline appears beneath line-spacing rather than beneath text
Date: Wed, 28 Feb 2018 07:19:02 -0800	[thread overview]
Message-ID: <CAHyO48zs19zCocFauGgE4BU6wzYGw-8iz9RZNxGAbf7zd2c9dw@mail.gmail.com> (raw)
In-Reply-To: <83a7vu1k51.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 441 bytes --]

On Tue, Feb 27, 2018 at 8:18 AM, Eli Zaretskii <eliz@gnu.org> wrote:
> and similarly with other variables (except that a boolean variable
> will return a value of Qt or Qnil, not a number).

Thank you for the feedback. I used NILP and Fbuffer_local_value
because I saw that used elsewhere. If that's not right, please let me
know.

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

Done.

Patch attached, thanks!

[-- Attachment #2: 0001-Allow-buffer-local-underline-position-vars.patch --]
[-- Type: application/octet-stream, Size: 9849 bytes --]

From b97379defb2e3e62783029d1236c724dad0efc23 Mon Sep 17 00:00:00 2001
From: Aaron Jensen <aaronjensen@gmail.com>
Date: Wed, 28 Feb 2018 07:17:14 -0800
Subject: [PATCH] Allow buffer local underline position vars

* src/nsterm.m (ns_draw_text_decoration):
* src/w32term.c (x_draw_glyph_string):
* src/xterm.c (x_draw_glyph_string): Allow buffer local underline
position vars

* src/xdisp.c: Add symbol
---
 src/nsterm.m  | 19 +++++++++++++++----
 src/w32term.c | 18 +++++++++++++++---
 src/xdisp.c   |  1 +
 src/xterm.c   | 19 +++++++++++++++----
 4 files changed, 46 insertions(+), 11 deletions(-)

diff --git a/src/nsterm.m b/src/nsterm.m
index 1919c6defa..a004e73c4b 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -3487,23 +3487,32 @@ Note that CURSOR_WIDTH is meaningful only for (h)bar cursors.
             {
 	      struct font *font = font_for_underline_metrics (s);
               unsigned long descent = s->y + s->height - s->ybase;
+              unsigned long minimum_offset;
+              Lisp_Object val = Fbuffer_local_value (Qunderline_minimum_offset,
+                                                    s->w->contents);
+              if (INTEGERP (val))
+                minimum_offset = XFASTINT (val);
+              else
+                minimum_offset = 1;
 
               /* Use underline thickness of font, defaulting to 1. */
               thickness = (font && font->underline_thickness > 0)
                 ? font->underline_thickness : 1;
 
               /* Determine the offset of underlining from the baseline. */
-              if (x_underline_at_descent_line)
+              if (!NILP (Fbuffer_local_value (Qx_underline_at_descent_line,
+                                              s->w->contents)))
                 position = descent - thickness;
-              else if (x_use_underline_position_properties
+              else if (!NILP (Fbuffer_local_value (Qx_use_underline_position_properties,
+                                                   s->w->contents))
                        && font && font->underline_position >= 0)
                 position = font->underline_position;
               else if (font)
                 position = lround (font->descent / 2);
               else
-                position = underline_minimum_offset;
+                position = minimum_offset;
 
-              position = max (position, underline_minimum_offset);
+              position = max (position, minimum_offset);
 
               /* Ensure underlining is not cropped. */
               if (descent <= position)
@@ -9465,11 +9474,13 @@ Nil means use fullscreen the old (< 10.7) way.  The old way works better with
 	       x_use_underline_position_properties,
      doc: /* SKIP: real doc in xterm.c.  */);
   x_use_underline_position_properties = 0;
+  DEFSYM (Qx_use_underline_position_properties, "x-use-underline-position-properties");
 
   DEFVAR_BOOL ("x-underline-at-descent-line",
 	       x_underline_at_descent_line,
      doc: /* SKIP: real doc in xterm.c.  */);
   x_underline_at_descent_line = 0;
+  DEFSYM (Qx_underline_at_descent_line, "x-underline-at-descent-line");
 
   /* Tell Emacs about this window system.  */
   Fprovide (Qns, Qnil);
diff --git a/src/w32term.c b/src/w32term.c
index 97afb678c1..c3fce0481c 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -2475,13 +2475,22 @@ x_draw_glyph_string (struct glyph_string *s)
               else
                 {
 		  struct font *font = font_for_underline_metrics (s);
+                  unsigned long minimum_offset;
+                  Lisp_Object val = buffer_local_value (Qunderline_minimum_offset,
+                                                        s->w->contents);
+                  if (INTEGERP (val))
+                    minimum_offset = XFASTINT (val);
+                  else
+                    minimum_offset = 1;
 
                   /* Get the underline thickness.  Default is 1 pixel.  */
                   if (font && font->underline_thickness > 0)
                     thickness = font->underline_thickness;
                   else
                     thickness = 1;
-                  if (x_underline_at_descent_line || !font)
+                  if (!NILP (Fbuffer_local_value (Qx_underline_at_descent_line,
+                                                  s->w->contents))
+                      || !font)
                     position = (s->height - thickness) - (s->ybase - s->y);
                   else
                     {
@@ -2493,13 +2502,14 @@ x_draw_glyph_string (struct glyph_string *s)
                          ROUND ((maximum_descent) / 2), with
                          ROUND (x) = floor (x + 0.5)  */
 
-                      if (x_use_underline_position_properties
+                      if (!NILP (Fbuffer_local_value (Qx_use_underline_position_properties,
+                                                      s->w->contents))
                           && font->underline_position >= 0)
                         position = font->underline_position;
                       else
                         position = (font->descent + 1) / 2;
                     }
-                  position = max (position, underline_minimum_offset);
+                  position = max (position, minimum_offset);
                 }
               /* Check the sanity of thickness and position.  We should
                  avoid drawing underline out of the current line area.  */
@@ -7385,11 +7395,13 @@ the cursor have no effect.  */);
 	       x_use_underline_position_properties,
      doc: /* SKIP: real doc in xterm.c.  */);
   x_use_underline_position_properties = 0;
+  DEFSYM (Qx_use_underline_position_properties, "x-use-underline-position-properties");
 
   DEFVAR_BOOL ("x-underline-at-descent-line",
 	       x_underline_at_descent_line,
      doc: /* SKIP: real doc in xterm.c.  */);
   x_underline_at_descent_line = 0;
+  DEFSYM (Qx_underline_at_descent_line, "x-underline-at-descent-line");
 
   DEFVAR_LISP ("x-toolkit-scroll-bars", Vx_toolkit_scroll_bars,
 	       doc: /* SKIP: real doc in xterm.c.  */);
diff --git a/src/xdisp.c b/src/xdisp.c
index 9170d6b777..13f281e8ea 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -32978,6 +32978,7 @@ particularly when using variable `x-use-underline-position-properties'
 with fonts that specify an UNDERLINE_POSITION relatively close to the
 baseline.  The default value is 1.  */);
   underline_minimum_offset = 1;
+  DEFSYM (Qunderline_minimum_offset, "underline-minimum-offset");
 
   DEFVAR_BOOL ("display-hourglass", display_hourglass_p,
 	       doc: /* Non-nil means show an hourglass pointer, when Emacs is busy.
diff --git a/src/xterm.c b/src/xterm.c
index 0d25c7f1a2..abc9be12c9 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -3707,13 +3707,21 @@ x_draw_glyph_string (struct glyph_string *s)
               else
                 {
 		  struct font *font = font_for_underline_metrics (s);
+                  unsigned long minimum_offset;
+                  Lisp_Object val = buffer_local_value (Qunderline_minimum_offset,
+                                                        s->w->contents);
+                  if (INTEGERP (val))
+                    minimum_offset = XFASTINT (val);
+                  else
+                    minimum_offset = 1;
 
                   /* Get the underline thickness.  Default is 1 pixel.  */
                   if (font && font->underline_thickness > 0)
                     thickness = font->underline_thickness;
                   else
                     thickness = 1;
-                  if (x_underline_at_descent_line)
+                  if (!NILP (Fbuffer_local_value (Qx_underline_at_descent_line,
+                                                  s->w->contents)))
                     position = (s->height - thickness) - (s->ybase - s->y);
                   else
                     {
@@ -3725,15 +3733,16 @@ x_draw_glyph_string (struct glyph_string *s)
                          ROUND ((maximum descent) / 2), with
                          ROUND(x) = floor (x + 0.5)  */
 
-                      if (x_use_underline_position_properties
+                      if (!NILP (Fbuffer_local_value (Qx_use_underline_position_properties,
+                                                      s->w->contents))
                           && font && font->underline_position >= 0)
                         position = font->underline_position;
                       else if (font)
                         position = (font->descent + 1) / 2;
                       else
-                        position = underline_minimum_offset;
+                        position = minimum_offset;
                     }
-                  position = max (position, underline_minimum_offset);
+                  position = max (position, minimum_offset);
                 }
               /* Check the sanity of thickness and position.  We should
                  avoid drawing underline out of the current line area.  */
@@ -13246,6 +13255,7 @@ UNDERLINE_POSITION font properties, set this to nil.  You can also use
 `underline-minimum-offset' to override the font's UNDERLINE_POSITION for
 small font display sizes.  */);
   x_use_underline_position_properties = true;
+  DEFSYM (Qx_use_underline_position_properties, "x-use-underline-position-properties");
 
   DEFVAR_BOOL ("x-underline-at-descent-line",
 	       x_underline_at_descent_line,
@@ -13256,6 +13266,7 @@ A value of nil means to draw the underline according to the value of the
 variable `x-use-underline-position-properties', which is usually at the
 baseline level.  The default value is nil.  */);
   x_underline_at_descent_line = false;
+  DEFSYM (Qx_underline_at_descent_line, "x-underline-at-descent-line");
 
   DEFVAR_BOOL ("x-mouse-click-focus-ignore-position",
 	       x_mouse_click_focus_ignore_position,
-- 
2.15.1


  reply	other threads:[~2018-02-28 15:19 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-20 18:16 bug#30553: 26.0.91; underline appears beneath line-spacing rather than beneath text Aaron Jensen
2018-02-20 19:33 ` Eli Zaretskii
2018-02-20 19:44   ` Aaron Jensen
2018-02-21  1:46     ` Alp Aker
2018-02-21  4:23       ` Eli Zaretskii
2018-02-21  4:27         ` Aaron Jensen
2018-02-21  5:01           ` Alp Aker
2018-02-21  6:03             ` Aaron Jensen
2018-02-21 13:47               ` Alp Aker
2018-02-21 16:17                 ` Aaron Jensen
2018-02-21 17:56                   ` Eli Zaretskii
2018-02-22  2:15                     ` Aaron Jensen
2018-02-22  6:26                       ` Eli Zaretskii
2018-02-22  6:29                         ` Aaron Jensen
2018-02-22  7:21                           ` Eli Zaretskii
2018-02-25 22:09                     ` Aaron Jensen
2018-02-26 15:42                       ` Eli Zaretskii
2018-02-26 16:01                         ` Aaron Jensen
2018-02-26 19:25                           ` Eli Zaretskii
2018-02-26 20:21                             ` Aaron Jensen
2018-02-26 20:41                               ` Eli Zaretskii
2018-02-26 20:46                                 ` Eli Zaretskii
2018-02-26 21:05                                 ` Aaron Jensen
2018-02-27 14:19                                   ` Aaron Jensen
2018-02-27 16:18                                     ` Eli Zaretskii
2018-02-28 15:19                                       ` Aaron Jensen [this message]
2018-02-28 16:14                                         ` Eli Zaretskii
2018-02-28 17:41                                           ` Aaron Jensen
2018-02-28 17:56                                             ` Eli Zaretskii
2018-03-01  8:36                                               ` Aaron Jensen
2018-03-08  6:31                                                 ` Aaron Jensen
2018-03-08 13:45                                                   ` Eli Zaretskii
2018-03-10 11:18                                                 ` Eli Zaretskii
2018-03-10 17:47                                                   ` Aaron Jensen
2018-03-10 18:48                                                     ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAHyO48zs19zCocFauGgE4BU6wzYGw-8iz9RZNxGAbf7zd2c9dw@mail.gmail.com \
    --to=aaronjensen@gmail.com \
    --cc=30553@debbugs.gnu.org \
    --cc=alptekin.aker@gmail.com \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).