From: Juanma Barranquero <lekktu@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: wavexx@thregr.org, spacibba@aol.com,
Lars Magne Ingebrigtsen <larsi@gnus.org>,
Emacs developers <emacs-devel@gnu.org>
Subject: Re: Native line numbers landed on master
Date: Thu, 3 Oct 2019 06:11:41 +0200 [thread overview]
Message-ID: <CAAeL0SR-vitQv5cb3w6VX=sL2uJomh9v1DLs05FiXWLLnAgcnA@mail.gmail.com> (raw)
In-Reply-To: <83lfu389vn.fsf@gnu.org>
[-- Attachment #1.1: Type: text/plain, Size: 423 bytes --]
New patch attached.
Faces are now 'line-number-Nth-line' and 'line-number-Mth-line', and
customizable options to set the numbers are 'display-line-numbers-Nth-line'
and 'display-line-numbers-Mth-line'. Better names, or wording, or
customization type, are welcome.
Both options default to 0 and so are initially disabled. (But I've set up
the customization so when setting them, 10 and 5 are suggested as default
values.)
[-- Attachment #1.2: Type: text/html, Size: 530 bytes --]
[-- Attachment #2: 0001-Allow-highlighting-line-numbers-that-are-multiple-of.patch --]
[-- Type: application/octet-stream, Size: 8074 bytes --]
From c83c8bdd49b8639a2824e489698c70e36d54fe42 Mon Sep 17 00:00:00 2001
From: Juanma Barranquero <lekktu@gmail.com>
Date: Thu, 3 Oct 2019 06:04:53 +0200
Subject: [PATCH] Allow highlighting line numbers that are multiple of given
values
* lisp/faces.el (line-number-Nth-line, line-number-Mth-line):
New faces.
* lisp/cus-start.el (display-line-numbers-Nth-line)
(display-line-numbers-Mth-line): Add customization info.
* src/xdisp.c (syms_of_xdisp) <display-line-numbers-Nth-line>
<display-line-numbers-Mth-line>: Defvar new options.
(syms_of_xdisp) <line-number-Nth-line, line-number-Mth-line>:
Defsym new faces.
(maybe_produce_line_number): Use new faces for line numbers
that are multiple of `display-line-numbers-Nth-line' and
`display-line-numbers-Mth-line'.
* etc/NEWS (value): Announce new feature.
* doc/emacs/display.texi (Display Custom): Describe it.
---
doc/emacs/display.texi | 6 +++++-
etc/NEWS | 10 ++++++++++
lisp/cus-start.el | 12 ++++++++++++
lisp/faces.el | 32 ++++++++++++++++++++++++++++++++
src/xdisp.c | 27 +++++++++++++++++++++++++++
5 files changed, 86 insertions(+), 1 deletion(-)
diff --git a/doc/emacs/display.texi b/doc/emacs/display.texi
index 84363d0f0d..0bd3ae85e3 100644
--- a/doc/emacs/display.texi
+++ b/doc/emacs/display.texi
@@ -1871,7 +1871,11 @@ 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-Nth-line} and
+@code{line-number-Mth-line} can be used to highlight the line number
+of lines multiple of certain numbers which can be customized via the
+variables @code{display-line-numbers-Nth-line} and
+@code{display-line-numbers-Mth-line} respectively.
@vindex visible-bell
If the variable @code{visible-bell} is non-@code{nil}, Emacs attempts
diff --git a/etc/NEWS b/etc/NEWS
index 00a01999a7..f14d73ef91 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -553,6 +553,16 @@ 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-Nth-line' and 'line-number-Mth-line',
+and customizable variables 'display-line-numbers-Nth-line' and
+'display-line-numbers-Mth-line', can be used to highlight the line
+numbers of lines multiple of N and M.
+
+*** 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/cus-start.el b/lisp/cus-start.el
index e61c1954a1..8ff1bd33ec 100644
--- a/lisp/cus-start.el
+++ b/lisp/cus-start.el
@@ -655,6 +655,18 @@ minibuffer-prompt-properties--setter
(const :tag "Count lines from beginning of narrowed region"
:value nil))
"26.1")
+ (display-line-numbers-Nth-line
+ display-line-numbers
+ (choice
+ (const :tag "No line" 0)
+ (integer :tag "Multiples of" 10))
+ "27.1")
+ (display-line-numbers-Mth-line
+ display-line-numbers
+ (choice
+ (const :tag "No line" 0)
+ (integer :tag "Multiples of" 5))
+ "27.1")
(display-fill-column-indicator
display-fill-column-indicator
diff --git a/lisp/faces.el b/lisp/faces.el
index 9c5ffe1e59..cb0b8b77af 100644
--- a/lisp/faces.el
+++ b/lisp/faces.el
@@ -2390,6 +2390,38 @@ line-number-current-line
:group 'basic-faces
:group 'display-line-numbers)
+(defface line-number-Nth-line
+ '((t :inherit line-number))
+ "Face for highlighting the line number of every Nth line.
+This face is used when `display-line-numbers' is non-nil and
+variable `display-line-numbers-Nth-line' has a positive value.
+
+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-Mth-line
+ '((t :inherit line-number))
+ "Face for highlighting the line number of every Mth line.
+This face is used when `display-line-numbers' is non-nil and
+variable `display-line-numbers-Mth-line' has a positive value.
+
+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 89a72ff751..225fb02576 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -22566,6 +22566,14 @@ 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 (RANGED_FIXNUMP (1, Vdisplay_line_numbers_Nth_line, INT_MAX)
+ && (lnum_to_display % XFIXNUM (Vdisplay_line_numbers_Nth_line) == 0))
+ tem_it.face_id = merge_faces (it->w, Qline_number_Nth_line,
+ 0, DEFAULT_FACE_ID);
+ else if (RANGED_FIXNUMP (1, Vdisplay_line_numbers_Mth_line, INT_MAX)
+ && (lnum_to_display % XFIXNUM (Vdisplay_line_numbers_Mth_line) == 0))
+ tem_it.face_id = merge_faces (it->w, Qline_number_Mth_line,
+ 0, DEFAULT_FACE_ID);
else
tem_it.face_id = lnum_face_id;
if (beyond_zv
@@ -34006,6 +34014,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_Nth_line, "line-number-Nth-line");
+ DEFSYM (Qline_number_Mth_line, "line-number-Mth-line");
/* Name of a text property which disables line-number display. */
DEFSYM (Qdisplay_line_numbers_disable, "display-line-numbers-disable");
@@ -34641,6 +34651,23 @@ syms_of_xdisp (void)
DEFSYM (Qdisplay_fill_column_indicator_character, "display-fill-column-indicator-character");
Fmake_variable_buffer_local (Qdisplay_fill_column_indicator_character);
+ DEFVAR_LISP ("display-line-numbers-Nth-line", Vdisplay_line_numbers_Nth_line,
+ doc: /* If an integer N > 0, highlight line number of every Nth line.
+The line number is shown with the `line-number-Nth-line' face.
+Otherwise, no special highlighting is done every Nth lines. */);
+ Vdisplay_line_numbers_Nth_line = make_fixnum (0);
+ DEFSYM (Qdisplay_line_numbers_Nth_line, "display-line-numbers-Nth-line");
+ Fmake_variable_buffer_local (Qdisplay_line_numbers_Nth_line);
+
+ DEFVAR_LISP ("display-line-numbers-Mth-line", Vdisplay_line_numbers_Mth_line,
+ doc: /* If an integer M > 0, highlight line number of every Mth line.
+The line number is shown with the `line-number-Mth-line' face.
+Otherwise, no special highlighting is done every Mth lines.
+Note that `display-line-numbers-Nth-line' takes precedence. */);
+ Vdisplay_line_numbers_Mth_line = make_fixnum (0);
+ DEFSYM (Qdisplay_line_numbers_Mth_line, "display-line-numbers-Mth-line");
+ Fmake_variable_buffer_local (Qdisplay_line_numbers_Mth_line);
+
DEFVAR_BOOL ("inhibit-eval-during-redisplay", inhibit_eval_during_redisplay,
doc: /* Non-nil means don't eval Lisp during redisplay. */);
inhibit_eval_during_redisplay = false;
--
2.23.0.windows.1
next prev parent reply other threads:[~2019-10-03 4:11 UTC|newest]
Thread overview: 129+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-08 7:58 Native line numbers landed on master Eli Zaretskii
2017-07-08 8:41 ` martin rudalics
2017-07-08 10:23 ` Eli Zaretskii
2017-07-08 22:38 ` Alex
2017-07-09 14:22 ` Eli Zaretskii
2017-07-09 22:56 ` Alex
2017-07-10 17:50 ` Eli Zaretskii
2017-07-10 20:31 ` Alex
2017-07-11 15:12 ` Eli Zaretskii
2017-07-11 20:44 ` Alex
2017-07-12 14:40 ` Eli Zaretskii
2017-07-16 7:30 ` Alex
2017-07-16 14:10 ` Eli Zaretskii
2017-07-16 19:31 ` Alex
2017-07-17 15:00 ` Eli Zaretskii
2017-07-17 20:34 ` Alex
2017-07-22 9:18 ` Eli Zaretskii
2017-07-10 22:19 ` John Wiegley
2017-07-11 2:29 ` Eli Zaretskii
2017-07-11 15:27 ` Stefan Monnier
2017-07-11 16:04 ` Eli Zaretskii
2017-07-11 16:16 ` Stefan Monnier
2017-07-11 17:23 ` Eli Zaretskii
2017-07-11 17:48 ` Stefan Monnier
2017-07-11 18:04 ` Eli Zaretskii
2017-07-11 18:19 ` Stefan Monnier
2017-07-11 18:18 ` Sharp-quoting function symbols (Was: Native line numbers landed on master) Kaushal Modi
2017-09-30 18:36 ` Philipp Stephani
2017-12-30 21:09 ` Philipp Stephani
2017-07-10 16:51 ` Native line numbers landed on master Filipe Silva
2017-07-11 13:00 ` Robert Pluim
2017-07-11 13:37 ` Jean-Christophe Helary
2017-07-11 13:47 ` Robert Pluim
2017-07-11 14:19 ` Jean-Christophe Helary
2017-07-11 15:24 ` Eli Zaretskii
2017-07-11 15:29 ` Robert Pluim
2017-07-11 16:07 ` Eli Zaretskii
2017-07-11 16:12 ` Robert Pluim
2017-07-11 17:33 ` Eli Zaretskii
2017-07-12 3:23 ` Kaushal Modi
2017-07-12 7:11 ` martin rudalics
2017-07-12 14:27 ` Eli Zaretskii
2017-07-12 15:49 ` martin rudalics
2017-07-15 22:02 ` Yuri D'Elia
2017-07-16 2:34 ` Eli Zaretskii
2017-07-16 14:25 ` Eli Zaretskii
2017-07-17 9:44 ` Yuri D'Elia
2017-07-17 14:16 ` Eli Zaretskii
2019-06-10 2:46 ` Juanma Barranquero
2019-06-10 8:32 ` Yuri D'Elia
2019-06-10 12:38 ` Juanma Barranquero
2019-06-10 15:22 ` Eli Zaretskii
2019-06-10 15:32 ` Juanma Barranquero
2019-06-10 15:33 ` Yuri D'Elia
2019-06-10 15:54 ` Eli Zaretskii
2019-06-10 16:23 ` Yuri D'Elia
2019-06-10 17:41 ` Eli Zaretskii
2019-09-30 10:01 ` Juanma Barranquero
2019-09-30 10:21 ` Eli Zaretskii
2019-10-01 5:44 ` Juanma Barranquero
2019-10-01 7:05 ` Eli Zaretskii
2019-10-01 8:49 ` Juanma Barranquero
2019-10-01 8:55 ` Juanma Barranquero
2019-10-01 9:26 ` Eli Zaretskii
2019-10-01 9:25 ` Eli Zaretskii
2019-10-01 9:09 ` Yuri D'Elia
2019-10-01 9:21 ` Juanma Barranquero
2019-10-01 9:51 ` Yuri D'Elia
2019-10-01 10:23 ` Juanma Barranquero
2019-10-01 10:40 ` Yuri D'Elia
2019-10-01 10:39 ` Eli Zaretskii
2019-10-01 10:47 ` Lars Ingebrigtsen
2019-10-01 11:07 ` Eli Zaretskii
2019-10-01 11:11 ` Juanma Barranquero
2019-10-01 22:52 ` Ergus
2019-10-01 23:51 ` Juanma Barranquero
2019-10-02 3:41 ` Ergus
2019-10-02 9:40 ` Juanma Barranquero
2019-10-02 13:56 ` Ergus
2019-10-02 15:06 ` Eli Zaretskii
2019-10-03 4:11 ` Juanma Barranquero [this message]
2019-10-03 8:16 ` martin rudalics
2019-10-03 14:43 ` Juanma Barranquero
2019-10-03 9:10 ` Robert Pluim
2019-10-03 14:47 ` Juanma Barranquero
2019-10-03 15:18 ` Robert Pluim
2019-10-03 20:37 ` Stefan Kangas
2019-10-03 21:48 ` Juanma Barranquero
2019-10-03 22:37 ` Yuri D'Elia
2019-10-04 1:51 ` Juanma Barranquero
2019-10-04 7:45 ` Eli Zaretskii
2019-10-04 9:52 ` Yuri D'Elia
2019-10-04 10:24 ` Juanma Barranquero
2019-10-05 6:26 ` Juanma Barranquero
2019-10-07 0:14 ` Juanma Barranquero
2019-10-07 6:54 ` Robert Pluim
2019-10-07 7:39 ` Juanma Barranquero
2019-10-07 8:09 ` Robert Pluim
2019-10-07 8:39 ` Juanma Barranquero
2019-10-07 18:52 ` Juri Linkov
2019-10-08 0:57 ` Juanma Barranquero
2019-10-19 20:38 ` Juri Linkov
2019-10-07 16:30 ` Eli Zaretskii
2019-10-08 11:15 ` Robert Pluim
2019-10-08 12:23 ` Eli Zaretskii
2019-10-09 7:19 ` Robert Pluim
2019-10-09 8:16 ` Eli Zaretskii
2019-10-09 12:14 ` Robert Pluim
2019-10-09 12:23 ` Eli Zaretskii
2019-10-09 13:19 ` Robert Pluim
2019-10-09 10:51 ` Juanma Barranquero
2019-10-04 10:22 ` Ergus
2019-10-04 10:26 ` Juanma Barranquero
2019-10-03 12:28 ` Yuri Khan
2019-10-03 14:48 ` Juanma Barranquero
2019-10-03 17:56 ` Yuri D'Elia
2019-10-03 18:40 ` Eli Zaretskii
2019-10-03 19:01 ` Yuri D'Elia
2019-10-04 2:01 ` Juanma Barranquero
2019-10-04 5:01 ` Juanma Barranquero
2019-10-04 15:57 ` Johan Bockgård
2019-10-04 17:28 ` Juanma Barranquero
2019-10-04 19:24 ` Stefan Monnier
2019-10-04 20:12 ` Yuri D'Elia
2019-10-04 22:45 ` Juanma Barranquero
2019-10-06 14:04 ` Juanma Barranquero
2019-10-06 14:45 ` Juanma Barranquero
2019-10-06 18:02 ` Eli Zaretskii
2019-10-01 9:24 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAAeL0SR-vitQv5cb3w6VX=sL2uJomh9v1DLs05FiXWLLnAgcnA@mail.gmail.com' \
--to=lekktu@gmail.com \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=larsi@gnus.org \
--cc=spacibba@aol.com \
--cc=wavexx@thregr.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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.