Subject: bug#50506: 28.0.50; display-line-numbers equivalent for linum-format?

From: Michael Gallagher - NOAA Affiliate <[email-masked]>
Date: Wed, 15 Sep 2021 09:22:18 -0600

Eli, I did indeed. I've added corrections to account for L2R vs R2L and the
updated patch is attached. Let me know what you think

On Tue, Sep 14, 2021 at 11:35 AM Eli Zaretskii <[email-masked]> wrote:

> > From: Michael Gallagher - NOAA Affiliate <[email-masked]>
> > Date: Tue, 14 Sep 2021 10:17:31 -0600
> > Cc: Lars Ingebrigtsen <[email-masked]>, [email-masked]
> >
> > OK. Here we go. I found some time last night. Attached is a git patch
> file for changes that implement this
> > feature request as well as (GNU) diffs for the individual files in
> question. It's a pretty simple commit. It's worth
> > noting that I'm probably overlooking something in how I create the
> glyph, I definitely don't understand the
> > nuances of the display code. But I hope it's helpful.
>
> Thanks.  But I don't see that you did anything about the problem with
> R2L lines.  What happens if you turn on display-line-numbers-mode in
> the buffer that visits TUTORIAL.he, and then turn on this feature in
> that buffer? don't you see the separator line on the wrong side of the
> line numbers?
>

-- 
Michael Gallagher, PhD
CIRES Research Scientist
Polar Observations and Processes Team (ESRL/NOAA/PSD)
325 Broadway, Boulder, Colorado 80305
From 550d2716feb78cf6353e8d9a8f63b7fd12adfd83 Mon Sep 17 00:00:00 2001
From: polair <[email-masked]>
Date: Wed, 15 Sep 2021 09:18:58 -0600
Subject: [PATCH 21/21] inclusion of line number separator character

---
 lisp/cus-start.el |  6 ++++++
 lisp/frame.el     |  1 +
 src/xdisp.c       | 24 ++++++++++++++++++++++++
 3 files changed, 31 insertions(+)

diff --git a/lisp/cus-start.el b/lisp/cus-start.el
index 1a3e5682bba..c755aaa41cf 100644
--- a/lisp/cus-start.el
+++ b/lisp/cus-start.el
@@ -740,6 +740,12 @@ minibuffer-prompt-properties--setter
                (const :tag "Visually relative line numbers"
                       :value visual))
               "26.1")
+             (display-line-numbers-separator-character
+              display-line-numbers
+              (character :tag "Character to separate numbers from buffer")
+              :safe (lambda (value) (or (characterp value) (null value)))
+              "28.05")
+              ;:safe (lambda (value) (or (characterp value) (null value))))
              (display-line-numbers-width
               display-line-numbers
               (choice
diff --git a/lisp/frame.el b/lisp/frame.el
index 60234fc2ae9..c6975a71cf2 100644
--- a/lisp/frame.el
+++ b/lisp/frame.el
@@ -2876,6 +2876,7 @@ set-frame-property--interactive
         header-line-format
         tab-line-format
         display-line-numbers
+        display-line-numbers-separator-character
         display-line-numbers-width
         display-line-numbers-current-absolute
         display-line-numbers-widen
diff --git a/src/xdisp.c b/src/xdisp.c
index d30a68570f0..32fc6089292 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -23265,6 +23265,14 @@ maybe_produce_line_number (struct it *it)
 	tem_it.face_id = merge_faces (it->w, Qline_number_minor_tick,
 				      0, DEFAULT_FACE_ID);
     }
+  if (FIXNATP (Vdisplay_line_numbers_separator_character)
+      && it->paragraph_embedding != L2R)
+    {
+      tem_it.c = tem_it.char_to_display = XFIXNAT (Vdisplay_line_numbers_separator_character);
+      tem_it.len = 1;
+      SET_TEXT_POS (tem_it.position, -1, -1);
+      PRODUCE_GLYPHS (&tem_it);
+    }
 
   /* Produce glyphs for the line number in a scratch glyph_row.  */
   for (const char *p = lnum_buf; *p; p++)
@@ -23296,6 +23304,15 @@ maybe_produce_line_number (struct it *it)
 	}
     }
 
+  if (FIXNATP (Vdisplay_line_numbers_separator_character)
+      && it->paragraph_embedding == L2R)
+    {
+      tem_it.c = tem_it.char_to_display = XFIXNAT (Vdisplay_line_numbers_separator_character);
+      tem_it.len = 1;
+      SET_TEXT_POS (tem_it.position, -1, -1);
+      PRODUCE_GLYPHS (&tem_it);
+    }
+
   inhibit_free_realized_faces = save_free_realized_faces;
 
   /* Record the width in pixels we need for the line number display.  */
@@ -35509,6 +35526,13 @@ syms_of_xdisp (void)
   DEFSYM (Qrelative, "relative");
   DEFSYM (Qvisual, "visual");
 
+  DEFVAR_LISP ("display-line-numbers-separator-character", Vdisplay_line_numbers_separator_character,
+    doc: /* Character to draw between line numbers and buffer when non-nil. Some interesting
+options are: ├, ╞, │, ┃, ║, ▶, ⧽, and ⟫ */);
+  Vdisplay_line_numbers_separator_character = Qnil;
+  DEFSYM (Qdisplay_line_numbers_separator_character, "display-line-numbers-separator-character");
+  //Fmake_variable_buffer_local (Qdisplay_line_numbers_separator_character);
+
   DEFVAR_LISP ("display-line-numbers-width", Vdisplay_line_numbers_width,
     doc: /* Minimum width of space reserved for line number display.
 A positive number means reserve that many columns for line numbers,
-- 
2.33.0