From 6a9428999ca048bb357d6448564a737edd61743e Mon Sep 17 00:00:00 2001
From: Juanma Barranquero <lekktu@gmail.com>
Date: Tue, 1 Oct 2019 10:44:49 +0200
Subject: [PATCH] New faces to higlight line numbers multiple of 5 and 10

* lisp/faces.el (line-number-fith-line, line-number-tenth-line):
New faces.
* src/xdisp.c (maybe_produce_line_number): Use new faces for lines
that are multiple of 5 and 10.
(syms_of_xdisp) <line-number-fith-line, line-number-tenth-line>:
Defsym them.
* etc/NEWS: Announce them.
* doc/emacs/display.texi (Display Custom): Describe them.
---
 doc/emacs/display.texi |  4 +++-
 etc/NEWS               |  5 +++++
 lisp/faces.el          | 31 +++++++++++++++++++++++++++++++
 src/xdisp.c            | 10 ++++++++++
 4 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/doc/emacs/display.texi b/doc/emacs/display.texi
index 6fc99bd271..1acd056f94 100644
--- a/doc/emacs/display.texi
+++ b/doc/emacs/display.texi
@@ -1865,7 +1865,9 @@ Display Custom
 The current line number is displayed in a different face,
 @code{line-number-current-line}, so you can make the current line's
 number have a distinct appearance, which will help locating the line
-showing point.
+showing point. Additional faces @code{line-number-fifth-line} and
+@code{line-number-tenth-line} can be used to highlight the line number
+of every fifth or tenth line, if desired.
 
 @vindex visible-bell
   If the variable @code{visible-bell} is non-@code{nil}, Emacs attempts
diff --git a/etc/NEWS b/etc/NEWS
index 9a9e25bea9..c2fef47220 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -553,6 +553,11 @@ network connection information (in addition to the host name).
 *** When called interactively with a prefix arg 'C-u', 'desktop-read'
 now prompts the user for the directory containing the desktop file.
 
++++
+** display-line-numbers-mode
+*** New faces 'line-number-fifth-line' and 'line-number-tenth-line'
+can be used to highlight the line number of every fifth or tenth line.
+
 +++
 ** winner
 *** A new variable, 'winner-boring-buffers-regexp', has been added.
diff --git a/lisp/faces.el b/lisp/faces.el
index 9c5ffe1e59..6edb6bde96 100644
--- a/lisp/faces.el
+++ b/lisp/faces.el
@@ -2390,6 +2390,37 @@ line-number-current-line
   :group 'basic-faces
   :group 'display-line-numbers)
 
+(defface line-number-fifth-line
+  '((t :inherit line-number))
+  "Face for displaying line numbers that end in 5.
+That is, multiple of 5 but not of 10.
+This face is used when `display-line-numbers' is non-nil.
+
+If you customize the font of this face, make sure it is a
+monospaced font, otherwise line numbers will not line up,
+and text lines might move horizontally as you move through
+the buffer.  Similarly, making this face's font different
+from that of the `line-number' face could produce such
+unwanted effects."
+  :version "27.1"
+  :group 'basic-faces
+  :group 'display-line-numbers)
+
+(defface line-number-tenth-line
+  '((t :inherit line-number))
+  "Face for displaying line numbers that are multiples of 10.
+This face is used when `display-line-numbers' is non-nil.
+
+If you customize the font of this face, make sure it is a
+monospaced font, otherwise line numbers will not line up,
+and text lines might move horizontally as you move through
+the buffer.  Similarly, making this face's font different
+from that of the `line-number' face could produce such
+unwanted effects."
+  :version "27.1"
+  :group 'basic-faces
+  :group 'display-line-numbers)
+
 ;; Definition stolen from display-line-numbers.
 (defface fill-column-indicator
   '((t :inherit shadow :weight normal :slant normal
diff --git a/src/xdisp.c b/src/xdisp.c
index 95895ec3ac..aebd460d55 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -21482,6 +21482,10 @@ maybe_produce_line_number (struct it *it)
   int lnum_face_id = merge_faces (it->w, Qline_number, 0, DEFAULT_FACE_ID);
   int current_lnum_face_id
     = merge_faces (it->w, Qline_number_current_line, 0, DEFAULT_FACE_ID);
+  int fifth_lnum_face_id
+    = merge_faces (it->w, Qline_number_fifth_line, 0, DEFAULT_FACE_ID);
+  int tenth_lnum_face_id
+    = merge_faces (it->w, Qline_number_tenth_line, 0, DEFAULT_FACE_ID);
   /* Compute point's line number if needed.  */
   if ((EQ (Vdisplay_line_numbers, Qrelative)
        || EQ (Vdisplay_line_numbers, Qvisual)
@@ -21575,6 +21579,10 @@ maybe_produce_line_number (struct it *it)
 	     empty lines beyond EOB.  */
 	  && it->what != IT_EOB)
 	tem_it.face_id = current_lnum_face_id;
+      else if (lnum_to_display % 10 == 0)
+	tem_it.face_id = tenth_lnum_face_id;
+      else if (lnum_to_display % 5 == 0)
+	tem_it.face_id = fifth_lnum_face_id;
       else
 	tem_it.face_id = lnum_face_id;
       if (beyond_zv
@@ -32970,6 +32978,8 @@ syms_of_xdisp (void)
   /* Names of the faces used to display line numbers.  */
   DEFSYM (Qline_number, "line-number");
   DEFSYM (Qline_number_current_line, "line-number-current-line");
+  DEFSYM (Qline_number_fifth_line, "line-number-fifth-line");
+  DEFSYM (Qline_number_tenth_line, "line-number-tenth-line");
   /* Name of a text property which disables line-number display.  */
   DEFSYM (Qdisplay_line_numbers_disable, "display-line-numbers-disable");
 
-- 
2.21.0.windows.1

