all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Native line numbers landed on master
@ 2017-07-08  7:58 Eli Zaretskii
  2017-07-08  8:41 ` martin rudalics
                   ` (5 more replies)
  0 siblings, 6 replies; 129+ messages in thread
From: Eli Zaretskii @ 2017-07-08  7:58 UTC (permalink / raw)
  To: emacs-devel

I've merged the line-numbers branch into master.  Please report any
problems you see as result of this via 'report-emacs-bug', as usual.

Thanks to everyone who tested the branch and provided feedback.

I will keep the branch in the repository for a week or so, before
deleting it, to let people who tracked the branch switch to master in
their own free time.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  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
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 129+ messages in thread
From: martin rudalics @ 2017-07-08  8:41 UTC (permalink / raw)
  To: Eli Zaretskii, emacs-devel

 > I've merged the line-numbers branch into master.  Please report any
 > problems you see as result of this via 'report-emacs-bug', as usual.

One small detail: Menu entries are usually capitalized.  Please consider
doing this for "all lines" too.

Many thanks for the great work, martin



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2017-07-08  8:41 ` martin rudalics
@ 2017-07-08 10:23   ` Eli Zaretskii
  0 siblings, 0 replies; 129+ messages in thread
From: Eli Zaretskii @ 2017-07-08 10:23 UTC (permalink / raw)
  To: martin rudalics; +Cc: emacs-devel

> Date: Sat, 08 Jul 2017 10:41:20 +0200
> From: martin rudalics <rudalics@gmx.at>
> 
>  > I've merged the line-numbers branch into master.  Please report any
>  > problems you see as result of this via 'report-emacs-bug', as usual.
> 
> One small detail: Menu entries are usually capitalized.  Please consider
> doing this for "all lines" too.

Done, thanks for the suggestion.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2017-07-08  7:58 Native line numbers landed on master Eli Zaretskii
  2017-07-08  8:41 ` martin rudalics
@ 2017-07-08 22:38 ` Alex
  2017-07-09 14:22   ` Eli Zaretskii
  2017-07-10 16:51 ` Native line numbers landed on master Filipe Silva
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 129+ messages in thread
From: Alex @ 2017-07-08 22:38 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

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

Eli Zaretskii <eliz@gnu.org> writes:

> I've merged the line-numbers branch into master.  Please report any
> problems you see as result of this via 'report-emacs-bug', as usual.
>
> Thanks to everyone who tested the branch and provided feedback.
>
> I will keep the branch in the repository for a week or so, before
> deleting it, to let people who tracked the branch switch to master in
> their own free time.

Why did you choose the name line-number-display-width over, e.g.,
display-line-number-width? It seems every other related variable has a
prefix of display-. I can see the name being confused with
line-number-display-limit-width and line-number-display-limit.

P.S. I was thinking about how a minor mode for this should be
implemented. I attached a proof of concept, which includes a couple
extra variables to achieve line number width behaviour similar to
linum/nlinum. What do you think?


[-- Attachment #2: display-line-numbers.el --]
[-- Type: application/emacs-lisp, Size: 1964 bytes --]

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2017-07-08 22:38 ` Alex
@ 2017-07-09 14:22   ` Eli Zaretskii
  2017-07-09 22:56     ` Alex
                       ` (2 more replies)
  0 siblings, 3 replies; 129+ messages in thread
From: Eli Zaretskii @ 2017-07-09 14:22 UTC (permalink / raw)
  To: Alex; +Cc: emacs-devel

> From: Alex <agrambot@gmail.com>
> Cc: emacs-devel@gnu.org
> Date: Sat, 08 Jul 2017 16:38:44 -0600
> 
> Why did you choose the name line-number-display-width over, e.g.,
> display-line-number-width? It seems every other related variable has a
> prefix of display-.

Not every other one: the faces start with line-number.

Is the name that bad?  It sounded right at the time, but if others
think it might confuse, we could rename it.

> P.S. I was thinking about how a minor mode for this should be
> implemented. I attached a proof of concept, which includes a couple
> extra variables to achieve line number width behaviour similar to
> linum/nlinum. What do you think?

Looks okay, although I'd drop the # part in the below:

  (add-hook 'pre-command-hook #'display-line-numbers-update-width nil t))

Thanks.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2017-07-09 14:22   ` Eli Zaretskii
@ 2017-07-09 22:56     ` Alex
  2017-07-10 17:50       ` Eli Zaretskii
  2017-07-10 22:19     ` John Wiegley
  2017-07-11 15:27     ` Stefan Monnier
  2 siblings, 1 reply; 129+ messages in thread
From: Alex @ 2017-07-09 22:56 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

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

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Alex <agrambot@gmail.com>
>> Cc: emacs-devel@gnu.org
>> Date: Sat, 08 Jul 2017 16:38:44 -0600
>> 
>> Why did you choose the name line-number-display-width over, e.g.,
>> display-line-number-width? It seems every other related variable has a
>> prefix of display-.
>
> Not every other one: the faces start with line-number.
>
> Is the name that bad?  It sounded right at the time, but if others
> think it might confuse, we could rename it.

I think it's a little confusing, but it's not a huge deal.

>> P.S. I was thinking about how a minor mode for this should be
>> implemented. I attached a proof of concept, which includes a couple
>> extra variables to achieve line number width behaviour similar to
>> linum/nlinum. What do you think?
>
> Looks okay, although I'd drop the # part in the below:
>
>   (add-hook 'pre-command-hook #'display-line-numbers-update-width nil t))

Is there a reason to drop it? I heard that the byte compiler uses #' to
check for existence of the function (and warns if it's not found), so it
seems like a nice default in these situations.

I've attached a patch below. I changed the menu bar to toggle the global
mode since the other toggles in the Show/Hide menu are also toggled
globally. Does it look alright for inclusion?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: minor mode --]
[-- Type: text/x-diff, Size: 5765 bytes --]

From 283ac10f3601362c0b200f0b610047bec75d0a59 Mon Sep 17 00:00:00 2001
From: Alexander Gramiak <agrambot@gmail.com>
Date: Sun, 9 Jul 2017 16:40:52 -0600
Subject: [PATCH] Add minor mode interface for display-line-numbers

* lisp/display-line-numbers.el: New file.
* lisp/menu-bar (menu-bar-showhide-menu): Use global minor mode.
(toggle-display-line-numbers): Remove.
---
 lisp/display-line-numbers.el | 99 ++++++++++++++++++++++++++++++++++++++++++++
 lisp/menu-bar.el             | 14 ++-----
 2 files changed, 102 insertions(+), 11 deletions(-)
 create mode 100644 lisp/display-line-numbers.el

diff --git a/lisp/display-line-numbers.el b/lisp/display-line-numbers.el
new file mode 100644
index 0000000000..ebc3494f73
--- /dev/null
+++ b/lisp/display-line-numbers.el
@@ -0,0 +1,99 @@
+;;; display-line-numbers.el --- interface for display-line-numbers -*- lexical-binding: t -*-
+
+;; Copyright (C) 2017 Free Software Foundation, Inc.
+
+;; Maintainer: emacs-devel@gnu.org
+;; Keywords: convenience
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Provides a minor mode interface for `display-line-numbers'.
+;;
+;; Toggle display of line numbers with M-x display-line-numbers-mode.
+;; To enable line numbering in all buffers, use M-x
+;; global-display-line-numbers-mode.  To change the default type of
+;; line numbers displayed, customize display-line-number-type.
+
+;;; Code:
+
+(defgroup display-line-numbers nil
+  "Display line numbers in the buffer."
+  :group 'display)
+
+(defcustom display-line-number-type t
+  "Sets the type of line numbers to use in `display-line-number-mode'.
+See `display-line-numbers' for value options."
+  :group 'display-line-numbers
+  :type '(choice (const :tag "Relative line numbers" relative)
+                 (const :tag "Relative visual line numbers" visual)
+                 (other :tag "Regular line numbers" t))
+  :version "26.1")
+
+(defcustom display-line-number-inhibit-shrink nil
+  "If non-nil, do not shrink line number width."
+  :group 'display-line-numbers
+  :type 'boolean
+  :version "26.1")
+
+(defcustom display-line-number-width-start nil
+  "If non-nil, set initial line number width based on buffer contents.
+`display-line-number-width' is set to the minimum width necessary
+to display all line numbers in the buffer."
+  :group 'display-line-numbers
+  :type 'boolean
+  :version "26.1")
+
+(defun display-line-numbers-update-width ()
+  "Prevent the line number width from shrinking."
+  (setq display-line-number-width
+        (max (or display-line-number-width 1)
+             (line-number-display-width))))
+
+;;;###autoload
+(define-minor-mode display-line-numbers-mode
+  "Toggle display of line numbers in the buffer.
+This uses `display-line-numbers' internally.
+
+To change the type of line numbers displayed by default,
+customize `display-line-number-type'. To change the type while
+the mode is on, set `display-line-numbers' directly."
+  :lighter nil
+  (if display-line-numbers-mode
+      (progn
+        (when display-line-number-width-start
+          (setq display-line-number-width
+                (length (number-to-string
+                         (count-lines (point-min) (point-max))))))
+        (when display-line-number-inhibit-shrink
+          (add-hook 'pre-command-hook #'display-line-numbers-update-width nil t))
+        (setq display-line-numbers display-line-number-type))
+    (remove-hook 'pre-command-hook #'display-line-numbers-update-width t)
+    (setq display-line-numbers nil)))
+
+;;;###autoload
+(define-globalized-minor-mode global-display-line-numbers-mode
+  display-line-numbers-mode
+  (lambda ()
+    (unless (or (minibufferp)
+                ;; taken from linum.el
+                (and (daemonp) (null (frame-parameter nil 'client))))
+      (display-line-numbers-mode))))
+
+(provide 'display-line-numbers)
+
+;;; display-line-numbers.el ends here
diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el
index 3ca7d1b5b3..434dd9b91f 100644
--- a/lisp/menu-bar.el
+++ b/lisp/menu-bar.el
@@ -1101,23 +1101,15 @@ menu-bar-showhide-tool-bar-menu-customize-enable-bottom
                     :button (:radio . (eq tool-bar-mode nil))))
       menu)))
 
-(defun toggle-display-line-numbers ()
-  (interactive)
-  (if display-line-numbers
-      (setq display-line-numbers nil)
-    (setq display-line-numbers t))
-  (force-mode-line-update))
-
 (defvar menu-bar-showhide-menu
   (let ((menu (make-sparse-keymap "Show/Hide")))
 
     (bindings--define-key menu [display-line-numbers]
       `(menu-item "Line Numbers for All Lines"
-                  ,(lambda ()
-                     (interactive)
-                     (toggle-display-line-numbers))
+                  global-display-line-numbers-mode
                   :help "Show the line number alongside each line"
-                  :button (:toggle . display-line-numbers)))
+                  :button (:toggle . (bound-and-true-p
+                                      global-display-line-numbers-mode))))
 
     (bindings--define-key menu [column-number-mode]
       (menu-bar-make-mm-toggle column-number-mode
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2017-07-08  7:58 Native line numbers landed on master Eli Zaretskii
  2017-07-08  8:41 ` martin rudalics
  2017-07-08 22:38 ` Alex
@ 2017-07-10 16:51 ` Filipe Silva
  2017-07-11 13:00 ` Robert Pluim
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 129+ messages in thread
From: Filipe Silva @ 2017-07-10 16:51 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Emacs developers

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

Thank you for your quality work on this feature Eli. It will be a huge
success for the emacs community.

Filipe

On Jul 8, 2017 04:59, "Eli Zaretskii" <eliz@gnu.org> wrote:

> I've merged the line-numbers branch into master.  Please report any
> problems you see as result of this via 'report-emacs-bug', as usual.
>
> Thanks to everyone who tested the branch and provided feedback.
>
> I will keep the branch in the repository for a week or so, before
> deleting it, to let people who tracked the branch switch to master in
> their own free time.
>
>

[-- Attachment #2: Type: text/html, Size: 913 bytes --]

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2017-07-09 22:56     ` Alex
@ 2017-07-10 17:50       ` Eli Zaretskii
  2017-07-10 20:31         ` Alex
  0 siblings, 1 reply; 129+ messages in thread
From: Eli Zaretskii @ 2017-07-10 17:50 UTC (permalink / raw)
  To: Alex; +Cc: emacs-devel

> From: Alex <agrambot@gmail.com>
> Cc: emacs-devel@gnu.org
> Date: Sun, 09 Jul 2017 16:56:23 -0600
> 
> I've attached a patch below. I changed the menu bar to toggle the global
> mode since the other toggles in the Show/Hide menu are also toggled
> globally. Does it look alright for inclusion?

I have some comments:

> +(defgroup display-line-numbers nil
> +  "Display line numbers in the buffer."
> +  :group 'display)

This means the defcustoms here will be separate from those defined in
cus-start.el.  Is that intended?

More generally, do we want some of the defcustoms to live here and
some in another file?  And if we want all of them here, does that mean
this file needs to be preloaded, or at least auto-loaded when
display-line-numbers is set by the user?

> +(defcustom display-line-number-inhibit-shrink nil

Instead of "inhibit-shrink" (which is a kind-of double negation), I
would suggest to use "grow-only", which AFAIR was your original
suggestion.

> +(defcustom display-line-number-width-start nil
> +  "If non-nil, set initial line number width based on buffer contents.

"Based on buffer contents" is a euphemism.  I would suggest to tell
explicitly that this will cause the lines counted in the buffer when
it's created.

> +To change the type of line numbers displayed by default,
> +customize `display-line-number-type'. To change the type while
                                       ^^
Two spaces, please.

> +(define-globalized-minor-mode global-display-line-numbers-mode
> +  display-line-numbers-mode
> +  (lambda ()
> +    (unless (or (minibufferp)
> +                ;; taken from linum.el
> +                (and (daemonp) (null (frame-parameter nil 'client))))
> +      (display-line-numbers-mode))))

The daemonp part is only needed when display-line-number-width-start
is non-nil, right?

Thanks.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2017-07-10 17:50       ` Eli Zaretskii
@ 2017-07-10 20:31         ` Alex
  2017-07-11 15:12           ` Eli Zaretskii
  0 siblings, 1 reply; 129+ messages in thread
From: Alex @ 2017-07-10 20:31 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Alex <agrambot@gmail.com>
>> Cc: emacs-devel@gnu.org
>> Date: Sun, 09 Jul 2017 16:56:23 -0600
>> 
>> I've attached a patch below. I changed the menu bar to toggle the global
>> mode since the other toggles in the Show/Hide menu are also toggled
>> globally. Does it look alright for inclusion?
>
> I have some comments:
>
>> +(defgroup display-line-numbers nil
>> +  "Display line numbers in the buffer."
>> +  :group 'display)
>
> This means the defcustoms here will be separate from those defined in
> cus-start.el.  Is that intended?
>
> More generally, do we want some of the defcustoms to live here and
> some in another file?  And if we want all of them here, does that mean
> this file needs to be preloaded, or at least auto-loaded when
> display-line-numbers is set by the user?

I'm not sure if there's a convention for this (built-in feature with a
Lisp-level mode wrapper) situation, but it might be nice to separate the
variables that are directly linked to display-line-numbers and ones that
only are used in the minor mode wrapper.

What about defining the defgroup in cus-edit.el, making both these
variables and the ones in cus-start belong to it?

I don't know if the file should be pre/auto-loaded. Is there a reason to
do so considering linum.el isn't?

>> +(define-globalized-minor-mode global-display-line-numbers-mode
>> +  display-line-numbers-mode
>> +  (lambda ()
>> +    (unless (or (minibufferp)
>> +                ;; taken from linum.el
>> +                (and (daemonp) (null (frame-parameter nil 'client))))
>> +      (display-line-numbers-mode))))
>
> The daemonp part is only needed when display-line-number-width-start
> is non-nil, right?

I suppose so, but would one want line numbers in that specific buffer
either way? I added that part because you added it to linum.el in
bd3c6eec. Does the problem affect display-line-numbers?

Also, I was wondering if setting display-line-number-width in
pre-command-hook unconditionally is a good idea. I timed it and the
function itself seemed slightly faster than a let/when approach, but
describe-variable states that setting it calls set-buffer-redisplay,
which disables redisplay optimizations. So if I understand this
correctly, adding the current display-line-numbers-update-width to
pre-command-hook would disable redisplay optimizations for every
command.

P.S. I also noticed that the docstring for display-line-numbers doesn't
describe the 'relative value, or state that 'visual also uses relative
line numbers.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2017-07-09 14:22   ` Eli Zaretskii
  2017-07-09 22:56     ` Alex
@ 2017-07-10 22:19     ` John Wiegley
  2017-07-11  2:29       ` Eli Zaretskii
  2017-07-11 15:27     ` Stefan Monnier
  2 siblings, 1 reply; 129+ messages in thread
From: John Wiegley @ 2017-07-10 22:19 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Alex, emacs-devel

>>>>> "EZ" == Eli Zaretskii <eliz@gnu.org> writes:

>> Why did you choose the name line-number-display-width over, e.g.,
>> display-line-number-width? It seems every other related variable has a
>> prefix of display-.

EZ> Not every other one: the faces start with line-number.

If the defgroup is display-line-numbers, shouldn't all customization options
use that prefix?

-- 
John Wiegley                  GPG fingerprint = 4710 CF98 AF9B 327B B80F
http://newartisans.com                          60E1 46C4 BD1A 7AC1 4BA2



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2017-07-10 22:19     ` John Wiegley
@ 2017-07-11  2:29       ` Eli Zaretskii
  0 siblings, 0 replies; 129+ messages in thread
From: Eli Zaretskii @ 2017-07-11  2:29 UTC (permalink / raw)
  To: John Wiegley; +Cc: agrambot, emacs-devel

> From: John Wiegley <jwiegley@gmail.com>
> Cc: Alex <agrambot@gmail.com>,  emacs-devel@gnu.org
> Date: Mon, 10 Jul 2017 15:19:18 -0700
> 
> >>>>> "EZ" == Eli Zaretskii <eliz@gnu.org> writes:
> 
> >> Why did you choose the name line-number-display-width over, e.g.,
> >> display-line-number-width? It seems every other related variable has a
> >> prefix of display-.
> 
> EZ> Not every other one: the faces start with line-number.
> 
> If the defgroup is display-line-numbers, shouldn't all customization options
> use that prefix?

They should, and they do, AFAICT.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2017-07-08  7:58 Native line numbers landed on master Eli Zaretskii
                   ` (2 preceding siblings ...)
  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 15:24   ` Eli Zaretskii
  2017-07-12  3:23 ` Kaushal Modi
  2017-07-15 22:02 ` Yuri D'Elia
  5 siblings, 2 replies; 129+ messages in thread
From: Robert Pluim @ 2017-07-11 13:00 UTC (permalink / raw)
  To: emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

> I've merged the line-numbers branch into master.  Please report any
> problems you see as result of this via 'report-emacs-bug', as usual.
>

Hi Eli,

I'm not sure if this is a problem or intended design:

If I customize line-number-current-line to have a background colour,
then when the current line is wrapped, the current line number and the
empty space(s) below it have that backround applied. I was hoping to
have that apply just to the line number itself.

In any case, it's a minor issue, I've removed nlinum from my
setup. Thanks for your work on this Eli.

Regards

Robert




^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  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 15:24   ` Eli Zaretskii
  1 sibling, 1 reply; 129+ messages in thread
From: Jean-Christophe Helary @ 2017-07-11 13:37 UTC (permalink / raw)
  To: Emacs-Devel devel

> Eli Zaretskii <eliz@gnu.org> writes:
> 
>> I've merged the line-numbers branch into master.  Please report any
>> problems you see as result of this via 'report-emacs-bug', as usual.

I'm pretty sure I'm building master but I don't see how to make the line numbers appear.

Jean-Christophe 


^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2017-07-11 13:37   ` Jean-Christophe Helary
@ 2017-07-11 13:47     ` Robert Pluim
  2017-07-11 14:19       ` Jean-Christophe Helary
  0 siblings, 1 reply; 129+ messages in thread
From: Robert Pluim @ 2017-07-11 13:47 UTC (permalink / raw)
  To: emacs-devel

Jean-Christophe Helary <jean.christophe.helary@gmail.com> writes:

>> Eli Zaretskii <eliz@gnu.org> writes:
>> 
>>> I've merged the line-numbers branch into master.  Please report any
>>> problems you see as result of this via 'report-emacs-bug', as usual.
>
> I'm pretty sure I'm building master but I don't see how to make the line numbers appear.

From NEWS:

** Emacs now supports optional display of line numbers in the buffer.
This is similar to what linum-mode provides, but much faster and
doesn't usurp the display margin for the line numbers.  Customize the
buffer-local variable 'display-line-numbers' to activate this optional
display.

If you don't have that, you don't have master :-)

Regards

Robert




^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2017-07-11 13:47     ` Robert Pluim
@ 2017-07-11 14:19       ` Jean-Christophe Helary
  0 siblings, 0 replies; 129+ messages in thread
From: Jean-Christophe Helary @ 2017-07-11 14:19 UTC (permalink / raw)
  To: Emacs-Devel devel


> On Jul 11, 2017, at 22:47, Robert Pluim <rpluim@gmail.com> wrote:
> 
>> I'm pretty sure I'm building master but I don't see how to make the line numbers appear.
> 
> From NEWS:
> 
> ** Emacs now supports optional display of line numbers in the buffer.
> This is similar to what linum-mode provides, but much faster and
> doesn't usurp the display margin for the line numbers.  Customize the
> buffer-local variable 'display-line-numbers' to activate this optional
> display.
> 
> If you don't have that, you don't have master :-)

I was not looking at the right place :) Thank you.
I'll have NEWS popup each time I build master from now on... :)

And, wow, that's amazing.

Jean-Christophe 


^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2017-07-10 20:31         ` Alex
@ 2017-07-11 15:12           ` Eli Zaretskii
  2017-07-11 20:44             ` Alex
  0 siblings, 1 reply; 129+ messages in thread
From: Eli Zaretskii @ 2017-07-11 15:12 UTC (permalink / raw)
  To: Alex; +Cc: emacs-devel

> From: Alex <agrambot@gmail.com>
> Cc: emacs-devel@gnu.org
> Date: Mon, 10 Jul 2017 14:31:46 -0600
> 
> >> +(defgroup display-line-numbers nil
> >> +  "Display line numbers in the buffer."
> >> +  :group 'display)
> >
> > This means the defcustoms here will be separate from those defined in
> > cus-start.el.  Is that intended?
> >
> > More generally, do we want some of the defcustoms to live here and
> > some in another file?  And if we want all of them here, does that mean
> > this file needs to be preloaded, or at least auto-loaded when
> > display-line-numbers is set by the user?
> 
> I'm not sure if there's a convention for this (built-in feature with a
> Lisp-level mode wrapper) situation, but it might be nice to separate the
> variables that are directly linked to display-line-numbers and ones that
> only are used in the minor mode wrapper.
> 
> What about defining the defgroup in cus-edit.el, making both these
> variables and the ones in cus-start belong to it?

Sounds OK to me, thanks.  I think we do want all the variables to
appear in the same customization group, even if they are defined
separately.

Maybe also add a comment in display-line-numbers.el that some
additional defcustoms are defined in cus-start.el.

> I don't know if the file should be pre/auto-loaded. Is there a reason to
> do so considering linum.el isn't?

linum.el _is_ autoloaded if you invoke linum-mode, no?

The scenario I had in mind was a user doing this:

  M-x set-variable RET display-line-numbers RET t RET

This is a legitimate way of activating the feature in a buffer.  Do we
want then the user to automatically have access to all the
customizations and features in display-line-numbers.el?

> >> +(define-globalized-minor-mode global-display-line-numbers-mode
> >> +  display-line-numbers-mode
> >> +  (lambda ()
> >> +    (unless (or (minibufferp)
> >> +                ;; taken from linum.el
> >> +                (and (daemonp) (null (frame-parameter nil 'client))))
> >> +      (display-line-numbers-mode))))
> >
> > The daemonp part is only needed when display-line-number-width-start
> > is non-nil, right?
> 
> I suppose so, but would one want line numbers in that specific buffer
> either way?

I don't know.  Similarity to interactive invocation, maybe?

> I added that part because you added it to linum.el in bd3c6eec.

That was to fix a bug that I think shouldn't happen with the native
implementation, because it doesn't count lines.

> Does the problem affect display-line-numbers?

I don't think so, but it should be easy to test.  I'll take a look.

> Also, I was wondering if setting display-line-number-width in
> pre-command-hook unconditionally is a good idea. I timed it and the
> function itself seemed slightly faster than a let/when approach, but
> describe-variable states that setting it calls set-buffer-redisplay,
> which disables redisplay optimizations. So if I understand this
> correctly, adding the current display-line-numbers-update-width to
> pre-command-hook would disable redisplay optimizations for every
> command.

Yes, it shouldn't be unconditional.

> P.S. I also noticed that the docstring for display-line-numbers doesn't
> describe the 'relative value, or state that 'visual also uses relative
> line numbers.

Thanks, I fixed this.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2017-07-11 13:00 ` Robert Pluim
  2017-07-11 13:37   ` Jean-Christophe Helary
@ 2017-07-11 15:24   ` Eli Zaretskii
  2017-07-11 15:29     ` Robert Pluim
  1 sibling, 1 reply; 129+ messages in thread
From: Eli Zaretskii @ 2017-07-11 15:24 UTC (permalink / raw)
  To: emacs-devel

> From: Robert Pluim <rpluim@gmail.com>
> Date: Tue, 11 Jul 2017 15:00:55 +0200
> 
> I'm not sure if this is a problem or intended design:

Not consciously intended, just the "natural" thing.

> If I customize line-number-current-line to have a background colour,
> then when the current line is wrapped, the current line number and the
> empty space(s) below it have that backround applied. I was hoping to
> have that apply just to the line number itself.

Are you talking about display-line-numbers set to t, and then about
the empty field displayed for continuation lines, which show no
numbers?  Otherwise I don't understand what you mean by "empty
space(s) below it".

If you indeed mean continuation lines, I'd like to hear from others
what they think about this use case.  Displaying the empty fields in a
face different from the number itself is some work, but I will do it
if that's the "popular demand".

> In any case, it's a minor issue, I've removed nlinum from my
> setup. Thanks for your work on this Eli.

You are welcome, and thanks for the feedback.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2017-07-09 14:22   ` Eli Zaretskii
  2017-07-09 22:56     ` Alex
  2017-07-10 22:19     ` John Wiegley
@ 2017-07-11 15:27     ` Stefan Monnier
  2017-07-11 16:04       ` Eli Zaretskii
  2 siblings, 1 reply; 129+ messages in thread
From: Stefan Monnier @ 2017-07-11 15:27 UTC (permalink / raw)
  To: emacs-devel

> Looks okay, although I'd drop the # part in the below:
>   (add-hook 'pre-command-hook #'display-line-numbers-update-width nil t))

Recent Elisp changes have rather gone the other way (adding a # rather
than removing them).  Part of the reason is that lexical-binding gives
different semantics to '(lambda ...) and #'(lambda ...), other part is
that cl-flet and cl-labels also give different semantics to 'foo and
#'foo.

Finally, if you keep the # part, the byte-compiler will be able to check
that you spelled the function correctly (and warn you if that function
is not known to exist).


        Stefan




^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2017-07-11 15:24   ` Eli Zaretskii
@ 2017-07-11 15:29     ` Robert Pluim
  2017-07-11 16:07       ` Eli Zaretskii
  0 siblings, 1 reply; 129+ messages in thread
From: Robert Pluim @ 2017-07-11 15:29 UTC (permalink / raw)
  To: emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Robert Pluim <rpluim@gmail.com>
>> Date: Tue, 11 Jul 2017 15:00:55 +0200
>>
>> If I customize line-number-current-line to have a background colour,
>> then when the current line is wrapped, the current line number and the
>> empty space(s) below it have that backround applied. I was hoping to
>> have that apply just to the line number itself.
>
> Are you talking about display-line-numbers set to t, and then about
> the empty field displayed for continuation lines, which show no
> numbers?  Otherwise I don't understand what you mean by "empty
> space(s) below it".

Yes, I mean the empty field.

> If you indeed mean continuation lines, I'd like to hear from others
> what they think about this use case.  Displaying the empty fields in a
> face different from the number itself is some work, but I will do it
> if that's the "popular demand".

I can live with it, it just looks a little jarring when there are
continuation lines.

Regards

Robert




^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2017-07-11 15:27     ` Stefan Monnier
@ 2017-07-11 16:04       ` Eli Zaretskii
  2017-07-11 16:16         ` Stefan Monnier
  0 siblings, 1 reply; 129+ messages in thread
From: Eli Zaretskii @ 2017-07-11 16:04 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Date: Tue, 11 Jul 2017 11:27:18 -0400
> 
> > Looks okay, although I'd drop the # part in the below:
> >   (add-hook 'pre-command-hook #'display-line-numbers-update-width nil t))
> 
> Recent Elisp changes have rather gone the other way (adding a # rather
> than removing them).  Part of the reason is that lexical-binding gives
> different semantics to '(lambda ...) and #'(lambda ...), other part is
> that cl-flet and cl-labels also give different semantics to 'foo and
> #'foo.
> 
> Finally, if you keep the # part, the byte-compiler will be able to check
> that you spelled the function correctly (and warn you if that function
> is not known to exist).

Without this being documented anywhere (AFAICS), how can we ever hope
to educate our users (starting with myself) about this?



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2017-07-11 15:29     ` Robert Pluim
@ 2017-07-11 16:07       ` Eli Zaretskii
  2017-07-11 16:12         ` Robert Pluim
  0 siblings, 1 reply; 129+ messages in thread
From: Eli Zaretskii @ 2017-07-11 16:07 UTC (permalink / raw)
  To: emacs-devel

> From: Robert Pluim <rpluim@gmail.com>
> Date: Tue, 11 Jul 2017 17:29:22 +0200
> 
> > If you indeed mean continuation lines, I'd like to hear from others
> > what they think about this use case.  Displaying the empty fields in a
> > face different from the number itself is some work, but I will do it
> > if that's the "popular demand".
> 
> I can live with it, it just looks a little jarring when there are
> continuation lines.

OTOH, you immediately see very clearly where the current physical line
ends.

Anyway, I will wait for additional opinions.

Btw, if I were to do this, what other face attributes would you expect
to see removed from the empty fields, in addition to background color?
Or do you simply want them to be displayed using the line-number face
instead?  (That could be a different font size.)



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2017-07-11 16:07       ` Eli Zaretskii
@ 2017-07-11 16:12         ` Robert Pluim
  2017-07-11 17:33           ` Eli Zaretskii
  0 siblings, 1 reply; 129+ messages in thread
From: Robert Pluim @ 2017-07-11 16:12 UTC (permalink / raw)
  To: emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Robert Pluim <rpluim@gmail.com>
>> Date: Tue, 11 Jul 2017 17:29:22 +0200
>> 
>> I can live with it, it just looks a little jarring when there are
>> continuation lines.
>
> OTOH, you immediately see very clearly where the current physical line
> ends.

True

> Anyway, I will wait for additional opinions.
>
> Btw, if I were to do this, what other face attributes would you expect
> to see removed from the empty fields, in addition to background color?
> Or do you simply want them to be displayed using the line-number face
> instead?  (That could be a different font size.)

I'd expect it to use the line-number face. I confidently predict
opinions will differ here :-)

BTW, since we're discussing options, I definitely don't want a
configuration variable, let's just decide one way or the other.

Regards

Robert




^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2017-07-11 16:04       ` Eli Zaretskii
@ 2017-07-11 16:16         ` Stefan Monnier
  2017-07-11 17:23           ` Eli Zaretskii
  0 siblings, 1 reply; 129+ messages in thread
From: Stefan Monnier @ 2017-07-11 16:16 UTC (permalink / raw)
  To: emacs-devel

> Without this being documented anywhere (AFAICS), how can we ever hope
> to educate our users (starting with myself) about this?

It's way down the list in terms of importance, really.
Basically outside of cl-flet and cl-labels it's just a stylistic choice.
It's just that several "recent changes" (i.e. starting with Emacs-24)
have influenced at least my style and apparently that of some others
as well.


        Stefan




^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2017-07-11 16:16         ` Stefan Monnier
@ 2017-07-11 17:23           ` Eli Zaretskii
  2017-07-11 17:48             ` Stefan Monnier
  0 siblings, 1 reply; 129+ messages in thread
From: Eli Zaretskii @ 2017-07-11 17:23 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Date: Tue, 11 Jul 2017 12:16:29 -0400
> 
> > Without this being documented anywhere (AFAICS), how can we ever hope
> > to educate our users (starting with myself) about this?
> 
> It's way down the list in terms of importance, really.
> Basically outside of cl-flet and cl-labels it's just a stylistic choice.
> It's just that several "recent changes" (i.e. starting with Emacs-24)
> have influenced at least my style and apparently that of some others
> as well.

As long as we (or, rather, you) tell others to prefer that style, it's
not way down the list.  Because stuff that is way down the list
shouldn't be mentioned when we review code, IMO.  We should be
consistent in these matters: either they are important, or they
aren't; in the latter case they are just personal preferences that
should stay personal.  IMO, at least.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2017-07-11 16:12         ` Robert Pluim
@ 2017-07-11 17:33           ` Eli Zaretskii
  0 siblings, 0 replies; 129+ messages in thread
From: Eli Zaretskii @ 2017-07-11 17:33 UTC (permalink / raw)
  To: emacs-devel

> From: Robert Pluim <rpluim@gmail.com>
> Date: Tue, 11 Jul 2017 18:12:51 +0200
> 
> > Btw, if I were to do this, what other face attributes would you expect
> > to see removed from the empty fields, in addition to background color?
> > Or do you simply want them to be displayed using the line-number face
> > instead?  (That could be a different font size.)
> 
> I'd expect it to use the line-number face. I confidently predict
> opinions will differ here :-)

Well, using line-number is definitely easier to implement than what I
originally thought you wanted.  But let's see those opinions first ;-)

> BTW, since we're discussing options, I definitely don't want a
> configuration variable, let's just decide one way or the other.

Agreed.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  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:18               ` Sharp-quoting function symbols (Was: Native line numbers landed on master) Kaushal Modi
  0 siblings, 2 replies; 129+ messages in thread
From: Stefan Monnier @ 2017-07-11 17:48 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

> As long as we (or, rather, you) tell others to prefer that style, it's
> not way down the list.

I didn't tell anyone to prefer that style, actually (or at least,
I tried to write it such that it doesn't say that, maybe I failed).
I just wanted to point out that recentish changes make the difference
between 'foo and #'foo slightly more visible and as a result you might
like to reconsider your recommendation to strip the #.  You might still
decide that the # is too ugly to keep it where it's not
absolutely needed.


        Stefan



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  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
  1 sibling, 1 reply; 129+ messages in thread
From: Eli Zaretskii @ 2017-07-11 18:04 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

> From: Stefan Monnier <monnier@IRO.UMontreal.CA>
> Cc: emacs-devel@gnu.org
> Date: Tue, 11 Jul 2017 13:48:03 -0400
> 
> > As long as we (or, rather, you) tell others to prefer that style, it's
> > not way down the list.
> 
> I didn't tell anyone to prefer that style, actually (or at least,
> I tried to write it such that it doesn't say that, maybe I failed).

Well, they surely did get those ideas from someone, because the
documentation doesn't say anything about it.

> You might still decide that the # is too ugly to keep it where it's
> not absolutely needed.

And start yet another bikeshedding argument about something that isn't
considered a project-wide guideline?  No, thanks.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Sharp-quoting function symbols (Was: Native line numbers landed on master)
  2017-07-11 17:48             ` Stefan Monnier
  2017-07-11 18:04               ` Eli Zaretskii
@ 2017-07-11 18:18               ` Kaushal Modi
  2017-09-30 18:36                 ` Philipp Stephani
  1 sibling, 1 reply; 129+ messages in thread
From: Kaushal Modi @ 2017-07-11 18:18 UTC (permalink / raw)
  To: Stefan Monnier, Eli Zaretskii; +Cc: emacs-devel

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

Hello all,

I can speak for myself that I religiously follow the convention to use
#'SYMBOL instead of 'SYMBOL where SYMBOL is expected to be a function in
the form where it's used; exactly for the reasons that Stephan mentioned.
In addition, to the user it becomes evident if that symbol is expected to
be a function or not.

I use that convention in my emacs config, packages, etc. I have even seen
that convention in many other packages and configs too, from what I follow
on emacs.stackexchange, reddit, etc.

This[1] is a very popular post out in the wild, by Artur Malabarba that
explains why and when one should use sharp-quotes or hash-quotes.

If we are counting votes to add this to the official documentation, my vote
is in :)

[1]:
http://endlessparentheses.com/get-in-the-habit-of-using-sharp-quote.html

On Tue, Jul 11, 2017 at 1:48 PM Stefan Monnier <monnier@iro.umontreal.ca>
wrote:

> > As long as we (or, rather, you) tell others to prefer that style, it's
> > not way down the list.
>
> I didn't tell anyone to prefer that style, actually (or at least,
> I tried to write it such that it doesn't say that, maybe I failed).
> I just wanted to point out that recentish changes make the difference
> between 'foo and #'foo slightly more visible and as a result you might
> like to reconsider your recommendation to strip the #.  You might still
> decide that the # is too ugly to keep it where it's not
> absolutely needed.
>
-- 

Kaushal Modi

[-- Attachment #2: Type: text/html, Size: 2099 bytes --]

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2017-07-11 18:04               ` Eli Zaretskii
@ 2017-07-11 18:19                 ` Stefan Monnier
  0 siblings, 0 replies; 129+ messages in thread
From: Stefan Monnier @ 2017-07-11 18:19 UTC (permalink / raw)
  To: emacs-devel

> And start yet another bikeshedding argument about something that isn't
> considered a project-wide guideline?  No, thanks.

No, I meant for your own code.


        Stefan




^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2017-07-11 15:12           ` Eli Zaretskii
@ 2017-07-11 20:44             ` Alex
  2017-07-12 14:40               ` Eli Zaretskii
  0 siblings, 1 reply; 129+ messages in thread
From: Alex @ 2017-07-11 20:44 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

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

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Alex <agrambot@gmail.com>
>> Cc: emacs-devel@gnu.org
>> Date: Mon, 10 Jul 2017 14:31:46 -0600
>> 
>> I'm not sure if there's a convention for this (built-in feature with a
>> Lisp-level mode wrapper) situation, but it might be nice to separate the
>> variables that are directly linked to display-line-numbers and ones that
>> only are used in the minor mode wrapper.
>> 
>> What about defining the defgroup in cus-edit.el, making both these
>> variables and the ones in cus-start belong to it?
>
> Sounds OK to me, thanks.  I think we do want all the variables to
> appear in the same customization group, even if they are defined
> separately.

Well, it seems this cus-edit change doesn't fix it by itself. When
executing customize-group without display-line-numbers loaded, then the
lisp-level defcustoms aren't shown. It might be because there's a
missing entry in cus-load.el, but I don't know how to add a group to it.
linum, for instance, appears to automatically be added to it.

Would it be better to skip creating a new defgroup and have all
variables just be in the display group, or are you in favour of a new
group just for line numbers?

>> I don't know if the file should be pre/auto-loaded. Is there a reason to
>> do so considering linum.el isn't?
>
> linum.el _is_ autoloaded if you invoke linum-mode, no?

Right, I was referring to the defcustoms.

> The scenario I had in mind was a user doing this:
>
>   M-x set-variable RET display-line-numbers RET t RET
>
> This is a legitimate way of activating the feature in a buffer.  Do we
> want then the user to automatically have access to all the
> customizations and features in display-line-numbers.el?

As is stands, the contents of display-line-numbers.el only applies to
the minor modes and not display-line-numbers itself. So the user would
have to call one of the minor modes to use the features, and at that
point everything will be loaded.

I thought about autoloading the defcustoms, but it seems as if that's a
contentious decision[1].

> That was to fix a bug that I think shouldn't happen with the native
> implementation, because it doesn't count lines.

So even a single count-lines on the whole buffer is too much?

>> Does the problem affect display-line-numbers?
>
> I don't think so, but it should be easy to test.  I'll take a look.

If so, then I'll leave it in.

>> P.S. I also noticed that the docstring for display-line-numbers doesn't
>> describe the 'relative value, or state that 'visual also uses relative
>> line numbers.
>
> Thanks, I fixed this.

Thanks, though it seems like your copyedit commit introduced a couple
typos. It also doesn't mention that any other non-nil value is treated
as t.

I've attached an updated patch. I didn't update the commit message yet.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: v2 --]
[-- Type: text/x-diff, Size: 8465 bytes --]

From d0e76628503adc7fd6a4a41c61954f305d6f2ac5 Mon Sep 17 00:00:00 2001
From: Alexander Gramiak <agrambot@gmail.com>
Date: Sun, 9 Jul 2017 16:40:52 -0600
Subject: [PATCH] Add minor mode interface for display-line-numbers

* lisp/display-line-numbers.el: New file.
* lisp/menu-bar (menu-bar-showhide-menu): Use global minor mode.
(toggle-display-line-numbers): Remove.
---
 lisp/cus-edit.el             |  4 ++
 lisp/cus-start.el            |  8 ++--
 lisp/display-line-numbers.el | 99 ++++++++++++++++++++++++++++++++++++++++++++
 lisp/menu-bar.el             | 14 ++-----
 4 files changed, 110 insertions(+), 15 deletions(-)
 create mode 100644 lisp/display-line-numbers.el

diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el
index 6dbb45ec6b..6dde2faf92 100644
--- a/lisp/cus-edit.el
+++ b/lisp/cus-edit.el
@@ -380,6 +380,10 @@ display
   "How characters are displayed in buffers."
   :group 'environment)
 
+(defgroup display-line-numbers nil
+  "Display line numbers in the buffer."
+  :group 'display)
+
 (defgroup execute nil
   "Executing external commands."
   :group 'processes)
diff --git a/lisp/cus-start.el b/lisp/cus-start.el
index e0290395ad..117b336a65 100644
--- a/lisp/cus-start.el
+++ b/lisp/cus-start.el
@@ -584,7 +584,7 @@ minibuffer-prompt-properties--setter
 		       (const :tag "Grow only" :value grow-only))
 	      "25.1")
 	     (display-raw-bytes-as-hex display boolean "26.1")
-             (display-line-numbers display
+             (display-line-numbers display-line-numbers
                                    (choice
                                     (const :tag "Off (nil)" :value nil)
                                     (const :tag "Absolute line numbers"
@@ -594,7 +594,7 @@ minibuffer-prompt-properties--setter
                                     (const :tag "Visually relative line numbers"
                                            :value visual))
                                    "26.1")
-             (display-line-number-width display
+             (display-line-number-width display-line-numbers
                                  (choice
                                   (const :tag "Dynamically computed"
                                          :value nil)
@@ -602,14 +602,14 @@ minibuffer-prompt-properties--setter
                                            :value 2
                                            :format "%v"))
                                  "26.1")
-             (display-line-numbers-current-absolute display
+             (display-line-numbers-current-absolute display-line-numbers
                                  (choice
                                   (const :tag "Display actual number of current line"
                                          :value t)
                                   (const :tag "Display zero as number of current line"
                                          :value nil))
                                  "26.1")
-             (display-line-numbers-widen display
+             (display-line-numbers-widen display-line-numbers
                                  (choice
                                   (const :tag "Disregard narrowing when calculating line numbers"
                                          :value t)
diff --git a/lisp/display-line-numbers.el b/lisp/display-line-numbers.el
new file mode 100644
index 0000000000..cca537a17b
--- /dev/null
+++ b/lisp/display-line-numbers.el
@@ -0,0 +1,99 @@
+;;; display-line-numbers.el --- interface for display-line-numbers -*- lexical-binding: t -*-
+
+;; Copyright (C) 2017 Free Software Foundation, Inc.
+
+;; Maintainer: emacs-devel@gnu.org
+;; Keywords: convenience
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Provides a minor mode interface for `display-line-numbers'.
+;;
+;; Toggle display of line numbers with M-x display-line-numbers-mode.
+;; To enable line numbering in all buffers, use M-x
+;; global-display-line-numbers-mode.  To change the default type of
+;; line numbers displayed, customize display-line-number-type.
+
+;; NOTE: Customization variables for `display-line-numbers' itself are
+;; defined in cus-start.el.
+
+;;; Code:
+
+(defcustom display-line-number-type t
+  "Sets the type of line numbers to use in `display-line-number-mode'.
+See `display-line-numbers' for value options."
+  :group 'display-line-numbers
+  :type '(choice (const :tag "Relative line numbers" relative)
+                 (const :tag "Relative visual line numbers" visual)
+                 (other :tag "Absolute line numbers" t))
+  :version "26.1")
+
+(defcustom display-line-numbers-grow-only nil
+  "If non-nil, do not shrink line number width."
+  :group 'display-line-numbers
+  :type 'boolean
+  :version "26.1")
+
+(defcustom display-line-number-width-start nil
+  "If non-nil, count number of lines to use for line number width.
+When `display-line-number-mode' is turned on,
+`display-line-number-width' is set to the minimum width necessary
+to display all line numbers in the buffer."
+  :group 'display-line-numbers
+  :type 'boolean
+  :version "26.1")
+
+(defun display-line-numbers-update-width ()
+  "Prevent the line number width from shrinking."
+  (let ((width (line-number-display-width)))
+    (when (> width (or display-line-number-width 1))
+      (setq display-line-number-width width))))
+
+;;;###autoload
+(define-minor-mode display-line-numbers-mode
+  "Toggle display of line numbers in the buffer.
+This uses `display-line-numbers' internally.
+
+To change the type of line numbers displayed by default,
+customize `display-line-number-type'.  To change the type while
+the mode is on, set `display-line-numbers' directly."
+  :lighter nil
+  (if display-line-numbers-mode
+      (progn
+        (when display-line-number-width-start
+          (setq display-line-number-width
+                (length (number-to-string
+                         (count-lines (point-min) (point-max))))))
+        (when display-line-numbers-grow-only
+          (add-hook 'pre-command-hook #'display-line-numbers-update-width nil t))
+        (setq display-line-numbers display-line-number-type))
+    (remove-hook 'pre-command-hook #'display-line-numbers-update-width t)
+    (setq display-line-numbers nil)))
+
+;;;###autoload
+(define-globalized-minor-mode global-display-line-numbers-mode
+  display-line-numbers-mode
+  (lambda ()
+    (unless (or (minibufferp)
+                ;; taken from linum.el
+                (and (daemonp) (null (frame-parameter nil 'client))))
+      (display-line-numbers-mode))))
+
+(provide 'display-line-numbers)
+
+;;; display-line-numbers.el ends here
diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el
index 3ca7d1b5b3..434dd9b91f 100644
--- a/lisp/menu-bar.el
+++ b/lisp/menu-bar.el
@@ -1101,23 +1101,15 @@ menu-bar-showhide-tool-bar-menu-customize-enable-bottom
                     :button (:radio . (eq tool-bar-mode nil))))
       menu)))
 
-(defun toggle-display-line-numbers ()
-  (interactive)
-  (if display-line-numbers
-      (setq display-line-numbers nil)
-    (setq display-line-numbers t))
-  (force-mode-line-update))
-
 (defvar menu-bar-showhide-menu
   (let ((menu (make-sparse-keymap "Show/Hide")))
 
     (bindings--define-key menu [display-line-numbers]
       `(menu-item "Line Numbers for All Lines"
-                  ,(lambda ()
-                     (interactive)
-                     (toggle-display-line-numbers))
+                  global-display-line-numbers-mode
                   :help "Show the line number alongside each line"
-                  :button (:toggle . display-line-numbers)))
+                  :button (:toggle . (bound-and-true-p
+                                      global-display-line-numbers-mode))))
 
     (bindings--define-key menu [column-number-mode]
       (menu-bar-make-mm-toggle column-number-mode
-- 
2.13.2


[-- Attachment #3: Type: text/plain, Size: 59 bytes --]


Footnotes: 
[1]  https://emacs.stackexchange.com/a/32860


^ permalink raw reply related	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2017-07-08  7:58 Native line numbers landed on master Eli Zaretskii
                   ` (3 preceding siblings ...)
  2017-07-11 13:00 ` Robert Pluim
@ 2017-07-12  3:23 ` Kaushal Modi
  2017-07-12  7:11   ` martin rudalics
  2017-07-15 22:02 ` Yuri D'Elia
  5 siblings, 1 reply; 129+ messages in thread
From: Kaushal Modi @ 2017-07-12  3:23 UTC (permalink / raw)
  To: Eli Zaretskii, emacs-devel

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

On Sat, Jul 8, 2017 at 3:59 AM Eli Zaretskii <eliz@gnu.org> wrote:

> I've merged the line-numbers branch into master.  Please report any
> problems you see as result of this via 'report-emacs-bug', as usual.
>
> Thanks to everyone who tested the branch and provided feedback.
>

I noticed that just one of the four variables for this feature has prefix
"display-line-number-" instead of "display-line-numbers-".

When all seen together:

    display-line-number-width
    display-line-numbers
    display-line-numbers-widen
    display-line-numbers-current-absolute

it seems like that one 's' got missed in that first variable. Should that
variable name be instead "display-line-numbers-width"?

-- 

Kaushal Modi

[-- Attachment #2: Type: text/html, Size: 1263 bytes --]

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2017-07-12  3:23 ` Kaushal Modi
@ 2017-07-12  7:11   ` martin rudalics
  2017-07-12 14:27     ` Eli Zaretskii
  0 siblings, 1 reply; 129+ messages in thread
From: martin rudalics @ 2017-07-12  7:11 UTC (permalink / raw)
  To: Kaushal Modi, Eli Zaretskii, emacs-devel

 > Should that
 > variable name be instead "display-line-numbers-width"?

I think so too.

Also, the latest fix of the doc-string of ‘display-line-numbers’
introduced a few typos.  Maybe it should be even rewritten as sketched
below (provided I managed to grasp the sense of it correctly).

   DEFVAR_LISP ("display-line-numbers", Vdisplay_line_numbers,
     doc: /* Non-nil means display line numbers.
If the value is t, display the absolute number of each line of a buffer
shown in a window.  Absolute line numbers count from the beginning of
the current narrowing, or from buffer beginning.  If the value is
`relative', display for each line not containing the window's point its
relative number instead, i.e. the number of the line relative to the
line showing the window's point.

In either case, line numbers are displayed at the beginning of each
non-continuation line that displays buffer text, i.e. after each newline
character that comes from the buffer.  The value `visual' is like
`relative' but counts screen lines instead of buffer lines.  In practice
this means that continuation lines count as well when calculating the
relative number of a line.

Lisp programs can disable display of a line number of a particular
buffer line by putting the `display-line-numbers-disable' text property
or overlay property on the first visible character of that line.  */);

martin




^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2017-07-12  7:11   ` martin rudalics
@ 2017-07-12 14:27     ` Eli Zaretskii
  2017-07-12 15:49       ` martin rudalics
  0 siblings, 1 reply; 129+ messages in thread
From: Eli Zaretskii @ 2017-07-12 14:27 UTC (permalink / raw)
  To: martin rudalics; +Cc: emacs-devel, kaushal.modi

> Date: Wed, 12 Jul 2017 09:11:43 +0200
> From: martin rudalics <rudalics@gmx.at>
> 
>  > Should that
>  > variable name be instead "display-line-numbers-width"?
> 
> I think so too.

Feel free to fix as you see fit.

> Also, the latest fix of the doc-string of ‘display-line-numbers’
> introduced a few typos.  Maybe it should be even rewritten as sketched
> below (provided I managed to grasp the sense of it correctly).

Fine with me, thanks.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2017-07-11 20:44             ` Alex
@ 2017-07-12 14:40               ` Eli Zaretskii
  2017-07-16  7:30                 ` Alex
  0 siblings, 1 reply; 129+ messages in thread
From: Eli Zaretskii @ 2017-07-12 14:40 UTC (permalink / raw)
  To: Alex; +Cc: emacs-devel

> From: Alex <agrambot@gmail.com>
> Cc: emacs-devel@gnu.org
> Date: Tue, 11 Jul 2017 14:44:13 -0600
> 
> > Sounds OK to me, thanks.  I think we do want all the variables to
> > appear in the same customization group, even if they are defined
> > separately.
> 
> Well, it seems this cus-edit change doesn't fix it by itself. When
> executing customize-group without display-line-numbers loaded, then the
> lisp-level defcustoms aren't shown. It might be because there's a
> missing entry in cus-load.el, but I don't know how to add a group to it.
> linum, for instance, appears to automatically be added to it.

cus-load.el is auto-generated.  Did the rule which updates it in
lisp/Makefile get running after your changes, and was cus-load.el
regenerated as result?  If not, maybe you need to run that rule by
hand.

> Would it be better to skip creating a new defgroup and have all
> variables just be in the display group, or are you in favour of a new
> group just for line numbers?

If it's a hassle to make a new group, we can stay in the display
group.

> >   M-x set-variable RET display-line-numbers RET t RET
> >
> > This is a legitimate way of activating the feature in a buffer.  Do we
> > want then the user to automatically have access to all the
> > customizations and features in display-line-numbers.el?
> 
> As is stands, the contents of display-line-numbers.el only applies to
> the minor modes and not display-line-numbers itself. So the user would
> have to call one of the minor modes to use the features, and at that
> point everything will be loaded.

OK.

> > That was to fix a bug that I think shouldn't happen with the native
> > implementation, because it doesn't count lines.
> 
> So even a single count-lines on the whole buffer is too much?

No, it isn't.  Feel free to leave it, I will look into that when I
have time.

> I've attached an updated patch. I didn't update the commit message yet.

LGTM, thanks.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2017-07-12 14:27     ` Eli Zaretskii
@ 2017-07-12 15:49       ` martin rudalics
  0 siblings, 0 replies; 129+ messages in thread
From: martin rudalics @ 2017-07-12 15:49 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: kaushal.modi, emacs-devel

 >>   > Should that
 >>   > variable name be instead "display-line-numbers-width"?
 >>
 >> I think so too.
 >
 > Feel free to fix as you see fit.

Done.

 >> Also, the latest fix of the doc-string of ‘display-line-numbers’
 >> introduced a few typos.  Maybe it should be even rewritten as sketched
 >> below (provided I managed to grasp the sense of it correctly).
 >
 > Fine with me, thanks.

Pushed as well.

martin




^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2017-07-08  7:58 Native line numbers landed on master Eli Zaretskii
                   ` (4 preceding siblings ...)
  2017-07-12  3:23 ` Kaushal Modi
@ 2017-07-15 22:02 ` Yuri D'Elia
  2017-07-16  2:34   ` Eli Zaretskii
  2019-06-10  2:46   ` Juanma Barranquero
  5 siblings, 2 replies; 129+ messages in thread
From: Yuri D'Elia @ 2017-07-15 22:02 UTC (permalink / raw)
  To: emacs-devel

On Sat, Jul 08 2017, Eli Zaretskii wrote:
> I've merged the line-numbers branch into master.  Please report any
> problems you see as result of this via 'report-emacs-bug', as usual.

I gave this a try today and I love the performance boost.
But I have an instant request ;)

Is there a way to customize the face on a line basis, like
`linum-format' allows?

I currently highlight every 5th line using a different face in order to
make the line numbers a little prettier ;)




^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2017-07-15 22:02 ` Yuri D'Elia
@ 2017-07-16  2:34   ` Eli Zaretskii
  2017-07-16 14:25     ` Eli Zaretskii
  2019-06-10  2:46   ` Juanma Barranquero
  1 sibling, 1 reply; 129+ messages in thread
From: Eli Zaretskii @ 2017-07-16  2:34 UTC (permalink / raw)
  To: Yuri D'Elia; +Cc: emacs-devel

> From: Yuri D'Elia <wavexx@thregr.org>
> Date: Sun, 16 Jul 2017 00:02:15 +0200
> 
> Is there a way to customize the face on a line basis, like
> `linum-format' allows?

No.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2017-07-12 14:40               ` Eli Zaretskii
@ 2017-07-16  7:30                 ` Alex
  2017-07-16 14:10                   ` Eli Zaretskii
  0 siblings, 1 reply; 129+ messages in thread
From: Alex @ 2017-07-16  7:30 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Alex <agrambot@gmail.com>
>> Cc: emacs-devel@gnu.org
>> Date: Tue, 11 Jul 2017 14:44:13 -0600
>> 
>> > Sounds OK to me, thanks.  I think we do want all the variables to
>> > appear in the same customization group, even if they are defined
>> > separately.
>> 
>> Well, it seems this cus-edit change doesn't fix it by itself. When
>> executing customize-group without display-line-numbers loaded, then the
>> lisp-level defcustoms aren't shown. It might be because there's a
>> missing entry in cus-load.el, but I don't know how to add a group to it.
>> linum, for instance, appears to automatically be added to it.
>
> cus-load.el is auto-generated.  Did the rule which updates it in
> lisp/Makefile get running after your changes, and was cus-load.el
> regenerated as result?  If not, maybe you need to run that rule by
> hand.

I'm still not well-versed in Emacs's build system. cus-load doesn't get
updated automatically for me (I had to manually run the target). Is this
expected? It appears that no rule forces cus-load to be regenerated, and
only bootstrap-clean removes the file.

After pulling changes, all I do is run "make -j4"; is it recommended to
run extra rules each time, or just when I notice issues?

>> Would it be better to skip creating a new defgroup and have all
>> variables just be in the display group, or are you in favour of a new
>> group just for line numbers?
>
> If it's a hassle to make a new group, we can stay in the display
> group.

It's not a hassle, but I was looking at the git-blame for cus-edit and
noticed that most of the entries are quite old. Is this group important
enough to add to the file?

It looks like I could just leave the defgroup definition in
display-line-numbers.el and the variables in cus-start.el can still use
it without display-line-numbers.el being preloaded.

Which file would you rather have it in?



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2017-07-16  7:30                 ` Alex
@ 2017-07-16 14:10                   ` Eli Zaretskii
  2017-07-16 19:31                     ` Alex
  0 siblings, 1 reply; 129+ messages in thread
From: Eli Zaretskii @ 2017-07-16 14:10 UTC (permalink / raw)
  To: Alex; +Cc: emacs-devel

> From: Alex <agrambot@gmail.com>
> Cc: emacs-devel@gnu.org
> Date: Sun, 16 Jul 2017 01:30:16 -0600
> 
> > cus-load.el is auto-generated.  Did the rule which updates it in
> > lisp/Makefile get running after your changes, and was cus-load.el
> > regenerated as result?  If not, maybe you need to run that rule by
> > hand.
> 
> I'm still not well-versed in Emacs's build system. cus-load doesn't get
> updated automatically for me (I had to manually run the target). Is this
> expected?

Yes, I think so.

> It appears that no rule forces cus-load to be regenerated, and
> only bootstrap-clean removes the file.

Indeed, I think the idea is that you should go into the lisp directory
and run "make custom-deps" there by hand.  This only runs
automatically at bootstrap time.

> After pulling changes, all I do is run "make -j4"; is it recommended to
> run extra rules each time, or just when I notice issues?

The latter.

> >> Would it be better to skip creating a new defgroup and have all
> >> variables just be in the display group, or are you in favour of a new
> >> group just for line numbers?
> >
> > If it's a hassle to make a new group, we can stay in the display
> > group.
> 
> It's not a hassle, but I was looking at the git-blame for cus-edit and
> noticed that most of the entries are quite old. Is this group important
> enough to add to the file?

Not terribly important, no.

> It looks like I could just leave the defgroup definition in
> display-line-numbers.el and the variables in cus-start.el can still use
> it without display-line-numbers.el being preloaded.
> 
> Which file would you rather have it in?

All else being equal, I think having as much as possible in
display-line-numbers.el would be better, as it avoids scattering
related stuff across different files.

Thanks.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2017-07-16  2:34   ` Eli Zaretskii
@ 2017-07-16 14:25     ` Eli Zaretskii
  2017-07-17  9:44       ` Yuri D'Elia
  0 siblings, 1 reply; 129+ messages in thread
From: Eli Zaretskii @ 2017-07-16 14:25 UTC (permalink / raw)
  To: wavexx; +Cc: emacs-devel

> Date: Sun, 16 Jul 2017 05:34:04 +0300
> From: Eli Zaretskii <eliz@gnu.org>
> Cc: emacs-devel@gnu.org
> 
> > From: Yuri D'Elia <wavexx@thregr.org>
> > Date: Sun, 16 Jul 2017 00:02:15 +0200
> > 
> > Is there a way to customize the face on a line basis, like
> > `linum-format' allows?
> 
> No.

We could add a face to be used for each line number that is a multiple
of some number N, which could be specified by the user, if enough
people would like such a feature.  But I don't think it's a good idea
to call a Lisp function when we produce line numbers, as that would
slow down redisplay too much.  Don't forget that redisplay is called
for even the simplest operations, like cursor motion commands, and in
many cases it will have to call that function for (almost) all the
lines visible in the window.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2017-07-16 14:10                   ` Eli Zaretskii
@ 2017-07-16 19:31                     ` Alex
  2017-07-17 15:00                       ` Eli Zaretskii
  0 siblings, 1 reply; 129+ messages in thread
From: Alex @ 2017-07-16 19:31 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

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

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Alex <agrambot@gmail.com>
>> Cc: emacs-devel@gnu.org
>> Date: Sun, 16 Jul 2017 01:30:16 -0600
>> 
>> It looks like I could just leave the defgroup definition in
>> display-line-numbers.el and the variables in cus-start.el can still use
>> it without display-line-numbers.el being preloaded.
>> 
>> Which file would you rather have it in?
>
> All else being equal, I think having as much as possible in
> display-line-numbers.el would be better, as it avoids scattering
> related stuff across different files.

I agree. Here's an updated patch that includes this as well as other
improvements:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-a-minor-mode-interface-for-display-line-numbers.patch --]
[-- Type: text/x-diff, Size: 6841 bytes --]

From d9149e30871377f90c0d5e08201b3405f3865d58 Mon Sep 17 00:00:00 2001
From: Alexander Gramiak <agrambot@gmail.com>
Date: Sun, 16 Jul 2017 13:16:49 -0600
Subject: [PATCH] Add a minor mode interface for display-line-numbers

* lisp/cus-start.el: Use the new display-line-numbers group.
* lisp/display-line-numbers.el: New file.
---
 lisp/cus-start.el            |   8 ++--
 lisp/display-line-numbers.el | 103 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 107 insertions(+), 4 deletions(-)
 create mode 100644 lisp/display-line-numbers.el

diff --git a/lisp/cus-start.el b/lisp/cus-start.el
index ed913e3268..c28b8a147f 100644
--- a/lisp/cus-start.el
+++ b/lisp/cus-start.el
@@ -584,7 +584,7 @@ minibuffer-prompt-properties--setter
 		       (const :tag "Grow only" :value grow-only))
 	      "25.1")
 	     (display-raw-bytes-as-hex display boolean "26.1")
-             (display-line-numbers display
+             (display-line-numbers display-line-numbers
                                    (choice
                                     (const :tag "Off (nil)" :value nil)
                                     (const :tag "Absolute line numbers"
@@ -594,7 +594,7 @@ minibuffer-prompt-properties--setter
                                     (const :tag "Visually relative line numbers"
                                            :value visual))
                                    "26.1")
-             (display-line-numbers-width display
+             (display-line-numbers-width display-line-numbers
                                  (choice
                                   (const :tag "Dynamically computed"
                                          :value nil)
@@ -602,14 +602,14 @@ minibuffer-prompt-properties--setter
                                            :value 2
                                            :format "%v"))
                                  "26.1")
-             (display-line-numbers-current-absolute display
+             (display-line-numbers-current-absolute display-line-numbers
                                  (choice
                                   (const :tag "Display actual number of current line"
                                          :value t)
                                   (const :tag "Display zero as number of current line"
                                          :value nil))
                                  "26.1")
-             (display-line-numbers-widen display
+             (display-line-numbers-widen display-line-numbers
                                  (choice
                                   (const :tag "Disregard narrowing when calculating line numbers"
                                          :value t)
diff --git a/lisp/display-line-numbers.el b/lisp/display-line-numbers.el
new file mode 100644
index 0000000000..95237250f9
--- /dev/null
+++ b/lisp/display-line-numbers.el
@@ -0,0 +1,103 @@
+;;; display-line-numbers.el --- interface for display-line-numbers -*- lexical-binding: t -*-
+
+;; Copyright (C) 2017 Free Software Foundation, Inc.
+
+;; Maintainer: emacs-devel@gnu.org
+;; Keywords: convenience
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Provides a minor mode interface for `display-line-numbers'.
+;;
+;; Toggle display of line numbers with M-x display-line-numbers-mode.
+;; To enable line numbering in all buffers, use M-x
+;; global-display-line-numbers-mode.  To change the default type of
+;; line numbers displayed, customize display-line-numbers-type.
+
+;; NOTE: Customization variables for `display-line-numbers' itself are
+;; defined in cus-start.el.
+
+;;; Code:
+
+(defgroup display-line-numbers nil
+  "Display line numbers in the buffer."
+  :group 'display)
+
+(defcustom display-line-numbers-type t
+  "The default type of line numbers to use in `display-line-numbers-mode'.
+See `display-line-numbers' for value options."
+  :group 'display-line-numbers
+  :type '(choice (const :tag "Relative line numbers" relative)
+                 (const :tag "Relative visual line numbers" visual)
+                 (other :tag "Absolute line numbers" t))
+  :version "26.1")
+
+(defcustom display-line-numbers-grow-only nil
+  "If non-nil, do not shrink line number width."
+  :group 'display-line-numbers
+  :type 'boolean
+  :version "26.1")
+
+(defcustom display-line-numbers-width-start nil
+  "If non-nil, count number of lines to use for line number width.
+When `display-line-numbers-mode' is turned on,
+`display-line-numbers-width' is set to the minimum width necessary
+to display all line numbers in the buffer."
+  :group 'display-line-numbers
+  :type 'boolean
+  :version "26.1")
+
+(defun display-line-numbers-update-width ()
+  "Prevent the line number width from shrinking."
+  (let ((width (line-number-display-width)))
+    (when (> width (or display-line-numbers-width 1))
+      (setq display-line-numbers-width width))))
+
+;;;###autoload
+(define-minor-mode display-line-numbers-mode
+  "Toggle display of line numbers in the buffer.
+This uses `display-line-numbers' internally.
+
+To change the type of line numbers displayed by default,
+customize `display-line-numbers-type'.  To change the type while
+the mode is on, set `display-line-numbers' directly."
+  :lighter nil
+  (if display-line-numbers-mode
+      (progn
+        (when display-line-numbers-width-start
+          (setq display-line-numbers-width
+                (length (number-to-string
+                         (count-lines (point-min) (point-max))))))
+        (when display-line-numbers-grow-only
+          (add-hook 'pre-command-hook #'display-line-numbers-update-width nil t))
+        (setq display-line-numbers display-line-numbers-type))
+    (remove-hook 'pre-command-hook #'display-line-numbers-update-width t)
+    (setq display-line-numbers nil)))
+
+;;;###autoload
+(define-globalized-minor-mode global-display-line-numbers-mode
+  display-line-numbers-mode
+  (lambda ()
+    (unless (or (minibufferp)
+                ;; taken from linum.el
+                (and (daemonp) (null (frame-parameter nil 'client))))
+      (display-line-numbers-mode))))
+
+(provide 'display-line-numbers)
+
+;;; display-line-numbers.el ends here
-- 
2.13.2


^ permalink raw reply related	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2017-07-16 14:25     ` Eli Zaretskii
@ 2017-07-17  9:44       ` Yuri D'Elia
  2017-07-17 14:16         ` Eli Zaretskii
  0 siblings, 1 reply; 129+ messages in thread
From: Yuri D'Elia @ 2017-07-17  9:44 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

On Sun, Jul 16 2017, Eli Zaretskii wrote:
> We could add a face to be used for each line number that is a multiple
> of some number N, which could be specified by the user, if enough
> people would like such a feature.

That would actually be more than enough for me.
I often use line number transiently, I don't use linum all the time.

For example, I rebound M-g M-g to:

(defun goto-line-with-feedback ()
  (interactive)
  (let ((display-line-numbers t))
    (goto-line (read-number "Goto line: "))))

as often, when you need to jump to a line number, you'd like to see more
context. Here performance is secondary, and banding does help:

https://www.thregr.org/~wavexx/tmp/2017-07-17T113633.jpg

My main gripe with linum/nlinum aside from the performance was that it
often has glitches in several modes. So far, I didn't have any trouble
with display-line-numbers.

> But I don't think it's a good idea to call a Lisp function when we
> produce line numbers, as that would slow down redisplay too much.
> Don't forget that redisplay is called for even the simplest
> operations, like cursor motion commands, and in many cases it will
> have to call that function for (almost) all the lines visible in the
> window.

I see the point.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2017-07-17  9:44       ` Yuri D'Elia
@ 2017-07-17 14:16         ` Eli Zaretskii
  0 siblings, 0 replies; 129+ messages in thread
From: Eli Zaretskii @ 2017-07-17 14:16 UTC (permalink / raw)
  To: Yuri D'Elia; +Cc: emacs-devel

> From: Yuri D'Elia <wavexx@thregr.org>
> Cc: emacs-devel@gnu.org
> Date: Mon, 17 Jul 2017 11:44:34 +0200
> 
> On Sun, Jul 16 2017, Eli Zaretskii wrote:
> > We could add a face to be used for each line number that is a multiple
> > of some number N, which could be specified by the user, if enough
> > people would like such a feature.
> 
> That would actually be more than enough for me.
> I often use line number transiently, I don't use linum all the time.

OK, then please file a feature-request bug report about this, so it
isn't forgotten, and let's see how many more people ask for it.

Thanks.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2017-07-16 19:31                     ` Alex
@ 2017-07-17 15:00                       ` Eli Zaretskii
  2017-07-17 20:34                         ` Alex
  0 siblings, 1 reply; 129+ messages in thread
From: Eli Zaretskii @ 2017-07-17 15:00 UTC (permalink / raw)
  To: Alex; +Cc: emacs-devel

> From: Alex <agrambot@gmail.com>
> Cc: emacs-devel@gnu.org
> Date: Sun, 16 Jul 2017 13:31:52 -0600
> 
> > All else being equal, I think having as much as possible in
> > display-line-numbers.el would be better, as it avoids scattering
> > related stuff across different files.
> 
> I agree. Here's an updated patch that includes this as well as other
> improvements:

LGTM, thanks.  How about updating the manual and NEWS as well?



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2017-07-17 15:00                       ` Eli Zaretskii
@ 2017-07-17 20:34                         ` Alex
  2017-07-22  9:18                           ` Eli Zaretskii
  0 siblings, 1 reply; 129+ messages in thread
From: Alex @ 2017-07-17 20:34 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

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

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Alex <agrambot@gmail.com>
>> Cc: emacs-devel@gnu.org
>> Date: Sun, 16 Jul 2017 13:31:52 -0600
>> 
>> > All else being equal, I think having as much as possible in
>> > display-line-numbers.el would be better, as it avoids scattering
>> > related stuff across different files.
>> 
>> I agree. Here's an updated patch that includes this as well as other
>> improvements:
>
> LGTM, thanks.  How about updating the manual and NEWS as well?

Sure, I've done that in [1]. I've also fixed a DEFSYM issue that was
caused by the rename from display-line-number-width to
display-line-numbers-width in patch [2]

Footnotes: 
[1]  

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: document --]
[-- Type: text/x-diff, Size: 5377 bytes --]

From 7a9aacd3a4d5f0a98050502f624aea3cbb4e6ce0 Mon Sep 17 00:00:00 2001
From: Alexander Gramiak <agrambot@gmail.com>
Date: Mon, 17 Jul 2017 14:14:45 -0600
Subject: [PATCH] Document display-line-numbers-mode

* doc/emacs/custom.texi (Init Rebinding): Re-add entry that used to
belong to linum-mode.
* doc/emacs/modes.texi (Minor Modes): Summarize the mode.
* etc/NEWS: Document display-line-numbers-mode and its customization
variables, and mention that display-line-numbers-width is
buffer-local.
---
 doc/emacs/custom.texi |  1 +
 doc/emacs/modes.texi  |  7 +++++++
 etc/NEWS              | 44 +++++++++++++++++++++++++++++---------------
 3 files changed, 37 insertions(+), 15 deletions(-)

diff --git a/doc/emacs/custom.texi b/doc/emacs/custom.texi
index a756a89e3f..1c9c14a962 100644
--- a/doc/emacs/custom.texi
+++ b/doc/emacs/custom.texi
@@ -1701,6 +1701,7 @@ Init Rebinding
 (global-set-key (kbd "C-c y") 'clipboard-yank)
 (global-set-key (kbd "C-M-q") 'query-replace)
 (global-set-key (kbd "<f5>") 'flyspell-mode)
+(global-set-key (kbd "C-<f5>") 'display-line-numbers-mode)
 (global-set-key (kbd "C-<right>") 'forward-sentence)
 (global-set-key (kbd "<mouse-2>") 'mouse-save-then-kill)
 @end example
diff --git a/doc/emacs/modes.texi b/doc/emacs/modes.texi
index eb0c88b290..876431aa9e 100644
--- a/doc/emacs/modes.texi
+++ b/doc/emacs/modes.texi
@@ -225,6 +225,13 @@ Minor Modes
 programs.  It is enabled globally by default, but you can disable it
 in individual buffers.  @xref{Faces}.
 
+@findex display-line-numbers-mode
+@cindex display-line-numbers-mode
+@item
+Display Line Numbers mode is a convenience wrapper around
+@code{display-line-numbers}, setting it using the value of
+@code{display-line-numbers-type}.  @xref{Display Custom}.
+
 @item
 Outline minor mode provides similar facilities to the major mode
 called Outline mode.  @xref{Outline Mode}.
diff --git a/etc/NEWS b/etc/NEWS
index edb71118ef..ccc9984c4c 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -424,13 +424,18 @@ range of indentation.
 This is similar to what linum-mode provides, but much faster and
 doesn't usurp the display margin for the line numbers.  Customize the
 buffer-local variable 'display-line-numbers' to activate this optional
-display.  If set to t, Emacs will display the number of each line
-before the line.  If set to 'relative', Emacs will display the line
-number relative to the line showing point, with that line's number
-displayed as absolute.  If set to 'visual', Emacs will display a
-relative number for every screen line, i.e. it will count screen lines
-rather than buffer lines.  The default is nil, which doesn't display
-the line numbers.
+display.  Alternatively, you can use the `display-line-numbers-mode'
+minor mode or the global `global-display-line-numbers-mode'.  When
+using these modes, customize `display-line-numbers-type' with the same
+value as you would use with `display-line-numbers'.
+
+If `display-line-numbers' is set to t, Emacs will display the number
+of each line before the line.  If set to 'relative', Emacs will
+display the line number relative to the line showing point, with that
+line's number displayed as absolute.  If set to 'visual', Emacs will
+display a relative number for every screen line, i.e. it will count
+screen lines rather than buffer lines.  The default is nil, which
+doesn't display the line numbers.
 
 In 'relative' and 'visual' modes, the variable
 'display-line-numbers-current-absolute' controls what number is
@@ -448,14 +453,23 @@ new face 'line-number-current-line' can be customized to display the
 current line's number differently from all the other line numbers; by
 default these two faces are identical.
 
-You can also customize the new variable 'display-line-numbers-width' to
-specify a fixed minimal with of the area allocated to line-number
-display.  The default is nil, meaning that Emacs will dynamically
-calculate the area width, enlarging or shrinking it as needed.
-Setting it to a non-negative integer specifies that as the minimal
-width; selecting a value  that is large enough to display all line
-numbers in a buffer will then keep the line-number display area of
-constant width at all times, if that is desired.
+You can also customize the new buffer-local variable
+'display-line-numbers-width' to specify a fixed minimal with of the
+area allocated to line-number display.  The default is nil, meaning
+that Emacs will dynamically calculate the area width, enlarging or
+shrinking it as needed.  Setting it to a non-negative integer
+specifies that as the minimal width; selecting a value that is large
+enough to display all line numbers in a buffer will then keep the
+line-number display area of constant width at all times, if that is
+desired.
+
+When using `display-line-numbers-mode', you can customize the variable
+`display-line-numbers-grow-only' to a non-nil value; this means that
+Emacs may grow the above area width dynamically, but never shrink it.
+Under this mode, customizing the variable
+`display-line-numbers-width-start' to a non-nil value will cause Emacs
+to set `display-line-numbers-width' to the minimum width necessary to
+display all line numbers in the current buffer when first visiting it.
 
 Lisp programs can disable line-number display for a particular screen
 line by putting the 'display-line-numbers-disable' text property or
-- 
2.13.2


[-- Attachment #3: Type: text/plain, Size: 6 bytes --]


[2]  

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: rename --]
[-- Type: text/x-diff, Size: 894 bytes --]

From 1d85de761577540ba5a85a39d91f6b3cf221b948 Mon Sep 17 00:00:00 2001
From: Alexander Gramiak <agrambot@gmail.com>
Date: Mon, 17 Jul 2017 14:12:24 -0600
Subject: [PATCH] * src/xdisp.c (syms_of_xdisp): Fix renaming omission

---
 src/xdisp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/xdisp.c b/src/xdisp.c
index 2aceb89c00..5e594347f0 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -32718,7 +32718,7 @@ even if the actual number needs less space.
 The default value of nil means compute the space dynamically.
 Any other value is treated as nil.  */);
   Vdisplay_line_numbers_width = Qnil;
-  DEFSYM (Qdisplay_line_numbers_width, "display-line-number-width");
+  DEFSYM (Qdisplay_line_numbers_width, "display-line-numbers-width");
   Fmake_variable_buffer_local (Qdisplay_line_numbers_width);
 
   DEFVAR_LISP ("display-line-numbers-current-absolute",
-- 
2.13.2


^ permalink raw reply related	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2017-07-17 20:34                         ` Alex
@ 2017-07-22  9:18                           ` Eli Zaretskii
  0 siblings, 0 replies; 129+ messages in thread
From: Eli Zaretskii @ 2017-07-22  9:18 UTC (permalink / raw)
  To: Alex; +Cc: emacs-devel

> From: Alex <agrambot@gmail.com>
> Cc: emacs-devel@gnu.org
> Date: Mon, 17 Jul 2017 14:34:17 -0600
> 
> >> > All else being equal, I think having as much as possible in
> >> > display-line-numbers.el would be better, as it avoids scattering
> >> > related stuff across different files.
> >> 
> >> I agree. Here's an updated patch that includes this as well as other
> >> improvements:
> >
> > LGTM, thanks.  How about updating the manual and NEWS as well?
> 
> Sure, I've done that in [1]. I've also fixed a DEFSYM issue that was
> caused by the rename from display-line-number-width to
> display-line-numbers-width in patch [2]

Thanks, I pushed this and the previous patch to the master branch.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Sharp-quoting function symbols (Was: Native line numbers landed on master)
  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
  0 siblings, 1 reply; 129+ messages in thread
From: Philipp Stephani @ 2017-09-30 18:36 UTC (permalink / raw)
  To: Kaushal Modi, Stefan Monnier, Eli Zaretskii; +Cc: emacs-devel

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

Kaushal Modi <kaushal.modi@gmail.com> schrieb am Di., 11. Juli 2017 um
20:23 Uhr:

> Hello all,
>
> I can speak for myself that I religiously follow the convention to use
> #'SYMBOL instead of 'SYMBOL where SYMBOL is expected to be a function in
> the form where it's used; exactly for the reasons that Stephan mentioned.
> In addition, to the user it becomes evident if that symbol is expected to
> be a function or not.
>
> I use that convention in my emacs config, packages, etc. I have even seen
> that convention in many other packages and configs too, from what I follow
> on emacs.stackexchange, reddit, etc.
>
> This[1] is a very popular post out in the wild, by Artur Malabarba that
> explains why and when one should use sharp-quotes or hash-quotes.
>
> If we are counting votes to add this to the official documentation, my
> vote is in :)
>
>
I, too, agree that sharp-quoting should be an official recommendation.

[-- Attachment #2: Type: text/html, Size: 1416 bytes --]

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Sharp-quoting function symbols (Was: Native line numbers landed on master)
  2017-09-30 18:36                 ` Philipp Stephani
@ 2017-12-30 21:09                   ` Philipp Stephani
  0 siblings, 0 replies; 129+ messages in thread
From: Philipp Stephani @ 2017-12-30 21:09 UTC (permalink / raw)
  To: Kaushal Modi, Stefan Monnier, Eli Zaretskii; +Cc: emacs-devel

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

Philipp Stephani <p.stephani2@gmail.com> schrieb am Sa., 30. Sep. 2017 um
20:36 Uhr:

> Kaushal Modi <kaushal.modi@gmail.com> schrieb am Di., 11. Juli 2017 um
> 20:23 Uhr:
>
>> Hello all,
>>
>> I can speak for myself that I religiously follow the convention to use
>> #'SYMBOL instead of 'SYMBOL where SYMBOL is expected to be a function in
>> the form where it's used; exactly for the reasons that Stephan mentioned.
>> In addition, to the user it becomes evident if that symbol is expected to
>> be a function or not.
>>
>> I use that convention in my emacs config, packages, etc. I have even seen
>> that convention in many other packages and configs too, from what I follow
>> on emacs.stackexchange, reddit, etc.
>>
>> This[1] is a very popular post out in the wild, by Artur Malabarba that
>> explains why and when one should use sharp-quotes or hash-quotes.
>>
>> If we are counting votes to add this to the official documentation, my
>> vote is in :)
>>
>>
> I, too, agree that sharp-quoting should be an official recommendation.
>

I've checked some sections of the Lisp manual: while #' is used in many
places, it's only described in the context of lambdas. Other sections (such
as "Mapping functions") don't use it. Maybe this should be described early
on, e.g. in "What is a function" or "Function names".

[-- Attachment #2: Type: text/html, Size: 2180 bytes --]

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2017-07-15 22:02 ` Yuri D'Elia
  2017-07-16  2:34   ` Eli Zaretskii
@ 2019-06-10  2:46   ` Juanma Barranquero
  2019-06-10  8:32     ` Yuri D'Elia
  2019-06-10 15:22     ` Eli Zaretskii
  1 sibling, 2 replies; 129+ messages in thread
From: Juanma Barranquero @ 2019-06-10  2:46 UTC (permalink / raw)
  To: Yuri D'Elia; +Cc: Emacs developers

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

[Yes, I know that I'm replying to a two-years-old thread...]

On Sun, Jul 16, 2017 at 12:03 AM Yuri D'Elia <wavexx@thregr.org> wrote:

> Is there a way to customize the face on a line basis, like
> `linum-format' allows?
>
> I currently highlight every 5th line using a different face in order to
> make the line numbers a little prettier ;)

Performance-wise, the new line numbers are fantastic. Great job, Eli.

But I miss the ability to call a function to return the "number"
string, as I did in linum.

(The image shows both my customized linum.el numbers and the new
native line numbers, for comparison.)

To be clear, I'm not *asking* for it to be implemented. I can imagine
the performance hit, and the added complexity for a feature that
almost nobody (except, apparently, Yuri D'Elia and I) would find
useful.

[-- Attachment #2: linum.png --]
[-- Type: image/png, Size: 42162 bytes --]

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  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
  1 sibling, 1 reply; 129+ messages in thread
From: Yuri D'Elia @ 2019-06-10  8:32 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: Emacs developers

On Mon, Jun 10 2019, Juanma Barranquero wrote:
> (The image shows both my customized linum.el numbers and the new
> native line numbers, for comparison.)
>
> To be clear, I'm not *asking* for it to be implemented. I can imagine
> the performance hit, and the added complexity for a feature that
> almost nobody (except, apparently, Yuri D'Elia and I) would find
> useful.

It's a small tweak, but what is emacs if not a never-ending list of
small tweaks here and there ;)



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-06-10  8:32     ` Yuri D'Elia
@ 2019-06-10 12:38       ` Juanma Barranquero
  0 siblings, 0 replies; 129+ messages in thread
From: Juanma Barranquero @ 2019-06-10 12:38 UTC (permalink / raw)
  To: Yuri D'Elia; +Cc: Emacs developers

I think the issue would be its impact on performance on something
critical like redisplay.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-06-10  2:46   ` Juanma Barranquero
  2019-06-10  8:32     ` Yuri D'Elia
@ 2019-06-10 15:22     ` Eli Zaretskii
  2019-06-10 15:32       ` Juanma Barranquero
  2019-06-10 15:33       ` Yuri D'Elia
  1 sibling, 2 replies; 129+ messages in thread
From: Eli Zaretskii @ 2019-06-10 15:22 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: wavexx, emacs-devel

> From: Juanma Barranquero <lekktu@gmail.com>
> Date: Mon, 10 Jun 2019 04:46:29 +0200
> Cc: Emacs developers <emacs-devel@gnu.org>
> 
> But I miss the ability to call a function to return the "number"
> string, as I did in linum.
> 
> (The image shows both my customized linum.el numbers and the new
> native line numbers, for comparison.)

If the issue is to have an option that will only display every Nth
line number, maybe we can do that without allowing a function call.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-06-10 15:22     ` Eli Zaretskii
@ 2019-06-10 15:32       ` Juanma Barranquero
  2019-06-10 15:33       ` Yuri D'Elia
  1 sibling, 0 replies; 129+ messages in thread
From: Juanma Barranquero @ 2019-06-10 15:32 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: wavexx, Emacs developers

> If the issue is to have an option that will only display every Nth
> line number, maybe we can do that without allowing a function call.

I really like linum's ability to do "fancy" things with the line
number. But I understand why I'm in a very small minority and the
effort and performance impact aren't worth implementing it.

As for the option to display it every Nth line, that would be helpful,
yes. I find much more clear to have the number every five lines or so
than having a wall of three- or four-digit numbers (for large files).
Alternatively, the ability to use different faces for the Nth lines
and for the non-Nth ones (so I can use a very dim face for the non-Nth
ones).

Thanks for considering this.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  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
  1 sibling, 1 reply; 129+ messages in thread
From: Yuri D'Elia @ 2019-06-10 15:33 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Juanma Barranquero, emacs-devel

On Mon, Jun 10 2019, Eli Zaretskii wrote:
>> (The image shows both my customized linum.el numbers and the new
>> native line numbers, for comparison.)
>
> If the issue is to have an option that will only display every Nth
> line number, maybe we can do that without allowing a function call.

Hiding would be too much for me. But the ability to change the
:foreground property for a multiple of N should be equivalent.

But as a side note: is this really that impactful to add a regular hook?
Surely this would (?) be run only for visible lines, of which you don't
have many. If you restrict to certain face properties such as face
colors, you can ensure there's no change in width. But it's just
speculation on my part, I didn't look at how redisplay is handled.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-06-10 15:33       ` Yuri D'Elia
@ 2019-06-10 15:54         ` Eli Zaretskii
  2019-06-10 16:23           ` Yuri D'Elia
  0 siblings, 1 reply; 129+ messages in thread
From: Eli Zaretskii @ 2019-06-10 15:54 UTC (permalink / raw)
  To: Yuri D'Elia; +Cc: lekktu, emacs-devel

> From: Yuri D'Elia <wavexx@thregr.org>
> Cc: Juanma Barranquero <lekktu@gmail.com>, emacs-devel@gnu.org
> Date: Mon, 10 Jun 2019 17:33:27 +0200
> 
> But as a side note: is this really that impactful to add a regular hook?

It's a feature creep that I would like to avoid.

> Surely this would (?) be run only for visible lines

No, that's not true.  The display code is also called for portions of
text that aren't going to be displayed, when Emacs needs to figure out
dimensions of some text or perform layout calculations without
displaying anything.  As just one example, vertical-motion, which is
at the core of any vertical motion command (C-n, C-p, etc.) does that.
Another popular example is posn-at-point.

> If you restrict to certain face properties such as face
> colors, you can ensure there's no change in width.

How can we justify support for only some faces?  This is the kind of a
slippery slope that I would like to avoid.  Too many display features
let users do stuff with unimaginable leeway, and we pay for that both
in performance and in maintainability.  I'm trying to avoid such
feature creep in this case, be that as un-emacsy as it might seem.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-06-10 15:54         ` Eli Zaretskii
@ 2019-06-10 16:23           ` Yuri D'Elia
  2019-06-10 17:41             ` Eli Zaretskii
  0 siblings, 1 reply; 129+ messages in thread
From: Yuri D'Elia @ 2019-06-10 16:23 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: lekktu, emacs-devel

On Mon, Jun 10 2019, Eli Zaretskii wrote:
>> If you restrict to certain face properties such as face
>> colors, you can ensure there's no change in width.
>
> How can we justify support for only some faces?

What I meant really is just specific face properties to avoid the need
to recalculate widths, but now that I check, we already allow to
"line-number-current-line-face" to be a different face entirely.

> I'm trying to avoid such feature creep in this case, be that as
> un-emacsy as it might seem.

I'm quite happy about display-line-numbers. I'm using it more than
before now that it has little difference in performance, so I concur.

I also consider color-banding very helpful for readability though.
That's the reason most tape measures and rulers have alternate ticks or
colors.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-06-10 16:23           ` Yuri D'Elia
@ 2019-06-10 17:41             ` Eli Zaretskii
  2019-09-30 10:01               ` Juanma Barranquero
  0 siblings, 1 reply; 129+ messages in thread
From: Eli Zaretskii @ 2019-06-10 17:41 UTC (permalink / raw)
  To: Yuri D'Elia; +Cc: lekktu, emacs-devel

> From: Yuri D'Elia <wavexx@thregr.org>
> Cc: lekktu@gmail.com, emacs-devel@gnu.org
> Date: Mon, 10 Jun 2019 18:23:24 +0200
> 
> What I meant really is just specific face properties to avoid the need
> to recalculate widths, but now that I check, we already allow to
> "line-number-current-line-face" to be a different face entirely.

Right.  So we could use something similar for lines whose numbers are
integral multiples of N, for some N.  I think a limited number of
specific features like that is better than a total freedom via a
function call.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-06-10 17:41             ` Eli Zaretskii
@ 2019-09-30 10:01               ` Juanma Barranquero
  2019-09-30 10:21                 ` Eli Zaretskii
  0 siblings, 1 reply; 129+ messages in thread
From: Juanma Barranquero @ 2019-09-30 10:01 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Yuri D'Elia, Emacs developers

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

On Mon, Jun 10, 2019 at 7:41 PM Eli Zaretskii <eliz@gnu.org> wrote:

> Right.  So we could use something similar for lines whose numbers are
> integral multiples of N, for some N.  I think a limited number of
> specific features like that is better than a total freedom via a
> function call.

The thread waned, but I still think it'd be useful at least to be able to
use a different face for some line numbers. In fact, having for multiples
of 5, of 10, and all the rest, would be ideal.

[-- Attachment #2: Type: text/html, Size: 644 bytes --]

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-09-30 10:01               ` Juanma Barranquero
@ 2019-09-30 10:21                 ` Eli Zaretskii
  2019-10-01  5:44                   ` Juanma Barranquero
  0 siblings, 1 reply; 129+ messages in thread
From: Eli Zaretskii @ 2019-09-30 10:21 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: wavexx, emacs-devel

> From: Juanma Barranquero <lekktu@gmail.com>
> Date: Mon, 30 Sep 2019 12:01:25 +0200
> Cc: "Yuri D'Elia" <wavexx@thregr.org>, Emacs developers <emacs-devel@gnu.org>
> 
> On Mon, Jun 10, 2019 at 7:41 PM Eli Zaretskii <eliz@gnu.org> wrote:
> 
> > Right.  So we could use something similar for lines whose numbers are
> > integral multiples of N, for some N.  I think a limited number of
> > specific features like that is better than a total freedom via a
> > function call.
> 
> The thread waned, but I still think it'd be useful at least to be able to use a different face for some line
> numbers. In fact, having for multiples of 5, of 10, and all the rest, would be ideal.

Patches welcome.  I don't think it should be too hard to write that.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-09-30 10:21                 ` Eli Zaretskii
@ 2019-10-01  5:44                   ` Juanma Barranquero
  2019-10-01  7:05                     ` Eli Zaretskii
  2019-10-01  9:09                     ` Yuri D'Elia
  0 siblings, 2 replies; 129+ messages in thread
From: Juanma Barranquero @ 2019-10-01  5:44 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: wavexx, Emacs developers

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

On Mon, Sep 30, 2019 at 12:21 PM Eli Zaretskii <eliz@gnu.org> wrote:

> Patches welcome.

To quote Barney Stinson, "Challenge accepted!"

> I don't think it should be too hard to write that.

Didn't know you were an optimist.

Ok. The following extremely simple patch (with no documentation, etc, and
horrible, *horrible* face names because I couldn't think of anything
better) seems to work in the various tests I've done in absolute, visual
and relative modes.

Now, I'm not sure about code (try_cursor_movement and try_window_id) that
compare the line-number and line-number-current-line faces for
optimization. Performance seems to be fine, and I haven't seen any obvious
visual glitch.

Also, this in maybe_produce_line_number:

  /* Compute point's line number if needed.  */
  if ((EQ (Vdisplay_line_numbers, Qrelative)
       || EQ (Vdisplay_line_numbers, Qvisual)
       || lnum_face_id != current_lnum_face_id)
      && !it->pt_lnum)

should perhaps compare curremt_lnum_face_id also with the face_ids of the
two new faces. ?


diff --git i/lisp/faces.el w/lisp/faces.el
index 9c5ffe1e59..0d9107a6a0 100644
--- i/lisp/faces.el
+++ w/lisp/faces.el
@@ -2391,4 +2391,35 @@ line-number-current-line
   :group 'display-line-numbers)

+(defface line-number-ends-5
+  '((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-ends-0
+  '((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
diff --git i/src/xdisp.c w/src/xdisp.c
index 95895ec3ac..7d5c0b11f4 100644
--- i/src/xdisp.c
+++ w/src/xdisp.c
@@ -21483,4 +21483,8 @@ maybe_produce_line_number (struct it *it)
   int current_lnum_face_id
     = merge_faces (it->w, Qline_number_current_line, 0, DEFAULT_FACE_ID);
+  int mul5_lnum_face_id
+    = merge_faces (it->w, Qline_number_ends_5, 0, DEFAULT_FACE_ID);
+  int mul10_lnum_face_id
+    = merge_faces (it->w, Qline_number_ends_0, 0, DEFAULT_FACE_ID);
   /* Compute point's line number if needed.  */
   if ((EQ (Vdisplay_line_numbers, Qrelative)
@@ -21576,4 +21580,8 @@ maybe_produce_line_number (struct it *it)
   && it->what != IT_EOB)
  tem_it.face_id = current_lnum_face_id;
+      else if (lnum_to_display % 10 == 0)
+ tem_it.face_id = mul10_lnum_face_id;
+      else if (lnum_to_display % 5 == 0)
+ tem_it.face_id = mul5_lnum_face_id;
       else
  tem_it.face_id = lnum_face_id;
@@ -32971,4 +32979,6 @@ syms_of_xdisp (void)
   DEFSYM (Qline_number, "line-number");
   DEFSYM (Qline_number_current_line, "line-number-current-line");
+  DEFSYM (Qline_number_ends_5, "line-number-ends-5");
+  DEFSYM (Qline_number_ends_0, "line-number-ends-0");
   /* Name of a text property which disables line-number display.  */
   DEFSYM (Qdisplay_line_numbers_disable, "display-line-numbers-disable");

[-- Attachment #2: Type: text/html, Size: 4651 bytes --]

^ permalink raw reply related	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-01  5:44                   ` Juanma Barranquero
@ 2019-10-01  7:05                     ` Eli Zaretskii
  2019-10-01  8:49                       ` Juanma Barranquero
  2019-10-01  9:09                     ` Yuri D'Elia
  1 sibling, 1 reply; 129+ messages in thread
From: Eli Zaretskii @ 2019-10-01  7:05 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: wavexx, emacs-devel

> From: Juanma Barranquero <lekktu@gmail.com>
> Date: Tue, 1 Oct 2019 07:44:47 +0200
> Cc: wavexx@thregr.org, Emacs developers <emacs-devel@gnu.org>
> 
> > Patches welcome.
> 
> To quote Barney Stinson, "Challenge accepted!"

Thanks.

> > I don't think it should be too hard to write that.
> 
> Didn't know you were an optimist.

I am not.

> Ok. The following extremely simple patch (with no documentation, etc, and
> horrible, *horrible* face names because I couldn't think of anything
> better) seems to work in the various tests I've done in absolute, visual
> and relative modes.

Ideas for better face names are welcome.  I can suggest:

  line-number-tenth-line
  line-number-fifth-line

(the latter is inaccurate, but a doc string can explain the subtlety).

> Now, I'm not sure about code (try_cursor_movement and try_window_id) that
> compare the line-number and line-number-current-line faces for
> optimization. Performance seems to be fine, and I haven't seen any obvious
> visual glitch.
> 
> Also, this in maybe_produce_line_number:
> 
>   /* Compute point's line number if needed.  */
>   if ((EQ (Vdisplay_line_numbers, Qrelative)
>        || EQ (Vdisplay_line_numbers, Qvisual)
>        || lnum_face_id != current_lnum_face_id)
>       && !it->pt_lnum)
> 
> should perhaps compare curremt_lnum_face_id also with the face_ids of the
> two new faces. ?

I don't think so.  Both the issue with disabling try_cursor_movement
and try_window_id, and the issue with the above 'if' clause are
because the line-number-current-line face is used for the _current_
line, whose position is not fixed wrt to the rest of the lines, but
changes due to moving point.  For that reason, any point movement
means the new and the old "current" lines need to be redrawn, even
though neither their text nor their line numbers have changed.  By
contrast, the 5th and 10th lines' positions wrt to the rest of the
lines are fixed, so point movement doesn't require to redraw these
lines.

The above is the theory, but I understand you didn't see any redisplay
problems without those changes?  If so, the theory is correct.

I suggest to wait for a week or so, to let people try the patch and
suggest better names for the faces, then push this.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  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:25                         ` Eli Zaretskii
  0 siblings, 2 replies; 129+ messages in thread
From: Juanma Barranquero @ 2019-10-01  8:49 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: wavexx, Emacs developers


[-- Attachment #1.1.1: Type: text/plain, Size: 106 bytes --]

Here's a version with NEWS, doc, and the face names you proposed.

An example of use:

[image: image.png]

[-- Attachment #1.1.2: Type: text/html, Size: 249 bytes --]

[-- Attachment #1.2: image.png --]
[-- Type: image/png, Size: 150940 bytes --]

[-- Attachment #2: 0001-New-faces-to-higlight-line-numbers-multiple-of-5-and.patch --]
[-- Type: application/octet-stream, Size: 5208 bytes --]

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


^ permalink raw reply related	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  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
  1 sibling, 1 reply; 129+ messages in thread
From: Juanma Barranquero @ 2019-10-01  8:55 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: wavexx, Emacs developers


[-- Attachment #1.1: Type: text/plain, Size: 882 bytes --]

BTW, this:

      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;

could also be written

      else if (lnum_to_display % 5 != 0)
        tem_it.face_id = lnum_face_id;
      else if (lnum_to_display % 10 == 0)
        tem_it.face_id = tenth_lnum_face_id;
      else /* lnum_to_display % 5 == 0 */
        tem_it.face_id = fifth_lnum_face_id;

with the idea that 80% of lines fall into the linum_face_id case, so it's
better to have it first. But I suspect it's a micro-optimization best left
to modern compilers.


On Tue, Oct 1, 2019 at 10:49 AM Juanma Barranquero <lekktu@gmail.com> wrote:

>
> Here's a version with NEWS, doc, and the face names you proposed.
>
> An example of use:
>
> [image: image.png]
>

[-- Attachment #1.2: Type: text/html, Size: 1488 bytes --]

[-- Attachment #2: image.png --]
[-- Type: image/png, Size: 150940 bytes --]

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-01  5:44                   ` Juanma Barranquero
  2019-10-01  7:05                     ` Eli Zaretskii
@ 2019-10-01  9:09                     ` Yuri D'Elia
  2019-10-01  9:21                       ` Juanma Barranquero
  2019-10-01  9:24                       ` Eli Zaretskii
  1 sibling, 2 replies; 129+ messages in thread
From: Yuri D'Elia @ 2019-10-01  9:09 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: Eli Zaretskii, Emacs developers

On Tue, Oct 01 2019, Juanma Barranquero wrote:
> +(defface line-number-ends-5
> +  '((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.

I'd personally prefer to see a single, customizable integer for
multiples, instead of selecting 5 and 10 arbitrarily.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  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:47                         ` Lars Ingebrigtsen
  2019-10-01  9:24                       ` Eli Zaretskii
  1 sibling, 2 replies; 129+ messages in thread
From: Juanma Barranquero @ 2019-10-01  9:21 UTC (permalink / raw)
  To: Yuri D'Elia; +Cc: Eli Zaretskii, Emacs developers

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

On Tue, Oct 1, 2019 at 11:09 AM Yuri D'Elia <wavexx@thregr.org> wrote:

> I'd personally prefer to see a single, customizable integer for
> multiples, instead of selecting 5 and 10 arbitrarily.

A single, customizable integer does not solve my use case, which is to
highlight tens and fives differently.

It'd be possible to add two faces, line-number-Nth-line and
line-number-Mth-line, and add variables to customize that N and M instead
of what I've done.

But, are you suggesting it just because it is more generic, or do you have
an use case for another integer?

[-- Attachment #2: Type: text/html, Size: 734 bytes --]

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-01  9:09                     ` Yuri D'Elia
  2019-10-01  9:21                       ` Juanma Barranquero
@ 2019-10-01  9:24                       ` Eli Zaretskii
  1 sibling, 0 replies; 129+ messages in thread
From: Eli Zaretskii @ 2019-10-01  9:24 UTC (permalink / raw)
  To: Yuri D'Elia; +Cc: lekktu, emacs-devel

> From: Yuri D'Elia <wavexx@thregr.org>
> Cc: Eli Zaretskii <eliz@gnu.org>, Emacs developers <emacs-devel@gnu.org>
> Date: Tue, 01 Oct 2019 11:09:02 +0200
> 
> I'd personally prefer to see a single, customizable integer for
> multiples, instead of selecting 5 and 10 arbitrarily.

If it's a single integer, there could be just one face, no?

And what value would you use for that integer, if it were available?



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-01  8:49                       ` Juanma Barranquero
  2019-10-01  8:55                         ` Juanma Barranquero
@ 2019-10-01  9:25                         ` Eli Zaretskii
  1 sibling, 0 replies; 129+ messages in thread
From: Eli Zaretskii @ 2019-10-01  9:25 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: wavexx, emacs-devel

> From: Juanma Barranquero <lekktu@gmail.com>
> Date: Tue, 1 Oct 2019 10:49:51 +0200
> Cc: wavexx@thregr.org, Emacs developers <emacs-devel@gnu.org>
> 
> Here's a version with NEWS, doc, and the face names you proposed.

LGTM, thanks.

> An example of use:

Looks fine.  Let's see what others think.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-01  8:55                         ` Juanma Barranquero
@ 2019-10-01  9:26                           ` Eli Zaretskii
  0 siblings, 0 replies; 129+ messages in thread
From: Eli Zaretskii @ 2019-10-01  9:26 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: wavexx, emacs-devel

> From: Juanma Barranquero <lekktu@gmail.com>
> Date: Tue, 1 Oct 2019 10:55:51 +0200
> Cc: wavexx@thregr.org, Emacs developers <emacs-devel@gnu.org>
> 
> BTW, this:
> 
>       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;
> 
> could also be written
> 
>       else if (lnum_to_display % 5 != 0)
>         tem_it.face_id = lnum_face_id;
>       else if (lnum_to_display % 10 == 0)
>         tem_it.face_id = tenth_lnum_face_id;
>       else /* lnum_to_display % 5 == 0 */
>         tem_it.face_id = fifth_lnum_face_id;
> 
> with the idea that 80% of lines fall into the linum_face_id case, so it's better to have it first. But I suspect it's a
> micro-optimization best left to modern compilers.

I'm okay with either version.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  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:39                           ` Eli Zaretskii
  2019-10-01 10:47                         ` Lars Ingebrigtsen
  1 sibling, 2 replies; 129+ messages in thread
From: Yuri D'Elia @ 2019-10-01  9:51 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: Eli Zaretskii, Emacs developers

On Tue, Oct 01 2019, Juanma Barranquero wrote:
> It'd be possible to add two faces, line-number-Nth-line and
> line-number-Mth-line, and add variables to customize that N and M instead
> of what I've done.
>
> But, are you suggesting it just because it is more generic, or do you have
> an use case for another integer?

Well, I did use linum formatting in weird ways before :)

But if I'd take two integers, I would put 10,100 or even 10,1000 instead.
When scanning through large files I'd rather think in bigger numbers.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  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
  1 sibling, 1 reply; 129+ messages in thread
From: Juanma Barranquero @ 2019-10-01 10:23 UTC (permalink / raw)
  To: Yuri D'Elia; +Cc: Eli Zaretskii, Emacs developers

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

On Tue, Oct 1, 2019 at 11:51 AM Yuri D'Elia <wavexx@thregr.org> wrote:

> Well, I did use linum formatting in weird ways before :)

Oh, I did too. Miss it, but it was slow and never worked very well.

> But if I'd take two integers, I would put 10,100 or even 10,1000 instead.
> When scanning through large files I'd rather think in bigger numbers.

Interesting.

[-- Attachment #2: Type: text/html, Size: 540 bytes --]

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-01  9:51                         ` Yuri D'Elia
  2019-10-01 10:23                           ` Juanma Barranquero
@ 2019-10-01 10:39                           ` Eli Zaretskii
  1 sibling, 0 replies; 129+ messages in thread
From: Eli Zaretskii @ 2019-10-01 10:39 UTC (permalink / raw)
  To: Yuri D'Elia; +Cc: lekktu, emacs-devel

> From: Yuri D'Elia <wavexx@thregr.org>
> Cc: Eli Zaretskii <eliz@gnu.org>, Emacs developers <emacs-devel@gnu.org>
> Date: Tue, 01 Oct 2019 11:51:28 +0200
> 
> But if I'd take two integers, I would put 10,100 or even 10,1000 instead.
> When scanning through large files I'd rather think in bigger numbers.

Can you tell why?  100 lines might fit in a single windowful, but 1000
most probably won't.  So what is the purpose of having such far-away
milestones?  Are you using line numbers for something other than
navigation through the buffer?



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-01 10:23                           ` Juanma Barranquero
@ 2019-10-01 10:40                             ` Yuri D'Elia
  0 siblings, 0 replies; 129+ messages in thread
From: Yuri D'Elia @ 2019-10-01 10:40 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: Eli Zaretskii, Emacs developers

On Tue, Oct 01 2019, Juanma Barranquero wrote:
>> But if I'd take two integers, I would put 10,100 or even 10,1000 instead.
>> When scanning through large files I'd rather think in bigger numbers.
>
> Interesting.

To corroborate, I'd should point out that I rarely use[d] linum on
source code. I only activate line numbers temporarily through goto-line,
and would mostly use '10' there, for quick readability.

But I do use line numbers frequently when scanning through data files of
various forms, especially now that numbers are fast. For data it's
generally much more useful to use large numbers or something that
has meaning in data.

In linum I also used to apply a line offset to ignore the initial
headers of many text files. When using this offset consistently in both
linum and a tweaked goto-line you can essentially jump to "records",
which is incredibly neat for many scenarios.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-01  9:21                       ` Juanma Barranquero
  2019-10-01  9:51                         ` Yuri D'Elia
@ 2019-10-01 10:47                         ` Lars Ingebrigtsen
  2019-10-01 11:07                           ` Eli Zaretskii
  2019-10-01 11:11                           ` Juanma Barranquero
  1 sibling, 2 replies; 129+ messages in thread
From: Lars Ingebrigtsen @ 2019-10-01 10:47 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: Yuri D'Elia, Eli Zaretskii, Emacs developers

Juanma Barranquero <lekktu@gmail.com> writes:

> It'd be possible to add two faces, line-number-Nth-line and
> line-number-Mth-line, and add variables to customize that N and M
> instead of what I've done.

What about an alist?

'((5 some-face)
  (10 some-other-face)
  (100 yet-another-face))
  
-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-01 10:47                         ` Lars Ingebrigtsen
@ 2019-10-01 11:07                           ` Eli Zaretskii
  2019-10-01 11:11                           ` Juanma Barranquero
  1 sibling, 0 replies; 129+ messages in thread
From: Eli Zaretskii @ 2019-10-01 11:07 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: wavexx, lekktu, emacs-devel

> From: Lars Ingebrigtsen <larsi@gnus.org>
> Cc: "Yuri D'Elia" <wavexx@thregr.org>,  Eli Zaretskii <eliz@gnu.org>,  Emacs
>  developers <emacs-devel@gnu.org>
> Date: Tue, 01 Oct 2019 12:47:26 +0200
> 
> What about an alist?
> 
> '((5 some-face)
>   (10 some-other-face)
>   (100 yet-another-face))

Please, no.  Not another reason for consing and Lisp errors inside
redisplay.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  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
  1 sibling, 1 reply; 129+ messages in thread
From: Juanma Barranquero @ 2019-10-01 11:11 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Yuri D'Elia, Eli Zaretskii, Emacs developers

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

On Tue, Oct 1, 2019 at 12:47 PM Lars Ingebrigtsen <larsi@gnus.org> wrote:

> What about an alist?
>
> '((5 some-face)
>   (10 some-other-face)
>   (100 yet-another-face))

There are many things that could be useful, but Eli already said several
months ago that he doesn't want to add bells and whistles that would make
redisplay slower and more fragile.

My patch implements (more or less) something that he said back then that it
would be acceptable.

[-- Attachment #2: Type: text/html, Size: 619 bytes --]

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-01 11:11                           ` Juanma Barranquero
@ 2019-10-01 22:52                             ` Ergus
  2019-10-01 23:51                               ` Juanma Barranquero
  0 siblings, 1 reply; 129+ messages in thread
From: Ergus @ 2019-10-01 22:52 UTC (permalink / raw)
  To: Juanma Barranquero
  Cc: Lars Ingebrigtsen, Yuri D'Elia, Eli Zaretskii,
	Emacs developers

Hi Juanma:

I would like to suggest two small changes to the patch if you agree:

1) I don't have any strong feeling about using one or two values. But in
any case they should be configurable. This will add more use cases that
could benefit with this and I think it will be simple to implement (just
need to add 2 int variables).

2) Is it possible to call merge_faces more lazily? I mean inside the
`if` `else if` so only one of them will be called when needed. AFAIK
maybe_produce_line_number is called for every line and the code needs
only one of those merges every 5/10/x lines.  (This will benefit more
the user who sets the values in 1) bigger)

Very thanks for this contribution.
Ergus.


On Tue, Oct 01, 2019 at 01:11:38PM +0200, Juanma Barranquero wrote:
>On Tue, Oct 1, 2019 at 12:47 PM Lars Ingebrigtsen <larsi@gnus.org> wrote:
>
>> What about an alist?
>>
>> '((5 some-face)
>>   (10 some-other-face)
>>   (100 yet-another-face))
>
>There are many things that could be useful, but Eli already said several
>months ago that he doesn't want to add bells and whistles that would make
>redisplay slower and more fragile.
>
>My patch implements (more or less) something that he said back then that it
>would be acceptable.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-01 22:52                             ` Ergus
@ 2019-10-01 23:51                               ` Juanma Barranquero
  2019-10-02  3:41                                 ` Ergus
  2019-10-02 15:06                                 ` Eli Zaretskii
  0 siblings, 2 replies; 129+ messages in thread
From: Juanma Barranquero @ 2019-10-01 23:51 UTC (permalink / raw)
  To: Ergus; +Cc: Yuri D'Elia, Lars Ingebrigtsen, Eli Zaretskii,
	Emacs developers


[-- Attachment #1.1: Type: text/plain, Size: 833 bytes --]

On Wed, Oct 2, 2019 at 12:53 AM Ergus <spacibba@aol.com> wrote:

> 1) I don't have any strong feeling about using one or two values. But in
> any case they should be configurable. This will add more use cases that
> could benefit with this and I think it will be simple to implement (just
> need to add 2 int variables).

Adding the variables is trivial, yes. The problem is dealing with errors,
like the user setting the variables to non-numbers, etc. I'm sure we don't
want to throw signals there, do we?

Eli, opinions?

> 2) Is it possible to call merge_faces more lazily? I mean inside the
> `if` `else if` so only one of them will be called when needed. AFAIK
> maybe_produce_line_number is called for every line and the code needs
> only one of those merges every 5/10/x lines.

You're right. Thanks. Improved patch attached.

[-- Attachment #1.2: Type: text/html, Size: 1097 bytes --]

[-- Attachment #2: 0001-New-faces-to-higlight-line-numbers-multiple-of-5-and.patch --]
[-- Type: application/octet-stream, Size: 4886 bytes --]

From a140f0b80312c0d9a38ba3e74c12a031eba49a91 Mon Sep 17 00:00:00 2001
From: Juanma Barranquero <lekktu@gmail.com>
Date: Wed, 2 Oct 2019 01:16:58 +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, 48 insertions(+), 2 deletions(-)

diff --git a/doc/emacs/display.texi b/doc/emacs/display.texi
index 84363d0f0d..1d4ac3eba5 100644
--- a/doc/emacs/display.texi
+++ b/doc/emacs/display.texi
@@ -1871,7 +1871,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 00a01999a7..3593b6df99 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 89a72ff751..d2e1112341 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -22566,8 +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
+      else if (lnum_to_display % 5 != 0)
 	tem_it.face_id = lnum_face_id;
+      else if (lnum_to_display %10 == 0)
+	tem_it.face_id = merge_faces (it->w, Qline_number_tenth_line,
+				      0, DEFAULT_FACE_ID);
+      else /* (lnum_to_display %5 == 0) */
+	tem_it.face_id = merge_faces (it->w, Qline_number_fifth_line,
+				      0, DEFAULT_FACE_ID);
       if (beyond_zv
 	  /* Don't display the same line number more than once.  */
 	  || (!EQ (Vdisplay_line_numbers, Qvisual)
@@ -34006,6 +34012,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


^ permalink raw reply related	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-01 23:51                               ` Juanma Barranquero
@ 2019-10-02  3:41                                 ` Ergus
  2019-10-02  9:40                                   ` Juanma Barranquero
  2019-10-02 15:06                                 ` Eli Zaretskii
  1 sibling, 1 reply; 129+ messages in thread
From: Ergus @ 2019-10-02  3:41 UTC (permalink / raw)
  To: Juanma Barranquero
  Cc: Lars Ingebrigtsen, Yuri D'Elia, Eli Zaretskii,
	Emacs developers

On Wed, Oct 02, 2019 at 01:51:17AM +0200, Juanma Barranquero wrote:
>On Wed, Oct 2, 2019 at 12:53 AM Ergus <spacibba@aol.com> wrote:
>
>> 1) I don't have any strong feeling about using one or two values. But in
>> any case they should be configurable. This will add more use cases that
>> could benefit with this and I think it will be simple to implement (just
>> need to add 2 int variables).
>
>Adding the variables is trivial, yes. The problem is dealing with errors,
>like the user setting the variables to non-numbers, etc. I'm sure we don't
>want to throw signals there, do we?
>
>Eli, opinions?
>
We deal with similar issues very often. For example in
display_fill_column_indicator_column it uses a general case where it can
be t or a positive number. You in the simpler case you can use also
DEFVAR_INT to bypass part of the needed tests. But in general you only
need to avoid divisions by zero, value = NILP,or any non numbers. if so,
the code does nothing.

You only need this:

if (RANGED_FIXNUMP (1, my_Lisp_Object, INT_MAX))
   int my_C_object = XFIXNUM (my_Lisp_Object);



>> 2) Is it possible to call merge_faces more lazily? I mean inside the
>> `if` `else if` so only one of them will be called when needed. AFAIK
>> maybe_produce_line_number is called for every line and the code needs
>> only one of those merges every 5/10/x lines.
>
>You're right. Thanks. Improved patch attached.





^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-02  3:41                                 ` Ergus
@ 2019-10-02  9:40                                   ` Juanma Barranquero
  2019-10-02 13:56                                     ` Ergus
  0 siblings, 1 reply; 129+ messages in thread
From: Juanma Barranquero @ 2019-10-02  9:40 UTC (permalink / raw)
  To: Ergus; +Cc: Yuri D'Elia, Lars Ingebrigtsen, Eli Zaretskii,
	Emacs developers

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

On Wed, Oct 2, 2019 at 5:42 AM Ergus <spacibba@aol.com> wrote:

> if so, the code does nothing.

That's what I'm asking. Not how to check for an integer, but what to do
when/if it's not. I don't have the foggiest idea what's usually done with
errors during redisplay.

[-- Attachment #2: Type: text/html, Size: 424 bytes --]

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-02  9:40                                   ` Juanma Barranquero
@ 2019-10-02 13:56                                     ` Ergus
  0 siblings, 0 replies; 129+ messages in thread
From: Ergus @ 2019-10-02 13:56 UTC (permalink / raw)
  To: Juanma Barranquero
  Cc: Yuri D'Elia, Lars Ingebrigtsen, Eli Zaretskii,
	Emacs developers

On Wed, Oct 02, 2019 at 11:40:12AM +0200, Juanma Barranquero wrote:
>On Wed, Oct 2, 2019 at 5:42 AM Ergus <spacibba@aol.com> wrote:
>
>> if so, the code does nothing.
>
>That's what I'm asking. Not how to check for an integer, but what to do
>when/if it's not. I don't have the foggiest idea what's usually done with
>errors during redisplay.

Usually the default is not to do anything if the values are invalid,
unset or null. So, if the user sets the values to something that cannot
be converted to a valid int within the valid range then the function
will return false and nothing needs to be done. The "if else" chain will
do nothing or will set the face to the default value (if not
already).

This has a nice side effect to disable your feature easily just setting
the values (or the faces) to nil, but also to for the values zero (which
is invalid) for example.

I think that what Eli tries to avoid is to parse a const pair array,
lisp lists or some other complex lisp data structures from withing the
display engine because it is very error prone, inefficient and hard to
maintain. So we only do that if it is really needed.

But he will confirm in any case.
Best,
Ergus



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-01 23:51                               ` Juanma Barranquero
  2019-10-02  3:41                                 ` Ergus
@ 2019-10-02 15:06                                 ` Eli Zaretskii
  2019-10-03  4:11                                   ` Juanma Barranquero
  1 sibling, 1 reply; 129+ messages in thread
From: Eli Zaretskii @ 2019-10-02 15:06 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: wavexx, spacibba, larsi, emacs-devel

> From: Juanma Barranquero <lekktu@gmail.com>
> Date: Wed, 2 Oct 2019 01:51:17 +0200
> Cc: Lars Ingebrigtsen <larsi@gnus.org>, "Yuri D'Elia" <wavexx@thregr.org>, Eli Zaretskii <eliz@gnu.org>, 
> 	Emacs developers <emacs-devel@gnu.org>
> 
> > 1) I don't have any strong feeling about using one or two values. But in
> > any case they should be configurable. This will add more use cases that
> > could benefit with this and I think it will be simple to implement (just
> > need to add 2 int variables).
> 
> Adding the variables is trivial, yes. The problem is dealing with errors, like the user setting the variables to
> non-numbers, etc. I'm sure we don't want to throw signals there, do we?
> 
> Eli, opinions?

You cannot usefully signal an error from redisplay.  So if the values
don't match expectations, use the hard-coded defaults instead.  If
this is documented ("Any other value is treated as ..."), we are fine.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-02 15:06                                 ` Eli Zaretskii
@ 2019-10-03  4:11                                   ` Juanma Barranquero
  2019-10-03  8:16                                     ` martin rudalics
                                                       ` (2 more replies)
  0 siblings, 3 replies; 129+ messages in thread
From: Juanma Barranquero @ 2019-10-03  4:11 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: wavexx, spacibba, Lars Magne Ingebrigtsen, Emacs developers


[-- 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


^ permalink raw reply related	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-03  4:11                                   ` Juanma Barranquero
@ 2019-10-03  8:16                                     ` martin rudalics
  2019-10-03 14:43                                       ` Juanma Barranquero
  2019-10-03  9:10                                     ` Robert Pluim
  2019-10-03 12:28                                     ` Yuri Khan
  2 siblings, 1 reply; 129+ messages in thread
From: martin rudalics @ 2019-10-03  8:16 UTC (permalink / raw)
  To: Juanma Barranquero, Eli Zaretskii
  Cc: wavexx, spacibba, Lars Magne Ingebrigtsen, Emacs developers

+@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

My English is too bad in order to judge whether this is correct.  But
I would prefer something like "... to highlight line numbers that are
multiples of ...".

martin



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-03  4:11                                   ` Juanma Barranquero
  2019-10-03  8:16                                     ` martin rudalics
@ 2019-10-03  9:10                                     ` Robert Pluim
  2019-10-03 14:47                                       ` Juanma Barranquero
  2019-10-03 12:28                                     ` Yuri Khan
  2 siblings, 1 reply; 129+ messages in thread
From: Robert Pluim @ 2019-10-03  9:10 UTC (permalink / raw)
  To: Juanma Barranquero
  Cc: wavexx, Lars Magne Ingebrigtsen, Eli Zaretskii, spacibba,
	Emacs developers

>>>>> On Thu, 3 Oct 2019 06:11:41 +0200, Juanma Barranquero <lekktu@gmail.com> said:
    Juanma> +showing point. Additional faces @code{line-number-Nth-line} and
    Juanma> +@code{line-number-Mth-line} can be used to highlight the line number
    Juanma> +of lines multiple of certain numbers which can be customized via the
    Juanma> +variables @code{display-line-numbers-Nth-line} and
    Juanma> +@code{display-line-numbers-Mth-line} respectively.

This sentence blew my stack. How about

    Additional faces @code{line-number-Nth-line} and
    @code{line-number-Mth-line} can be used to highlight the line numbers
    of lines which are a multiple of certain numbers.  Customize
    @code{display-line-numbers-Nth-line} and
    @code{display-line-numbers-Mth-line} respectively to set those
    numbers.

One other point: if N is a multiple of M, then lines numbers which are
multiples of both N and M get the 'N' face applied, which implies that
you should set N > M in that situation to avoid confusion. Would it
make sense to document that? (enforcing it via custom would be
overkill, I think).

Robert



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-03  4:11                                   ` Juanma Barranquero
  2019-10-03  8:16                                     ` martin rudalics
  2019-10-03  9:10                                     ` Robert Pluim
@ 2019-10-03 12:28                                     ` Yuri Khan
  2019-10-03 14:48                                       ` Juanma Barranquero
  2 siblings, 1 reply; 129+ messages in thread
From: Yuri Khan @ 2019-10-03 12:28 UTC (permalink / raw)
  To: Juanma Barranquero
  Cc: Yuri D'Elia, Lars Magne Ingebrigtsen, Eli Zaretskii, Ergus,
	Emacs developers

On Thu, 3 Oct 2019 at 11:12, Juanma Barranquero <lekktu@gmail.com> wrote:

> 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.

I believe in rulers and graphing these are called major ticks and
minor ticks, respectively.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-03  8:16                                     ` martin rudalics
@ 2019-10-03 14:43                                       ` Juanma Barranquero
  0 siblings, 0 replies; 129+ messages in thread
From: Juanma Barranquero @ 2019-10-03 14:43 UTC (permalink / raw)
  To: martin rudalics
  Cc: wavexx, Lars Magne Ingebrigtsen, Eli Zaretskii, spacibba,
	Emacs developers

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

On Thu, Oct 3, 2019 at 10:16 AM martin rudalics <rudalics@gmx.at> wrote:

> But
> I would prefer something like "... to highlight line numbers that are
> multiples of ...".

You're right. I've adopted Robert's wording, which is quite similar to
yours.

[-- Attachment #2: Type: text/html, Size: 404 bytes --]

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  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
  0 siblings, 2 replies; 129+ messages in thread
From: Juanma Barranquero @ 2019-10-03 14:47 UTC (permalink / raw)
  To: Robert Pluim
  Cc: wavexx, Lars Magne Ingebrigtsen, Eli Zaretskii, spacibba,
	Emacs developers


[-- Attachment #1.1: Type: text/plain, Size: 528 bytes --]

On Thu, Oct 3, 2019 at 11:10 AM Robert Pluim <rpluim@gmail.com> wrote:

> This sentence blew my stack.

Please excuse me for weaponizing and deplopying bad english upon you. I
can't really promise it won't happen again... ;-)

> How about

Yes, thanks. Fixed patch attached.

> Would it  make sense to document that?

I don't think so. It's kind of harmless, and the docstring for
display-line-numbers-Nth-line already says that it takes precedence.

But if you feel strongly about it, please suggest a wording and I'll add it.

[-- Attachment #1.2: Type: text/html, Size: 804 bytes --]

[-- Attachment #2: 0001-Allow-highlighting-line-numbers-that-are-multiple-of.patch --]
[-- Type: application/octet-stream, Size: 8124 bytes --]

From 862093b510ee1446c5a7ea8470bfaf4e3eade879 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.  Wording by
Robert Pluim <rpluim@gmail.com>
---
 doc/emacs/display.texi |  7 ++++++-
 etc/NEWS               | 10 ++++++++++
 lisp/cus-start.el      | 12 ++++++++++++
 lisp/faces.el          | 32 ++++++++++++++++++++++++++++++++
 src/xdisp.c            | 27 +++++++++++++++++++++++++++
 5 files changed, 87 insertions(+), 1 deletion(-)

diff --git a/doc/emacs/display.texi b/doc/emacs/display.texi
index 84363d0f0d..34ee8da6b7 100644
--- a/doc/emacs/display.texi
+++ b/doc/emacs/display.texi
@@ -1871,7 +1871,12 @@ 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 numbers
+of lines which are a multiple of certain numbers.  Customize
+@code{display-line-numbers-Nth-line} and
+@code{display-line-numbers-Mth-line} respectively to set those
+numbers.
 
 @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


^ permalink raw reply related	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-03 12:28                                     ` Yuri Khan
@ 2019-10-03 14:48                                       ` Juanma Barranquero
  2019-10-03 17:56                                         ` Yuri D'Elia
  0 siblings, 1 reply; 129+ messages in thread
From: Juanma Barranquero @ 2019-10-03 14:48 UTC (permalink / raw)
  To: Yuri Khan
  Cc: Yuri D'Elia, Lars Magne Ingebrigtsen, Eli Zaretskii, Ergus,
	Emacs developers

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

On Thu, Oct 3, 2019 at 2:28 PM Yuri Khan <yuri.v.khan@gmail.com> wrote:

> I believe in rulers and graphing these are called major ticks and
> minor ticks, respectively.

I kinda like it a lot. But it is perhaps a bit obscure?

[-- Attachment #2: Type: text/html, Size: 356 bytes --]

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-03 14:47                                       ` Juanma Barranquero
@ 2019-10-03 15:18                                         ` Robert Pluim
  2019-10-03 20:37                                         ` Stefan Kangas
  1 sibling, 0 replies; 129+ messages in thread
From: Robert Pluim @ 2019-10-03 15:18 UTC (permalink / raw)
  To: Juanma Barranquero
  Cc: wavexx, Lars Magne Ingebrigtsen, Eli Zaretskii, spacibba,
	Emacs developers

>>>>> On Thu, 3 Oct 2019 16:47:38 +0200, Juanma Barranquero <lekktu@gmail.com> said:

    >> Would it  make sense to document that?

    Juanma> I don't think so. It's kind of harmless, and the docstring for
    Juanma> display-line-numbers-Nth-line already says that it takes precedence.

Iʼd missed that. Looks good to me.

Robert



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-03 14:48                                       ` Juanma Barranquero
@ 2019-10-03 17:56                                         ` Yuri D'Elia
  2019-10-03 18:40                                           ` Eli Zaretskii
  0 siblings, 1 reply; 129+ messages in thread
From: Yuri D'Elia @ 2019-10-03 17:56 UTC (permalink / raw)
  To: Juanma Barranquero
  Cc: Lars Magne Ingebrigtsen, Eli Zaretskii, Emacs developers, Ergus,
	Yuri Khan

On Thu, Oct 03 2019, Juanma Barranquero wrote:
> On Thu, Oct 3, 2019 at 2:28 PM Yuri Khan <yuri.v.khan@gmail.com> wrote:
>
>> I believe in rulers and graphing these are called major ticks and
>> minor ticks, respectively.

It's a brilliant idea IMHO

> I kinda like it a lot. But it is perhaps a bit obscure?

I plot a lot, so I might be biased, but cannot be worse than N/M :)



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  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
  0 siblings, 2 replies; 129+ messages in thread
From: Eli Zaretskii @ 2019-10-03 18:40 UTC (permalink / raw)
  To: Yuri D'Elia; +Cc: lekktu, spacibba, emacs-devel, larsi, yuri.v.khan

> From: Yuri D'Elia <wavexx@thregr.org>
> Cc: Yuri Khan <yuri.v.khan@gmail.com>, Eli Zaretskii <eliz@gnu.org>, Ergus
>  <spacibba@aol.com>, Lars Magne Ingebrigtsen <larsi@gnus.org>, Emacs
>  developers <emacs-devel@gnu.org>
> Date: Thu, 03 Oct 2019 19:56:46 +0200
> 
> >> I believe in rulers and graphing these are called major ticks and
> >> minor ticks, respectively.
> 
> It's a brilliant idea IMHO

FWIW, I actually considered it when Juanma asked for better names, but
eventually decided that such names will be too obscure, except for few
initiated people.  I think -M and -N is much easier to understand and
remember.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-03 18:40                                           ` Eli Zaretskii
@ 2019-10-03 19:01                                             ` Yuri D'Elia
  2019-10-04  2:01                                             ` Juanma Barranquero
  1 sibling, 0 replies; 129+ messages in thread
From: Yuri D'Elia @ 2019-10-03 19:01 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: lekktu, spacibba, emacs-devel, larsi, yuri.v.khan

On Thu, Oct 03 2019, Eli Zaretskii wrote:
> FWIW, I actually considered it when Juanma asked for better names, but
> eventually decided that such names will be too obscure, except for few
> initiated people.  I think -M and -N is much easier to understand and
> remember.

I happen to have a fetish on short vars too, so I'm fine with either ;)



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  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
  1 sibling, 1 reply; 129+ messages in thread
From: Stefan Kangas @ 2019-10-03 20:37 UTC (permalink / raw)
  To: Juanma Barranquero
  Cc: Ergus, Robert Pluim, Emacs developers, wavexx, Eli Zaretskii,
	Lars Magne Ingebrigtsen

Juanma Barranquero <lekktu@gmail.com> writes:

> Fixed patch attached.

I didn't follow the thread closely, but I think this looks like a nice addition.

Just wanted to point out that Bug#27734 should probably be closed once
this is merged.

Best regards,
Stefan Kangas



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-03 20:37                                         ` Stefan Kangas
@ 2019-10-03 21:48                                           ` Juanma Barranquero
  2019-10-03 22:37                                             ` Yuri D'Elia
  0 siblings, 1 reply; 129+ messages in thread
From: Juanma Barranquero @ 2019-10-03 21:48 UTC (permalink / raw)
  To: Stefan Kangas
  Cc: Ergus, Robert Pluim, Emacs developers, wavexx, Eli Zaretskii,
	Lars Magne Ingebrigtsen

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

> Just wanted to point out that Bug#27734 should probably be closed once
> this is merged.

Right. I'll note so in the commit message.

Anything else lacking before committing?

[-- Attachment #2: Type: text/html, Size: 272 bytes --]

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-03 21:48                                           ` Juanma Barranquero
@ 2019-10-03 22:37                                             ` Yuri D'Elia
  2019-10-04  1:51                                               ` Juanma Barranquero
  0 siblings, 1 reply; 129+ messages in thread
From: Yuri D'Elia @ 2019-10-03 22:37 UTC (permalink / raw)
  To: Juanma Barranquero
  Cc: Ergus, Robert Pluim, Stefan Kangas, Emacs developers,
	Lars Magne Ingebrigtsen, Eli Zaretskii

On Thu, Oct 03 2019, Juanma Barranquero wrote:
>> Just wanted to point out that Bug#27734 should probably be closed once
>> this is merged.
>
> Right. I'll note so in the commit message.
>
> Anything else lacking before committing?

I'll throw this in, since I've mentioned it.
Can we add a line number offset?

display-line-number-offset

As a signed integer which gets added the current number, defaulting to
0.

My workflow involving the offset is to ignore the offset introduced by
headers frequently present in data files. Very, very, very useful,
especially when combined with a simple advice to goto-line to make the
two consistent. The number you see is the data row you get™.

I can mention that such an offset would also obsolete the linun-relative
(and some other) extension which could be fully reimplemented using N/M
+ offset.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-03 22:37                                             ` Yuri D'Elia
@ 2019-10-04  1:51                                               ` Juanma Barranquero
  2019-10-04  7:45                                                 ` Eli Zaretskii
  0 siblings, 1 reply; 129+ messages in thread
From: Juanma Barranquero @ 2019-10-04  1:51 UTC (permalink / raw)
  To: Yuri D'Elia
  Cc: Ergus, Robert Pluim, Stefan Kangas, Emacs developers,
	Lars Magne Ingebrigtsen, Eli Zaretskii

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

On Fri, Oct 4, 2019 at 12:37 AM Yuri D'Elia <wavexx@thregr.org> wrote:

> I'll throw this in, since I've mentioned it.
> Can we add a line number offset?
>
> display-line-number-offset
>
> As a signed integer which gets added the current number, defaulting to
> 0.

That's a different feature.

I don't understand the semantics.

- If you set it to a negative number (as you'll do, to compensate for the
headers), what number will had previous lines: negative (which is currently
unsupported), or positive going backwards?
- What do you want to do when in relative/visual modes?
- What about narrowing?

[-- Attachment #2: Type: text/html, Size: 869 bytes --]

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  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
  1 sibling, 1 reply; 129+ messages in thread
From: Juanma Barranquero @ 2019-10-04  2:01 UTC (permalink / raw)
  To: Eli Zaretskii
  Cc: Yuri D'Elia, spacibba, Emacs developers,
	Lars Magne Ingebrigtsen, yuri.v.khan

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

On Thu, Oct 3, 2019 at 8:40 PM Eli Zaretskii <eliz@gnu.org> wrote:

> FWIW, I actually considered it when Juanma asked for better names, but
> eventually decided that such names will be too obscure, except for few
> initiated people.  I think -M and -N is much easier to understand and
> remember.

The more I think about it, the more I like "major tick" and "minor tick".
They are a bit obscure, yeah. OTOH, they reflect exactly what the feature
is intended to do (at least,what I intended it to do), and "major" vs
"minor", and its association with rulers, clearly states that major ticks
have precedence over minor ones.

[-- Attachment #2: Type: text/html, Size: 823 bytes --]

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-04  2:01                                             ` Juanma Barranquero
@ 2019-10-04  5:01                                               ` Juanma Barranquero
  2019-10-04 15:57                                                 ` Johan Bockgård
  0 siblings, 1 reply; 129+ messages in thread
From: Juanma Barranquero @ 2019-10-04  5:01 UTC (permalink / raw)
  To: Eli Zaretskii
  Cc: Yuri D'Elia, spacibba, Emacs developers,
	Lars Magne Ingebrigtsen, yuri.v.khan


[-- Attachment #1.1: Type: text/plain, Size: 154 bytes --]

Two versions of the same patch.

0001-Nth-Mth.patch is the previous one, with a few typos fixed.
0001-Major-Minor.patch uses "Major tick" / "Minor tick".

[-- Attachment #1.2: Type: text/html, Size: 248 bytes --]

[-- Attachment #2: 0001-Major-minor.patch --]
[-- Type: application/octet-stream, Size: 8241 bytes --]

From 4b8c1cf92e9ec5e28838f944cad3ac77eb076e8c Mon Sep 17 00:00:00 2001
From: Juanma Barranquero <lekktu@gmail.com>
Date: Fri, 4 Oct 2019 06:44:10 +0200
Subject: [PATCH] Allow highlighting line numbers that are multiple of given
 values

* lisp/faces.el (line-number-major-tick, line-number-minor-tick):
New faces.
* lisp/cus-start.el (display-line-numbers-major-tick)
(display-line-numbers-minor-tick): Add customization info.

* src/xdisp.c (syms_of_xdisp) <display-line-numbers-major-tick>
<display-line-numbers-major-tick>: Defvar new options.
(syms_of_xdisp) <line-number-major-tick, line-number-minor-tick>:
Defsym new faces.
(maybe_produce_line_number): Use new faces for line numbers
that are multiple of `display-line-numbers-major-tick' and
`display-line-numbers-minor-tick'.

* etc/NEWS (value): Announce new feature.
* doc/emacs/display.texi (Display Custom): Describe it.  Wording by
Robert Pluim <rpluim@gmail.com>
---
 doc/emacs/display.texi |  7 ++++++-
 etc/NEWS               |  7 +++++++
 lisp/cus-start.el      | 12 ++++++++++++
 lisp/faces.el          | 34 ++++++++++++++++++++++++++++++++++
 src/xdisp.c            | 28 ++++++++++++++++++++++++++++
 5 files changed, 87 insertions(+), 1 deletion(-)

diff --git a/doc/emacs/display.texi b/doc/emacs/display.texi
index 84363d0f0d..406feb8c12 100644
--- a/doc/emacs/display.texi
+++ b/doc/emacs/display.texi
@@ -1871,7 +1871,12 @@ 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-major-tick} and
+@code{line-number-minor-tick} can be used to highlight the line numbers
+of lines which are a multiple of certain numbers.  Customize
+@code{display-line-numbers-major-tick} and
+@code{display-line-numbers-minor-tick} respectively to set those
+numbers.
 
 @vindex visible-bell
   If the variable @code{visible-bell} is non-@code{nil}, Emacs attempts
diff --git a/etc/NEWS b/etc/NEWS
index c8cc7537b0..d6d1da0638 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -553,6 +553,13 @@ 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-major-tick' and 'line-number-minor-tick',
+and customizable variables 'display-line-numbers-major-tick' and
+'display-line-numbers-minor-tick' can be used to highlight the line
+numbers of lines multiple of certain numbers.
+
 +++
 ** 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..2e37f095bb 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-major-tick
+              display-line-numbers
+              (choice
+               (const :tag "No line" 0)
+               (integer :tag "Multiples of" 10))
+              "27.1")
+             (display-line-numbers-minor-tick
+              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..58b6349ccf 100644
--- a/lisp/faces.el
+++ b/lisp/faces.el
@@ -2390,6 +2390,40 @@ line-number-current-line
   :group 'basic-faces
   :group 'display-line-numbers)
 
+(defface line-number-major-tick
+  '((t :inherit line-number))
+  "Face for highlighting \"major ticks\" (as in a ruler).
+When `display-line-numbers-major-tick' is positive, highlight
+the line numbers of lines which are a multiple of its value.
+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-minor-tick
+  '((t :inherit line-number))
+  "Face for highlighting \"minor ticks\" (as in a ruler).
+When `display-line-numbers-minor-tick' is positive, highlight
+the line numbers of lines which are a multiple of its value.
+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 89a72ff751..ca9bd0a19f 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_major_tick, INT_MAX)
+	       && (lnum_to_display % XFIXNUM (Vdisplay_line_numbers_major_tick) == 0))
+	tem_it.face_id = merge_faces (it->w, Qline_number_major_tick,
+				      0, DEFAULT_FACE_ID);
+      else if (RANGED_FIXNUMP (1, Vdisplay_line_numbers_minor_tick, INT_MAX)
+	       && (lnum_to_display % XFIXNUM (Vdisplay_line_numbers_minor_tick) == 0))
+	tem_it.face_id = merge_faces (it->w, Qline_number_minor_tick,
+				      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_major_tick, "line-number-major-tick");
+  DEFSYM (Qline_number_minor_tick, "line-number-minor-tick");
   /* Name of a text property which disables line-number display.  */
   DEFSYM (Qdisplay_line_numbers_disable, "display-line-numbers-disable");
 
@@ -34641,6 +34651,24 @@ 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-major-tick", Vdisplay_line_numbers_major_tick,
+    doc: /* If an integer N > 0, highlight line number of every Nth line.
+The line number is shown with the `line-number-major-tick' face.
+Otherwise, no special highlighting is done every Nth line.
+Note that major ticks take precedence over minor ticks.  */);
+  Vdisplay_line_numbers_major_tick = make_fixnum (0);
+  DEFSYM (Qdisplay_line_numbers_major_tick, "display-line-numbers-major-tick");
+  Fmake_variable_buffer_local (Qdisplay_line_numbers_major_tick);
+
+  DEFVAR_LISP ("display-line-numbers-minor-tick", Vdisplay_line_numbers_minor_tick,
+    doc: /* If an integer N > 0, highlight line number of every Nth line.
+The line number is shown with the `line-number-minor-tick' face.
+Otherwise, no special highlighting is done every Mth line.
+Note that major ticks take precedence over minor ticks.  */
+  Vdisplay_line_numbers_minor_tick = make_fixnum (0);
+  DEFSYM (Qdisplay_line_numbers_minor_tick, "display-line-numbers-minor-tick");
+  Fmake_variable_buffer_local (Qdisplay_line_numbers_minor_tick);
+
   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


[-- Attachment #3: 0001-Nth-Mth.patch --]
[-- Type: application/octet-stream, Size: 7976 bytes --]

From 7c1c51b2798ffaabedaecce891f2be1d0eb871f5 Mon Sep 17 00:00:00 2001
From: Juanma Barranquero <lekktu@gmail.com>
Date: Fri, 4 Oct 2019 06:21:20 +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.  Wording by
Robert Pluim <rpluim@gmail.com>
---
 doc/emacs/display.texi |  7 ++++++-
 etc/NEWS               |  7 +++++++
 lisp/cus-start.el      | 12 ++++++++++++
 lisp/faces.el          | 32 ++++++++++++++++++++++++++++++++
 src/xdisp.c            | 27 +++++++++++++++++++++++++++
 5 files changed, 84 insertions(+), 1 deletion(-)

diff --git a/doc/emacs/display.texi b/doc/emacs/display.texi
index 84363d0f0d..34ee8da6b7 100644
--- a/doc/emacs/display.texi
+++ b/doc/emacs/display.texi
@@ -1871,7 +1871,12 @@ 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 numbers
+of lines which are a multiple of certain numbers.  Customize
+@code{display-line-numbers-Nth-line} and
+@code{display-line-numbers-Mth-line} respectively to set those
+numbers.
 
 @vindex visible-bell
   If the variable @code{visible-bell} is non-@code{nil}, Emacs attempts
diff --git a/etc/NEWS b/etc/NEWS
index c8cc7537b0..ebd0256386 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -553,6 +553,13 @@ 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.
+
 +++
 ** 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..f2a0f4b0ab 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 line.  */);
+  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 line.
+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


^ permalink raw reply related	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  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:22                                                   ` Ergus
  0 siblings, 2 replies; 129+ messages in thread
From: Eli Zaretskii @ 2019-10-04  7:45 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: spacibba, rpluim, stefan, emacs-devel, wavexx, larsi

> From: Juanma Barranquero <lekktu@gmail.com>
> Date: Fri, 4 Oct 2019 03:51:29 +0200
> Cc: Stefan Kangas <stefan@marxist.se>, Robert Pluim <rpluim@gmail.com>, 
> 	Lars Magne Ingebrigtsen <larsi@gnus.org>, Eli Zaretskii <eliz@gnu.org>, Ergus <spacibba@aol.com>, 
> 	Emacs developers <emacs-devel@gnu.org>
> 
> > Can we add a line number offset?
> >
> > display-line-number-offset
> >
> > As a signed integer which gets added the current number, defaulting to
> > 0.
> 
> That's a different feature.

Indeed.

> I don't understand the semantics.

I can suggest easy solutions:

> - If you set it to a negative number (as you'll do, to compensate for the headers), what number will had
> previous lines: negative (which is currently unsupported), or positive going backwards?

The latter.  Or maybe no number at all.

> - What do you want to do when in relative/visual modes?

Nothing: these modes are incompatible with the offset mode.

> - What about narrowing?

We could say that using the offset implies display-line-numbers-widen.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  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-04 10:22                                                   ` Ergus
  1 sibling, 2 replies; 129+ messages in thread
From: Yuri D'Elia @ 2019-10-04  9:52 UTC (permalink / raw)
  To: Eli Zaretskii
  Cc: spacibba, Juanma Barranquero, rpluim, stefan, emacs-devel, larsi

On Fri, Oct 04 2019, Eli Zaretskii wrote:
>> That's a different feature.
>
> Indeed.

Fine with this.

>> - If you set it to a negative number (as you'll do, to compensate for the headers), what number will had
>> previous lines: negative (which is currently unsupported), or positive going backwards?
>
> The latter.  Or maybe no number at all.

I'm used to a negative sign, but it's logically redundant so omitting a
minus and going with a positive counting backwards would be perfectly
fine.

>> - What do you want to do when in relative/visual modes?
>
> Nothing: these modes are incompatible with the offset mode.

Agreed.

>> - What about narrowing?
>
> We could say that using the offset implies display-line-numbers-widen.

I never thought or happen to be in this scenario so far.
Implying d-l-n-widen makes sense as a starting point.

I could play around and see.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-04  7:45                                                 ` Eli Zaretskii
  2019-10-04  9:52                                                   ` Yuri D'Elia
@ 2019-10-04 10:22                                                   ` Ergus
  2019-10-04 10:26                                                     ` Juanma Barranquero
  1 sibling, 1 reply; 129+ messages in thread
From: Ergus @ 2019-10-04 10:22 UTC (permalink / raw)
  To: Eli Zaretskii
  Cc: Juanma Barranquero, rpluim, stefan, emacs-devel, wavexx, larsi

On Fri, Oct 04, 2019 at 10:45:30AM +0300, Eli Zaretskii wrote:
>> From: Juanma Barranquero <lekktu@gmail.com>
>> Date: Fri, 4 Oct 2019 03:51:29 +0200
>> Cc: Stefan Kangas <stefan@marxist.se>, Robert Pluim <rpluim@gmail.com>,
>> 	Lars Magne Ingebrigtsen <larsi@gnus.org>, Eli Zaretskii <eliz@gnu.org>, Ergus <spacibba@aol.com>,
>> 	Emacs developers <emacs-devel@gnu.org>
>>
>> > Can we add a line number offset?
>> >
>> > display-line-number-offset
>> >
>> > As a signed integer which gets added the current number, defaulting to
>> > 0.
>>
>> That's a different feature.
>
>Indeed.
>
As a different feature this should be in a different
branch||patch||commit please.

>> I don't understand the semantics.
>
>I can suggest easy solutions:
>
>> - If you set it to a negative number (as you'll do, to compensate for the headers), what number will had
>> previous lines: negative (which is currently unsupported), or positive going backwards?
>
>The latter.  Or maybe no number at all.
>
>> - What do you want to do when in relative/visual modes?
>
>Nothing: these modes are incompatible with the offset mode.
>
We should document that for the absolute numeration
(display-line-numbers t) in the manual and when defining DEFVAR_LISP
"display-line-numbers" right?


About the names I like the major/minor approach more than M/N. 



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-04  9:52                                                   ` Yuri D'Elia
@ 2019-10-04 10:24                                                     ` Juanma Barranquero
  2019-10-05  6:26                                                     ` Juanma Barranquero
  1 sibling, 0 replies; 129+ messages in thread
From: Juanma Barranquero @ 2019-10-04 10:24 UTC (permalink / raw)
  To: Yuri D'Elia
  Cc: spacibba, rpluim, stefan, Emacs developers,
	Lars Magne Ingebrigtsen, Eli Zaretskii

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

On Fri, Oct 4, 2019 at 11:52 AM Yuri D'Elia <wavexx@thregr.org> wrote:

> > The latter.  Or maybe no number at all.
>
> I'm used to a negative sign, but it's logically redundant so omitting a
> minus and going with a positive counting backwards would be perfectly
> fine.

Negative would be more of a change.

As for going for a positive backwards (passing throught 0), it's easy to
implement.

>> Nothing: these modes are incompatible with the offset mode.
> Agreed.

Ok.

>> We could say that using the offset implies display-line-numbers-widen.
>
> I never thought or happen to be in this scenario so far.
> Implying d-l-n-widen makes sense as a starting point.
>
> I could play around and see.

Ok.

I have a bit of an implementation. Give me a few hours. Also, I just broke
bootstrapping :-(

[-- Attachment #2: Type: text/html, Size: 1287 bytes --]

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-04 10:22                                                   ` Ergus
@ 2019-10-04 10:26                                                     ` Juanma Barranquero
  0 siblings, 0 replies; 129+ messages in thread
From: Juanma Barranquero @ 2019-10-04 10:26 UTC (permalink / raw)
  To: Ergus
  Cc: rpluim, stefan, Emacs developers, wavexx, Lars Magne Ingebrigtsen,
	Eli Zaretskii

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

On Fri, Oct 4, 2019 at 12:22 PM Ergus <spacibba@aol.com> wrote:

> As a different feature this should be in a different
> branch||patch||commit please.

Of course.

> >Nothing: these modes are incompatible with the offset mode.
> >
> We should document that for the absolute numeration
> (display-line-numbers t) in the manual and when defining DEFVAR_LISP
> "display-line-numbers" right?

When/if we implement it and write some doc.

> About the names I like the major/minor approach more than M/N.

Thanks.

[-- Attachment #2: Type: text/html, Size: 768 bytes --]

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-04  5:01                                               ` Juanma Barranquero
@ 2019-10-04 15:57                                                 ` Johan Bockgård
  2019-10-04 17:28                                                   ` Juanma Barranquero
  0 siblings, 1 reply; 129+ messages in thread
From: Johan Bockgård @ 2019-10-04 15:57 UTC (permalink / raw)
  To: Juanma Barranquero
  Cc: spacibba, yuri.v.khan, Yuri D'Elia, Lars Magne Ingebrigtsen,
	Emacs developers, Eli Zaretskii

Juanma Barranquero <lekktu@gmail.com> writes:

> +  DEFVAR_LISP ("display-line-numbers-major-tick", Vdisplay_line_numbers_major_tick,
> +    doc: /* If an integer N > 0, highlight line number of every Nth line.
> +The line number is shown with the `line-number-major-tick' face.
> +Otherwise, no special highlighting is done every Nth line.
> +Note that major ticks take precedence over minor ticks.  */);
> +  Vdisplay_line_numbers_major_tick = make_fixnum (0);

Why not use DEFVAR_INT?

> +  DEFSYM (Qdisplay_line_numbers_major_tick, "display-line-numbers-major-tick");
> +  Fmake_variable_buffer_local (Qdisplay_line_numbers_major_tick);

I realize that many existing variables in xdisp.c don't follow this
recommendation, but the manual says the following:

     *Warning:* Don’t assume that you should use
     ‘make-variable-buffer-local’ for user-option variables, simply
     because users _might_ want to customize them differently in
     different buffers.  Users can make any variable local, when they
     wish to.  It is better to leave the choice to them.

     The time to use ‘make-variable-buffer-local’ is when it is crucial
     that no two buffers ever share the same binding.  For example, when
     a variable is used for internal purposes in a Lisp program which
     depends on having separate values in separate buffers, then using
     ‘make-variable-buffer-local’ can be the best solution.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-04 15:57                                                 ` Johan Bockgård
@ 2019-10-04 17:28                                                   ` Juanma Barranquero
  2019-10-04 19:24                                                     ` Stefan Monnier
  0 siblings, 1 reply; 129+ messages in thread
From: Juanma Barranquero @ 2019-10-04 17:28 UTC (permalink / raw)
  To: Johan Bockgård
  Cc: spacibba, yuri.v.khan, Yuri D'Elia, Lars Magne Ingebrigtsen,
	Emacs developers, Eli Zaretskii

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

On Fri, Oct 4, 2019 at 5:58 PM Johan Bockgård <bojohan@gnu.org> wrote:
>
> Juanma Barranquero <lekktu@gmail.com> writes:

> Why not use DEFVAR_INT?

My feeling is that DEFVAR_INT is appropriate for variables that must always
have a number, like display-line-numbers-offset in the next patch. Even its
"off" value is just having an offset of 0.

On the other hand, ticks can be turned on and off, and though strictly
speaking 0 can serve as off, it seems cleaner to allow the user to set them
to nil to turn them off.

That said, I don't feel strongly about it. I'll got with the consensus.

> I realize that many existing variables in xdisp.c don't follow this
> recommendation, but the manual says the following:
>
>      *Warning:* Don’t assume that you should use
>      ‘make-variable-buffer-local’ for user-option variables, simply
>      because users _might_ want to customize them differently in
>      different buffers.  Users can make any variable local, when they
>      wish to.  It is better to leave the choice to them.

I know the recommendation, but the reason many variables don't follow it is
that it is less convenient. In cases like this one, I think it's quite
likely that the tick values will depend on the mode or the kind of data, or
even its length (Yuri said that he uses large values to quickly scan log
files, for example). When seems likely that every buffer will have its own
value, I strongly believe it's cleaner to have the variable automatically
buffer-local.

[-- Attachment #2: Type: text/html, Size: 1875 bytes --]

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-04 17:28                                                   ` Juanma Barranquero
@ 2019-10-04 19:24                                                     ` Stefan Monnier
  2019-10-04 20:12                                                       ` Yuri D'Elia
  0 siblings, 1 reply; 129+ messages in thread
From: Stefan Monnier @ 2019-10-04 19:24 UTC (permalink / raw)
  To: Juanma Barranquero
  Cc: spacibba, Johan Bockgård, Emacs developers, Yuri D'Elia,
	Lars Magne Ingebrigtsen, yuri.v.khan, Eli Zaretskii

> I know the recommendation, but the reason many variables don't follow it is
> that it is less convenient. In cases like this one, I think it's quite
> likely that the tick values will depend on the mode or the kind of data, or
> even its length

Really?  On the contrary, I'd assume most users will want to set it once
and for all with a (setq display-line-numbers-major-tick 16)
and then will be stumped why that setting doesn't seem to work (hint:
it only applies to the *scratch* buffer).

Maybe there will be a few special buffers/modes where they will set it
to a different value, but these will likely be exceptions.


        Stefan




^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-04 19:24                                                     ` Stefan Monnier
@ 2019-10-04 20:12                                                       ` Yuri D'Elia
  2019-10-04 22:45                                                         ` Juanma Barranquero
  0 siblings, 1 reply; 129+ messages in thread
From: Yuri D'Elia @ 2019-10-04 20:12 UTC (permalink / raw)
  To: Stefan Monnier
  Cc: spacibba, Juanma Barranquero, Johan Bockgård,
	Emacs developers, Lars Magne Ingebrigtsen, yuri.v.khan,
	Eli Zaretskii

On Fri, Oct 04 2019, Stefan Monnier wrote:
> Maybe there will be a few special buffers/modes where they will set it
> to a different value, but these will likely be exceptions.

I would agree here. Buffer-local exceptions won't be the norm.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-04 20:12                                                       ` Yuri D'Elia
@ 2019-10-04 22:45                                                         ` Juanma Barranquero
  2019-10-06 14:04                                                           ` Juanma Barranquero
  0 siblings, 1 reply; 129+ messages in thread
From: Juanma Barranquero @ 2019-10-04 22:45 UTC (permalink / raw)
  To: Yuri D'Elia
  Cc: spacibba, Johan Bockgård, Emacs developers, Stefan Monnier,
	Lars Magne Ingebrigtsen, yuri.v.khan, Eli Zaretskii


[-- Attachment #1.1: Type: text/plain, Size: 120 bytes --]

Ok, no big deal, if that's the consensus.

Attached version (major/minor) with no automatically buffer-local variables.

[-- Attachment #1.2: Type: text/html, Size: 184 bytes --]

[-- Attachment #2: 0001-Allow-highlighting-line-numbers-that-are-multiple-of.patch --]
[-- Type: application/octet-stream, Size: 8107 bytes --]

From b714c229e2d24f13e5a2888cbd5c1d8765b8bb16 Mon Sep 17 00:00:00 2001
From: Juanma Barranquero <lekktu@gmail.com>
Date: Sat, 5 Oct 2019 00:36:49 +0200
Subject: [PATCH] Allow highlighting line numbers that are multiple of given
 values

* lisp/faces.el (line-number-major-tick, line-number-minor-tick):
New faces.
* lisp/cus-start.el (display-line-numbers-major-tick)
(display-line-numbers-minor-tick): Add customization info.

* src/xdisp.c (syms_of_xdisp) <display-line-numbers-major-tick>
<display-line-numbers-major-tick>: Defvar new options.
(syms_of_xdisp) <line-number-major-tick, line-number-minor-tick>:
Defsym new faces.
(maybe_produce_line_number): Use new faces for line numbers
that are multiple of `display-line-numbers-major-tick' and
`display-line-numbers-minor-tick'.

* etc/NEWS (value): Announce new feature.
* doc/emacs/display.texi (Display Custom): Describe it.  Wording by
Robert Pluim <rpluim@gmail.com>
---
 doc/emacs/display.texi |  7 ++++++-
 etc/NEWS               |  7 +++++++
 lisp/cus-start.el      | 12 ++++++++++++
 lisp/faces.el          | 34 ++++++++++++++++++++++++++++++++++
 src/xdisp.c            | 26 ++++++++++++++++++++++++++
 5 files changed, 85 insertions(+), 1 deletion(-)

diff --git a/doc/emacs/display.texi b/doc/emacs/display.texi
index 84363d0f0d..406feb8c12 100644
--- a/doc/emacs/display.texi
+++ b/doc/emacs/display.texi
@@ -1871,7 +1871,12 @@ 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-major-tick} and
+@code{line-number-minor-tick} can be used to highlight the line numbers
+of lines which are a multiple of certain numbers.  Customize
+@code{display-line-numbers-major-tick} and
+@code{display-line-numbers-minor-tick} respectively to set those
+numbers.
 
 @vindex visible-bell
   If the variable @code{visible-bell} is non-@code{nil}, Emacs attempts
diff --git a/etc/NEWS b/etc/NEWS
index db90e8e5c5..617482b262 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -558,6 +558,13 @@ 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-major-tick' and 'line-number-minor-tick',
+and customizable variables 'display-line-numbers-major-tick' and
+'display-line-numbers-minor-tick' can be used to highlight the line
+numbers of lines multiple of certain numbers.
+
 +++
 ** 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..2e37f095bb 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-major-tick
+              display-line-numbers
+              (choice
+               (const :tag "No line" 0)
+               (integer :tag "Multiples of" 10))
+              "27.1")
+             (display-line-numbers-minor-tick
+              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..58b6349ccf 100644
--- a/lisp/faces.el
+++ b/lisp/faces.el
@@ -2390,6 +2390,40 @@ line-number-current-line
   :group 'basic-faces
   :group 'display-line-numbers)
 
+(defface line-number-major-tick
+  '((t :inherit line-number))
+  "Face for highlighting \"major ticks\" (as in a ruler).
+When `display-line-numbers-major-tick' is positive, highlight
+the line numbers of lines which are a multiple of its value.
+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-minor-tick
+  '((t :inherit line-number))
+  "Face for highlighting \"minor ticks\" (as in a ruler).
+When `display-line-numbers-minor-tick' is positive, highlight
+the line numbers of lines which are a multiple of its value.
+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 9d1fdecaff..423615c054 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -22567,6 +22567,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_major_tick, INT_MAX)
+	       && (lnum_to_display % XFIXNUM (Vdisplay_line_numbers_major_tick) == 0))
+	tem_it.face_id = merge_faces (it->w, Qline_number_major_tick,
+				      0, DEFAULT_FACE_ID);
+      else if (RANGED_FIXNUMP (1, Vdisplay_line_numbers_minor_tick, INT_MAX)
+	       && (lnum_to_display % XFIXNUM (Vdisplay_line_numbers_minor_tick) == 0))
+	tem_it.face_id = merge_faces (it->w, Qline_number_minor_tick,
+				      0, DEFAULT_FACE_ID);
       else
 	tem_it.face_id = lnum_face_id;
       if (beyond_zv
@@ -34007,6 +34015,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_major_tick, "line-number-major-tick");
+  DEFSYM (Qline_number_minor_tick, "line-number-minor-tick");
   /* Name of a text property which disables line-number display.  */
   DEFSYM (Qdisplay_line_numbers_disable, "display-line-numbers-disable");
 
@@ -34642,6 +34652,22 @@ 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-major-tick", Vdisplay_line_numbers_major_tick,
+    doc: /* If an integer N > 0, highlight line number of every Nth line.
+The line number is shown with the `line-number-major-tick' face.
+Otherwise, no special highlighting is done every Nth line.
+Note that major ticks take precedence over minor ticks.  */);
+  Vdisplay_line_numbers_major_tick = make_fixnum (0);
+  DEFSYM (Qdisplay_line_numbers_major_tick, "display-line-numbers-major-tick");
+
+  DEFVAR_LISP ("display-line-numbers-minor-tick", Vdisplay_line_numbers_minor_tick,
+    doc: /* If an integer N > 0, highlight line number of every Nth line.
+The line number is shown with the `line-number-minor-tick' face.
+Otherwise, no special highlighting is done every Mth line.
+Note that major ticks take precedence over minor ticks.  */);
+  Vdisplay_line_numbers_minor_tick = make_fixnum (0);
+  DEFSYM (Qdisplay_line_numbers_minor_tick, "display-line-numbers-minor-tick");
+
   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


^ permalink raw reply related	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  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
  1 sibling, 1 reply; 129+ messages in thread
From: Juanma Barranquero @ 2019-10-05  6:26 UTC (permalink / raw)
  To: Yuri D'Elia
  Cc: spacibba, rpluim, stefan, Emacs developers,
	Lars Magne Ingebrigtsen, Eli Zaretskii


[-- Attachment #1.1: Type: text/plain, Size: 224 bytes --]

Incomplete patch (no docs other than the variable's docstring, etc.)

AFAICS, it implements the suggested behavior with respect to
relative/visual and narrowing.

Please check that it does what you (y'all ;-) expected.

TIA

[-- Attachment #1.2: Type: text/html, Size: 362 bytes --]

[-- Attachment #2: 0001-First-shot-at-display-line-numbers-offset.patch --]
[-- Type: application/octet-stream, Size: 2985 bytes --]

From 6f56e329cdf26cd5d0dab9fc9f8fa8835851275d Mon Sep 17 00:00:00 2001
From: Juanma Barranquero <lekktu@gmail.com>
Date: Sat, 5 Oct 2019 08:20:23 +0200
Subject: [PATCH] First shot at `display-line-numbers-offset'

---
 src/xdisp.c | 29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)

diff --git a/src/xdisp.c b/src/xdisp.c
index 9d1fdecaff..334313bd45 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -22409,10 +22409,22 @@ maybe_produce_line_number (struct it *it)
   ptrdiff_t start_from, bytepos;
   ptrdiff_t this_line;
   bool first_time = false;
-  ptrdiff_t beg_byte = display_line_numbers_widen ? BEG_BYTE : BEGV_BYTE;
-  ptrdiff_t z_byte = display_line_numbers_widen ? Z_BYTE : ZV_BYTE;
+  ptrdiff_t beg_byte;
+  ptrdiff_t z_byte;
+  bool line_numbers_wide;
   void *itdata = bidi_shelve_cache ();
 
+  if (display_line_numbers_offset
+      && !display_line_numbers_widen
+      && !EQ (Vdisplay_line_numbers, Qvisual)
+      && !EQ (Vdisplay_line_numbers, Qrelative))
+    line_numbers_wide = true;
+  else
+    line_numbers_wide = display_line_numbers_widen;
+
+  beg_byte = line_numbers_wide ? BEG_BYTE : BEGV_BYTE;
+  z_byte = line_numbers_wide ? Z_BYTE : ZV_BYTE;
+
   if (EQ (Vdisplay_line_numbers, Qvisual))
     this_line = display_count_lines_visually (it);
   else
@@ -22427,7 +22439,7 @@ maybe_produce_line_number (struct it *it)
 		 numbers, so we cannot use its data if the user wants
 		 line numbers that disregard narrowing, or if the
 		 buffer's narrowing has just changed.  */
-	      && !(display_line_numbers_widen
+	      && !(line_numbers_wide
 		   && (BEG_BYTE != BEGV_BYTE || Z_BYTE != ZV_BYTE))
 	      && !current_buffer->clip_changed)
 	    {
@@ -22517,6 +22529,8 @@ maybe_produce_line_number (struct it *it)
     lnum_offset = it->pt_lnum;
   else if (EQ (Vdisplay_line_numbers, Qvisual))
     lnum_offset = 0;
+  else if (display_line_numbers_offset)
+    lnum_offset -= display_line_numbers_offset;
 
   /* Under 'relative', display the absolute line number for the
      current line, unless the user requests otherwise.  */
@@ -34619,6 +34633,15 @@ syms_of_xdisp (void)
   DEFSYM (Qdisplay_line_numbers_widen, "display-line-numbers-widen");
   Fmake_variable_buffer_local (Qdisplay_line_numbers_widen);
 
+  DEFVAR_INT ("display-line-numbers-offset", display_line_numbers_offset,
+    doc: /* A signed integer added to the current line number.
+This only has effect with absolute line numbers. Also, note that
+when this variable is non-zero, narrowing is disregarded as if
+`display-line-number-widen' were non-nil.  */);
+  display_line_numbers_offset = 0;
+  DEFSYM (Qdisplay_line_numbers_offset, "display-line-numbers-offset");
+  Fmake_variable_buffer_local (Qdisplay_line_numbers_offset);
+
   DEFVAR_BOOL ("display-fill-column-indicator", Vdisplay_fill_column_indicator,
     doc: /* Non-nil means display the fill column indicator.  */);
   Vdisplay_fill_column_indicator = false;
-- 
2.23.0.windows.1


^ permalink raw reply related	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  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
  0 siblings, 2 replies; 129+ messages in thread
From: Juanma Barranquero @ 2019-10-06 14:04 UTC (permalink / raw)
  To: Yuri D'Elia
  Cc: spacibba, Johan Bockgård, Emacs developers, Stefan Monnier,
	Lars Magne Ingebrigtsen, yuri.v.khan, Eli Zaretskii

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

I think the Major/Minor Ticks, or the alternate Nth/Mth one, is ready to
install.

Any further comments?

Eli, I prefer the Major/Minor Tick names, but I'll defer to your decision.

[-- Attachment #2: Type: text/html, Size: 254 bytes --]

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-06 14:04                                                           ` Juanma Barranquero
@ 2019-10-06 14:45                                                             ` Juanma Barranquero
  2019-10-06 18:02                                                             ` Eli Zaretskii
  1 sibling, 0 replies; 129+ messages in thread
From: Juanma Barranquero @ 2019-10-06 14:45 UTC (permalink / raw)
  To: Yuri D'Elia
  Cc: spacibba, Johan Bockgård, Emacs developers, Stefan Monnier,
	Lars Magne Ingebrigtsen, yuri.v.khan, Eli Zaretskii


[-- Attachment #1.1: Type: text/plain, Size: 285 bytes --]

> I think the Major/Minor Ticks, or the alternate Nth/Mth one, is ready to
install.

This (hopefully definitive) version uses DEFVAR_INT instead of DEFVAR_LISP.
I was initializing them to 0, so I wasn't following my own advice. This
makes it simpler and hopefully fractionally faster.

[-- Attachment #1.2: Type: text/html, Size: 379 bytes --]

[-- Attachment #2: 0001-Set-alternate-faces-for-some-line-numbers-bug-27734.patch --]
[-- Type: application/octet-stream, Size: 7822 bytes --]

From e60f4a9ee17a32dbc1a6bbf5a0227fb1afe217e8 Mon Sep 17 00:00:00 2001
From: Juanma Barranquero <lekktu@gmail.com>
Date: Sun, 6 Oct 2019 16:38:11 +0200
Subject: [PATCH] Set alternate faces for some line numbers (bug#27734)

* lisp/faces.el (line-number-major-tick, line-number-minor-tick):
New faces.
* lisp/cus-start.el (display-line-numbers-major-tick)
(display-line-numbers-minor-tick): Add customization info.

* src/xdisp.c (syms_of_xdisp) <display-line-numbers-major-tick>
<display-line-numbers-major-tick>: Defvar new options.
(syms_of_xdisp) <line-number-major-tick, line-number-minor-tick>:
Defsym new faces.
(maybe_produce_line_number): Use new faces for line numbers
that are multiple of `display-line-numbers-major-tick' and
`display-line-numbers-minor-tick'.

* etc/NEWS (value): Announce new feature.
* doc/emacs/display.texi (Display Custom): Describe it.  Wording by
Robert Pluim <rpluim@gmail.com>
---
 doc/emacs/display.texi |  7 ++++++-
 etc/NEWS               |  7 +++++++
 lisp/cus-start.el      | 12 ++++++++++++
 lisp/faces.el          | 34 ++++++++++++++++++++++++++++++++++
 src/xdisp.c            | 24 ++++++++++++++++++++++++
 5 files changed, 83 insertions(+), 1 deletion(-)

diff --git a/doc/emacs/display.texi b/doc/emacs/display.texi
index 84363d0f0d..406feb8c12 100644
--- a/doc/emacs/display.texi
+++ b/doc/emacs/display.texi
@@ -1871,7 +1871,12 @@ 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-major-tick} and
+@code{line-number-minor-tick} can be used to highlight the line numbers
+of lines which are a multiple of certain numbers.  Customize
+@code{display-line-numbers-major-tick} and
+@code{display-line-numbers-minor-tick} respectively to set those
+numbers.
 
 @vindex visible-bell
   If the variable @code{visible-bell} is non-@code{nil}, Emacs attempts
diff --git a/etc/NEWS b/etc/NEWS
index 0edbec6894..b3b97939e8 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -558,6 +558,13 @@ 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-major-tick' and 'line-number-minor-tick',
+and customizable variables 'display-line-numbers-major-tick' and
+'display-line-numbers-minor-tick' can be used to highlight the line
+numbers of lines multiple of certain numbers.
+
 +++
 ** 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..2e37f095bb 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-major-tick
+              display-line-numbers
+              (choice
+               (const :tag "No line" 0)
+               (integer :tag "Multiples of" 10))
+              "27.1")
+             (display-line-numbers-minor-tick
+              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..58b6349ccf 100644
--- a/lisp/faces.el
+++ b/lisp/faces.el
@@ -2390,6 +2390,40 @@ line-number-current-line
   :group 'basic-faces
   :group 'display-line-numbers)
 
+(defface line-number-major-tick
+  '((t :inherit line-number))
+  "Face for highlighting \"major ticks\" (as in a ruler).
+When `display-line-numbers-major-tick' is positive, highlight
+the line numbers of lines which are a multiple of its value.
+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-minor-tick
+  '((t :inherit line-number))
+  "Face for highlighting \"minor ticks\" (as in a ruler).
+When `display-line-numbers-minor-tick' is positive, highlight
+the line numbers of lines which are a multiple of its value.
+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 f5dedc218e..b97dd381a2 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -22574,6 +22574,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 (display_line_numbers_major_tick > 0
+	       && (lnum_to_display % display_line_numbers_major_tick == 0))
+	tem_it.face_id = merge_faces (it->w, Qline_number_major_tick,
+				      0, DEFAULT_FACE_ID);
+      else if (display_line_numbers_minor_tick > 0
+	       && (lnum_to_display % display_line_numbers_minor_tick == 0))
+	tem_it.face_id = merge_faces (it->w, Qline_number_minor_tick,
+				      0, DEFAULT_FACE_ID);
       else
 	tem_it.face_id = lnum_face_id;
       if (beyond_zv
@@ -34014,6 +34022,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_major_tick, "line-number-major-tick");
+  DEFSYM (Qline_number_minor_tick, "line-number-minor-tick");
   /* Name of a text property which disables line-number display.  */
   DEFSYM (Qdisplay_line_numbers_disable, "display-line-numbers-disable");
 
@@ -34649,6 +34659,20 @@ 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_INT ("display-line-numbers-major-tick", display_line_numbers_major_tick,
+    doc: /* If an integer N > 0, highlight line number of every Nth line.
+The line number is shown with the `line-number-major-tick' face.
+Otherwise, no special highlighting is done every Nth line.
+Note that major ticks take precedence over minor ticks.  */);
+  display_line_numbers_major_tick = 0;
+
+  DEFVAR_INT ("display-line-numbers-minor-tick", display_line_numbers_minor_tick,
+    doc: /* If an integer N > 0, highlight line number of every Nth line.
+The line number is shown with the `line-number-minor-tick' face.
+Otherwise, no special highlighting is done every Nth line.
+Note that major ticks take precedence over minor ticks.  */);
+  display_line_numbers_minor_tick = 0;
+
   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


^ permalink raw reply related	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-06 14:04                                                           ` Juanma Barranquero
  2019-10-06 14:45                                                             ` Juanma Barranquero
@ 2019-10-06 18:02                                                             ` Eli Zaretskii
  1 sibling, 0 replies; 129+ messages in thread
From: Eli Zaretskii @ 2019-10-06 18:02 UTC (permalink / raw)
  To: Juanma Barranquero
  Cc: spacibba, bojohan, yuri.v.khan, monnier, wavexx, larsi,
	emacs-devel

> From: Juanma Barranquero <lekktu@gmail.com>
> Date: Sun, 6 Oct 2019 16:04:04 +0200
> Cc: Stefan Monnier <monnier@iro.umontreal.ca>, Johan Bockgård <bojohan@gnu.org>, 
> 	spacibba@aol.com, yuri.v.khan@gmail.com, 
> 	Lars Magne Ingebrigtsen <larsi@gnus.org>, Emacs developers <emacs-devel@gnu.org>, Eli Zaretskii <eliz@gnu.org>
> 
> I think the Major/Minor Ticks, or the alternate Nth/Mth one, is ready to install.

Go for it.

> Eli, I prefer the Major/Minor Tick names, but I'll defer to your decision.

Major/Minor Ticks is fine with me.  Thanks.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-05  6:26                                                     ` Juanma Barranquero
@ 2019-10-07  0:14                                                       ` Juanma Barranquero
  2019-10-07  6:54                                                         ` Robert Pluim
  2019-10-09 10:51                                                         ` Juanma Barranquero
  0 siblings, 2 replies; 129+ messages in thread
From: Juanma Barranquero @ 2019-10-07  0:14 UTC (permalink / raw)
  To: Yuri D'Elia
  Cc: spacibba, rpluim, stefan, Emacs developers,
	Lars Magne Ingebrigtsen, Eli Zaretskii


[-- Attachment #1.1: Type: text/plain, Size: 1273 bytes --]

This implements display-line-numbers-offset, and adds info, NEWS, etc.
Better wording welcome, as always. The variable is automatically
buffer-local because I don't imagine that there's a good default value
(other than zero) and each buffer that uses it will want its own.

I've done some testing, but more eyes would be great.

As an aside, this allows some dirty tricks, like numbering from 0 (by
setting it to -1), or this funny monstrosity, which allows to reverse-count
the buffer:

  (let ((old nil)
        (buf (current-buffer)))
    (add-hook 'before-change-functions
              (lambda (beg end)
                (when (eq buf (current-buffer))
                  (setq old (count-lines beg end)))))
    (add-hook 'after-change-functions
              (lambda (beg end _len)
                (when (and (eq buf (current-buffer))
                           old
                           (/= old (count-lines beg end)))
                  (setq display-line-numbers-offset (- -1
                                                     (count-lines
(point-min)

(point-max)))
                        old nil)))))

Of course, if the buffer is immutable, this is just

  (setq display-line-numbers-offset (- -1 (count-lines (point-min)
(point-max))))

in some mode hook.

[-- Attachment #1.2: Type: text/html, Size: 1685 bytes --]

[-- Attachment #2: 0001-Implement-offsets-for-absolute-line-numbers.patch --]
[-- Type: application/octet-stream, Size: 6719 bytes --]

From 223ebc2a9a2a7cecbfae5e884e0e3bdc8995e000 Mon Sep 17 00:00:00 2001
From: Juanma Barranquero <lekktu@gmail.com>
Date: Mon, 7 Oct 2019 01:22:14 +0200
Subject: [PATCH] Implement offsets for absolute line numbers

* src/xdisp.c (syms_of_xdisp) <display-line-numbers-offset>:
New variable to add an offset to absolute line numbers.
(syms_of_xdisp) <display-line-numbers>: Mention it in docstring.
(maybe_produce_line_number): Use it.

* doc/emacs/display.texi (Display Custom): Document it.

* etc/NEWS (value): Announce it.

* lisp/frame.el: Add `display-line-numbers-offset' to list of
variables to which should trigger redisplay of the current buffer.
---
 doc/emacs/display.texi |  7 +++++++
 etc/NEWS               |  4 ++++
 lisp/frame.el          |  1 +
 src/xdisp.c            | 43 +++++++++++++++++++++++++++++++++++-------
 4 files changed, 48 insertions(+), 7 deletions(-)

diff --git a/doc/emacs/display.texi b/doc/emacs/display.texi
index 406feb8c12..cb37ef448e 100644
--- a/doc/emacs/display.texi
+++ b/doc/emacs/display.texi
@@ -1855,6 +1855,13 @@ Display Custom
 value, line numbers will disregard any narrowing and will start at the
 first character of the buffer.
 
+@vindex display-line-numbers-offset
+If the value of @code{display-line-numbers-offset} is non-zero, it is
+added to each absolute line number, and lines are counted from the
+beginning of the buffer, as if @code{display-line-numbers-widen} were
+non-@code{nil}.  It has no effect when set to zero, or when line
+numbers are not absolute.
+
 @vindex display-line-numbers-width-start
 @vindex display-line-numbers-grow-only
 @vindex display-line-numbers-width
diff --git a/etc/NEWS b/etc/NEWS
index 4a32300268..a40eb06b85 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -560,11 +560,15 @@ now prompts the user for the directory containing the desktop file.
 
 +++
 ** display-line-numbers-mode
+
 *** New faces 'line-number-major-tick' and 'line-number-minor-tick',
 and customizable variables 'display-line-numbers-major-tick' and
 'display-line-numbers-minor-tick' can be used to highlight the line
 numbers of lines multiple of certain numbers.
 
+*** New variable `display-line-numbers-offset', when non-zero, adds
+an offset to absolute line numbers.
+
 +++
 ** winner
 *** A new variable, 'winner-boring-buffers-regexp', has been added.
diff --git a/lisp/frame.el b/lisp/frame.el
index 51b3b621ff..018c2f578e 100644
--- a/lisp/frame.el
+++ b/lisp/frame.el
@@ -2726,6 +2726,7 @@ 'automatic-hscrolling
         display-line-numbers-widen
         display-line-numbers-major-tick
         display-line-numbers-minor-tick
+        display-line-numbers-offset
         display-fill-column-indicator
         display-fill-column-indicator-column
         display-fill-column-indicator-character
diff --git a/src/xdisp.c b/src/xdisp.c
index 1f3a8136f8..563cf473cf 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -22506,10 +22506,22 @@ maybe_produce_line_number (struct it *it)
   ptrdiff_t start_from, bytepos;
   ptrdiff_t this_line;
   bool first_time = false;
-  ptrdiff_t beg_byte = display_line_numbers_widen ? BEG_BYTE : BEGV_BYTE;
-  ptrdiff_t z_byte = display_line_numbers_widen ? Z_BYTE : ZV_BYTE;
+  ptrdiff_t beg_byte;
+  ptrdiff_t z_byte;
+  bool line_numbers_wide;
   void *itdata = bidi_shelve_cache ();
 
+  if (display_line_numbers_offset
+      && !display_line_numbers_widen
+      && !EQ (Vdisplay_line_numbers, Qvisual)
+      && !EQ (Vdisplay_line_numbers, Qrelative))
+    line_numbers_wide = true;
+  else
+    line_numbers_wide = display_line_numbers_widen;
+
+  beg_byte = line_numbers_wide ? BEG_BYTE : BEGV_BYTE;
+  z_byte = line_numbers_wide ? Z_BYTE : ZV_BYTE;
+
   if (EQ (Vdisplay_line_numbers, Qvisual))
     this_line = display_count_lines_visually (it);
   else
@@ -22524,7 +22536,7 @@ maybe_produce_line_number (struct it *it)
 		 numbers, so we cannot use its data if the user wants
 		 line numbers that disregard narrowing, or if the
 		 buffer's narrowing has just changed.  */
-	      && !(display_line_numbers_widen
+	      && !(line_numbers_wide
 		   && (BEG_BYTE != BEGV_BYTE || Z_BYTE != ZV_BYTE))
 	      && !current_buffer->clip_changed)
 	    {
@@ -22614,6 +22626,8 @@ maybe_produce_line_number (struct it *it)
     lnum_offset = it->pt_lnum;
   else if (EQ (Vdisplay_line_numbers, Qvisual))
     lnum_offset = 0;
+  else if (display_line_numbers_offset)
+    lnum_offset -= display_line_numbers_offset;
 
   /* Under 'relative', display the absolute line number for the
      current line, unless the user requests otherwise.  */
@@ -34701,12 +34715,18 @@ syms_of_xdisp (void)
 
   DEFVAR_LISP ("display-line-numbers", Vdisplay_line_numbers,
     doc: /* Non-nil means display line numbers.
+
 If the value is t, display the absolute number of each line of a buffer
 shown in a window.  Absolute line numbers count from the beginning of
-the current narrowing, or from buffer beginning.  If the value is
-`relative', display for each line not containing the window's point its
-relative number instead, i.e. the number of the line relative to the
-line showing the window's point.
+the current narrowing, or from buffer beginning.  The variable
+`display-line-numbers-offset', if non-zero, is a signed offset added
+to each absolute line number; it also forces line numbers to be counted
+from the beginning of the buffer, as if `display-line-numbers-wide'
+were non-nil.  It has no effect when line numbers are not absolute.
+
+If the value is `relative', display for each line not containing the
+window's point its relative number instead, i.e. the number of the line
+relative to the line showing the window's point.
 
 In either case, line numbers are displayed at the beginning of each
 non-continuation line that displays buffer text, i.e. after each newline
@@ -34747,6 +34767,15 @@ syms_of_xdisp (void)
   DEFSYM (Qdisplay_line_numbers_widen, "display-line-numbers-widen");
   Fmake_variable_buffer_local (Qdisplay_line_numbers_widen);
 
+  DEFVAR_INT ("display-line-numbers-offset", display_line_numbers_offset,
+    doc: /* A signed integer added to each absolute line number.
+When this variable is non-zero, line numbers are always counted from
+the beginning of the buffer even if `display-line-numbers-widen' is nil.
+It has no effect when set to 0, or when line numbers are not absolute.  */);
+  display_line_numbers_offset = 0;
+  DEFSYM (Qdisplay_line_numbers_offset, "display-line-numbers-offset");
+  Fmake_variable_buffer_local (Qdisplay_line_numbers_offset);
+
   DEFVAR_BOOL ("display-fill-column-indicator", Vdisplay_fill_column_indicator,
     doc: /* Non-nil means display the fill column indicator.  */);
   Vdisplay_fill_column_indicator = false;
-- 
2.23.0.windows.1


^ permalink raw reply related	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-07  0:14                                                       ` Juanma Barranquero
@ 2019-10-07  6:54                                                         ` Robert Pluim
  2019-10-07  7:39                                                           ` Juanma Barranquero
  2019-10-09 10:51                                                         ` Juanma Barranquero
  1 sibling, 1 reply; 129+ messages in thread
From: Robert Pluim @ 2019-10-07  6:54 UTC (permalink / raw)
  To: Juanma Barranquero
  Cc: spacibba, stefan, Emacs developers, Yuri D'Elia,
	Eli Zaretskii, Lars Magne Ingebrigtsen

>>>>> On Mon, 7 Oct 2019 02:14:05 +0200, Juanma Barranquero <lekktu@gmail.com> said:
    Juanma> +  DEFVAR_INT ("display-line-numbers-offset", display_line_numbers_offset,
    Juanma> +    doc: /* A signed integer added to each absolute line number.

I thought the convention for C-level variables for Lisp variables was
to stick a 'V' on the front, but I see Eli didnʼt do that for
display-line-numbers-widen, so now Iʼm wondering.

Also: if you add this new variable to lisp/cus-start.el, it will be
customizable.

Robert



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-07  6:54                                                         ` Robert Pluim
@ 2019-10-07  7:39                                                           ` Juanma Barranquero
  2019-10-07  8:09                                                             ` Robert Pluim
  0 siblings, 1 reply; 129+ messages in thread
From: Juanma Barranquero @ 2019-10-07  7:39 UTC (permalink / raw)
  To: Robert Pluim
  Cc: spacibba, stefan, Emacs developers, Yuri D'Elia,
	Eli Zaretskii, Lars Magne Ingebrigtsen

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

On Mon, Oct 7, 2019 at 8:54 AM Robert Pluim <rpluim@gmail.com> wrote:

> I thought the convention for C-level variables for Lisp variables was
> to stick a 'V' on the front, but I see Eli didnʼt do that for
> display-line-numbers-widen, so now Iʼm wondering.

I think it's usually not done for native type variables: integer, boolean.
But I could be wrong.

> Also: if you add this new variable to lisp/cus-start.el, it will be
> customizable.

Yes, I did that with the major/minor ticks.

But the offset strikes me as a variable that doesn't make much sense to
customize. More like setting it in a mode hook or something.

Do you feel otherwise?

[-- Attachment #2: Type: text/html, Size: 878 bytes --]

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-07  7:39                                                           ` Juanma Barranquero
@ 2019-10-07  8:09                                                             ` Robert Pluim
  2019-10-07  8:39                                                               ` Juanma Barranquero
  2019-10-07 16:30                                                               ` Eli Zaretskii
  0 siblings, 2 replies; 129+ messages in thread
From: Robert Pluim @ 2019-10-07  8:09 UTC (permalink / raw)
  To: Juanma Barranquero
  Cc: spacibba, stefan, Emacs developers, Yuri D'Elia,
	Eli Zaretskii, Lars Magne Ingebrigtsen

>>>>> On Mon, 7 Oct 2019 09:39:08 +0200, Juanma Barranquero <lekktu@gmail.com> said:

    Juanma> On Mon, Oct 7, 2019 at 8:54 AM Robert Pluim <rpluim@gmail.com> wrote:
    >> I thought the convention for C-level variables for Lisp variables was
    >> to stick a 'V' on the front, but I see Eli didnʼt do that for
    >> display-line-numbers-widen, so now Iʼm wondering.

    Juanma> I think it's usually not done for native type variables: integer, boolean.
    Juanma> But I could be wrong.

I canʼt find any documentation stating that, although a quick scan of eg
xdisp.c supports that.

    >> Also: if you add this new variable to lisp/cus-start.el, it will be
    >> customizable.

    Juanma> Yes, I did that with the major/minor ticks.

    Juanma> But the offset strikes me as a variable that doesn't make much sense to
    Juanma> customize. More like setting it in a mode hook or something.

    Juanma> Do you feel otherwise?

I was thinking of the case where people want a particular value in
most of their buffers, in which case they'd want a default, which
they'd then override for a few cases with a mode-hook. I canʼt judge
how common that would be though.

Robert



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-07  8:09                                                             ` Robert Pluim
@ 2019-10-07  8:39                                                               ` Juanma Barranquero
  2019-10-07 18:52                                                                 ` Juri Linkov
  2019-10-07 16:30                                                               ` Eli Zaretskii
  1 sibling, 1 reply; 129+ messages in thread
From: Juanma Barranquero @ 2019-10-07  8:39 UTC (permalink / raw)
  To: Robert Pluim
  Cc: spacibba, stefan, Emacs developers, Yuri D'Elia,
	Eli Zaretskii, Lars Magne Ingebrigtsen

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

On Mon, Oct 7, 2019 at 10:09 AM Robert Pluim <rpluim@gmail.com> wrote:

> I was thinking of the case where people want a particular value in
> most of their buffers, in which case they'd want a default, which
> they'd then override for a few cases with a mode-hook. I canʼt judge
> how common that would be though.

I can well imagine people wanting a default for the major/minor ticks,
because in most cases that's a matter of preference. But the offset will
surely depend on the kind of data in the buffer, don't you think? I think
it's unlikely that someone will want all their buffers' lines numbered
starting from 10 or something like that. The only clear exception I can
think of is someone setting it to -1 to start numbering lines from 0.

Anyway, we can add the customization later if there's interest.

[-- Attachment #2: Type: text/html, Size: 972 bytes --]

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-07  8:09                                                             ` Robert Pluim
  2019-10-07  8:39                                                               ` Juanma Barranquero
@ 2019-10-07 16:30                                                               ` Eli Zaretskii
  2019-10-08 11:15                                                                 ` Robert Pluim
  1 sibling, 1 reply; 129+ messages in thread
From: Eli Zaretskii @ 2019-10-07 16:30 UTC (permalink / raw)
  To: Robert Pluim; +Cc: spacibba, lekktu, stefan, emacs-devel, wavexx, larsi

> From: Robert Pluim <rpluim@gmail.com>
> Cc: "Yuri D'Elia" <wavexx@thregr.org>,  Eli Zaretskii <eliz@gnu.org>,
>   stefan@marxist.se,  Lars Magne Ingebrigtsen <larsi@gnus.org>,
>   spacibba@aol.com,  Emacs developers <emacs-devel@gnu.org>
> Date: Mon, 07 Oct 2019 10:09:43 +0200
> 
> >>>>> On Mon, 7 Oct 2019 09:39:08 +0200, Juanma Barranquero <lekktu@gmail.com> said:
> 
>     Juanma> On Mon, Oct 7, 2019 at 8:54 AM Robert Pluim <rpluim@gmail.com> wrote:
>     >> I thought the convention for C-level variables for Lisp variables was
>     >> to stick a 'V' on the front, but I see Eli didnʼt do that for
>     >> display-line-numbers-widen, so now Iʼm wondering.
> 
>     Juanma> I think it's usually not done for native type variables: integer, boolean.

That's right.  Only general Lisp objects get called Vsomething.

> I canʼt find any documentation stating that

We have a node about writing Emacs Lisp primitives; a node about Lisp
variables implemented in C still awaits its author.  Patches are
welcome.

> I was thinking of the case where people want a particular value in
> most of their buffers, in which case they'd want a default, which
> they'd then override for a few cases with a mode-hook. I canʼt judge
> how common that would be though.

I tend to think that this will be rare, so I think a simple variable
is good enough at this stage.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-07  8:39                                                               ` Juanma Barranquero
@ 2019-10-07 18:52                                                                 ` Juri Linkov
  2019-10-08  0:57                                                                   ` Juanma Barranquero
  0 siblings, 1 reply; 129+ messages in thread
From: Juri Linkov @ 2019-10-07 18:52 UTC (permalink / raw)
  To: Juanma Barranquero
  Cc: spacibba, Robert Pluim, stefan, Emacs developers, Yuri D'Elia,
	Eli Zaretskii, Lars Magne Ingebrigtsen

> Anyway, we can add the customization later if there's interest.

Please set some nice default colors to new faces, something like
“grey80” or “grey85”, so after users customize numeric options, the
result of customization can be seen immediately, and default colors
could be tweaked later.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-07 18:52                                                                 ` Juri Linkov
@ 2019-10-08  0:57                                                                   ` Juanma Barranquero
  2019-10-19 20:38                                                                     ` Juri Linkov
  0 siblings, 1 reply; 129+ messages in thread
From: Juanma Barranquero @ 2019-10-08  0:57 UTC (permalink / raw)
  To: Juri Linkov
  Cc: spacibba, Robert Pluim, stefan, Emacs developers, Yuri D'Elia,
	Eli Zaretskii, Lars Magne Ingebrigtsen

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

On Mon, Oct 7, 2019 at 9:02 PM Juri Linkov <juri@linkov.net> wrote:

> Please set some nice default colors to new faces, something like
> “grey80” or “grey85”, so after users customize numeric options, the
> result of customization can be seen immediately, and default colors
> could be tweaked later.

Done. Feel free to change them for better defaults.

[-- Attachment #2: Type: text/html, Size: 505 bytes --]

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-07 16:30                                                               ` Eli Zaretskii
@ 2019-10-08 11:15                                                                 ` Robert Pluim
  2019-10-08 12:23                                                                   ` Eli Zaretskii
  0 siblings, 1 reply; 129+ messages in thread
From: Robert Pluim @ 2019-10-08 11:15 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: spacibba, lekktu, stefan, emacs-devel, wavexx, larsi

>>>>> On Mon, 07 Oct 2019 19:30:34 +0300, Eli Zaretskii <eliz@gnu.org> said:

    Eli> We have a node about writing Emacs Lisp primitives; a node about Lisp
    Eli> variables implemented in C still awaits its author.  Patches are
    Eli> welcome.

I donʼt know about a separate node. How about this:

diff --git a/doc/lispref/internals.texi b/doc/lispref/internals.texi
index c52999e1cd..54f1e8858d 100644
--- a/doc/lispref/internals.texi
+++ b/doc/lispref/internals.texi
@@ -945,7 +945,7 @@ Writing Emacs Primitives
 @anchor{Defining Lisp variables in C}
 @vindex byte-boolean-vars
 @cindex defining Lisp variables in C
-@cindex @code{DEFVAR_INT}, @code{DEFVAR_LISP}, @code{DEFVAR_BOOL}
+@cindex @code{DEFVAR_INT}, @code{DEFVAR_LISP}, @code{DEFVAR_BOOL}, @code{DEFSYM}
   The function @code{syms_of_@var{filename}} is also the place to define
 any C variables that are to be visible as Lisp variables.
 @code{DEFVAR_LISP} makes a C variable of type @code{Lisp_Object} visible
@@ -956,6 +956,38 @@ Writing Emacs Primitives
 defined with @code{DEFVAR_BOOL} are automatically added to the list
 @code{byte-boolean-vars} used by the byte compiler.
 
+  These macros all expect three arguments:
+
+@table @code
+@item lname
+The Lisp-level name of the variable.
+@item vname
+The C-level name of the variable.
+@item doc
+The documentation for the variable, as a C comment.
+@end table
+
+  By convention, when defining variables of a ``native'' type
+(@code{int} and @code{bool}), the name of the C variable is the same
+as the name of the Lisp variable with ``-'' replaced by ``_''.  When
+the variable can hold any Lisp object, the convention is
+to also prefix the C variable name with ``V''.  i.e.
+
+@smallexample
+DEFVAR_INT ("my-int-variable", my_int_variable,
+           doc: /* An integer variable.  */);
+
+DEFVAR_LISP ("my-lisp-variable", Vmy_lisp_variable,
+           doc: /* A Lisp variable.  */);
+@end smallexample
+
+If you want to define a constant symbol rather than a variable, use
+@code{DEFSYM} instead.  e.g.
+
+@smallexample
+DEFSYM ("Qmy_symbol", "my-symbol");
+@end smallexample
+
 @cindex defining customization variables in C
   If you want to make a Lisp variable that is defined in C behave
 like one declared with @code{defcustom}, add an appropriate entry to



^ permalink raw reply related	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-08 11:15                                                                 ` Robert Pluim
@ 2019-10-08 12:23                                                                   ` Eli Zaretskii
  2019-10-09  7:19                                                                     ` Robert Pluim
  0 siblings, 1 reply; 129+ messages in thread
From: Eli Zaretskii @ 2019-10-08 12:23 UTC (permalink / raw)
  To: Robert Pluim; +Cc: spacibba, lekktu, stefan, emacs-devel, wavexx, larsi

> From: Robert Pluim <rpluim@gmail.com>
> Cc: lekktu@gmail.com,  wavexx@thregr.org,  stefan@marxist.se,
>   larsi@gnus.org,  spacibba@aol.com,  emacs-devel@gnu.org
> Date: Tue, 08 Oct 2019 13:15:46 +0200
> 
> I donʼt know about a separate node. How about this:

Thanks, it's a good start.  See a few comments below.

> +@table @code
> +@item lname
> +The Lisp-level name of the variable.
> +@item vname
> +The C-level name of the variable.

Instead of "Lisp-level" and "C-level", which IMO are somewhat unclear,
I'd use the likes of "the name of the variable to be used by Lisp
programs" and "the name of the variable in the C source".

> +@item doc
> +The documentation for the variable, as a C comment.

Here, please include a cross-reference to the tips about writing doc
strings.

> +  By convention, when defining variables of a ``native'' type
> +(@code{int} and @code{bool}), the name of the C variable is the same
> +as the name of the Lisp variable with ``-'' replaced by ``_''.  When
> +the variable can hold any Lisp object, the convention is
> +to also prefix the C variable name with ``V''.  i.e.

I think -, _, and V should be in @code or @samp, not in quotes.  Also,
I'd mention explicitly that the C data type of the latter category is
Lisp_Object.

> +If you want to define a constant symbol rather than a variable, use
> +@code{DEFSYM} instead.  e.g.
> +
> +@smallexample
> +DEFSYM ("Qmy_symbol", "my-symbol");
> +@end smallexample

This is IMO confusing, because it doesn't explain when would the C
programmer want "to define a constant symbol rather than a variable".
I think it's important to explain that the symbol corresponding to a
variable is needed where in Lisp one would use a quoted symbol.  A
good example is the use of specbind which is the equivalent of
let-binding on the Lisp level.

Bonus points for adding information missing from the above, such as
how to define buffer-local variables (see init_buffer_once), and how
to define custom forms for variables defined in C.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-08 12:23                                                                   ` Eli Zaretskii
@ 2019-10-09  7:19                                                                     ` Robert Pluim
  2019-10-09  8:16                                                                       ` Eli Zaretskii
  0 siblings, 1 reply; 129+ messages in thread
From: Robert Pluim @ 2019-10-09  7:19 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

>>>>> On Tue, 08 Oct 2019 15:23:57 +0300, Eli Zaretskii <eliz@gnu.org> said:

    Eli> Instead of "Lisp-level" and "C-level", which IMO are somewhat unclear,
    Eli> I'd use the likes of "the name of the variable to be used by Lisp
    Eli> programs" and "the name of the variable in the C source".

Done

    >> +@item doc
    >> +The documentation for the variable, as a C comment.

    Eli> Here, please include a cross-reference to the tips about writing doc
    Eli> strings.

Done

    >> +  By convention, when defining variables of a ``native'' type
    >> +(@code{int} and @code{bool}), the name of the C variable is the same
    >> +as the name of the Lisp variable with ``-'' replaced by ``_''.  When
    >> +the variable can hold any Lisp object, the convention is
    >> +to also prefix the C variable name with ``V''.  i.e.

    Eli> I think -, _, and V should be in @code or @samp, not in quotes.  Also,
    Eli> I'd mention explicitly that the C data type of the latter category is
    Eli> Lisp_Object.

Done

    >> +If you want to define a constant symbol rather than a variable, use
    >> +@code{DEFSYM} instead.  e.g.
    >> +
    >> +@smallexample
    >> +DEFSYM ("Qmy_symbol", "my-symbol");
    >> +@end smallexample

    Eli> This is IMO confusing, because it doesn't explain when would the C
    Eli> programmer want "to define a constant symbol rather than a variable".
    Eli> I think it's important to explain that the symbol corresponding to a
    Eli> variable is needed where in Lisp one would use a quoted symbol.  A
    Eli> good example is the use of specbind which is the equivalent of
    Eli> let-binding on the Lisp level.

Not just confusing, my example was wrong. I expanded that bit.

    Eli> Bonus points for adding information missing from the above, such as
    Eli> how to define buffer-local variables (see init_buffer_once), and how
    Eli> to define custom forms for variables defined in C.

Youʼre a hard taskmaster Eli :-) . Iʼve done my best, although I donʼt
see where init_buffer_once comes in.

Thereʼs a sentence further down that talks about cus-start.el, I added
a cross-reference to the defcustom node.

* doc/lispref/internals.texi (Writing Emacs Primitives): Add
description of DEFVAR_* arguments.  Describe variable naming
conventions. Explain 'specbind' and how to create buffer-local
variables.

diff --git a/doc/lispref/internals.texi b/doc/lispref/internals.texi
index c52999e1cd..45725c3c80 100644
--- a/doc/lispref/internals.texi
+++ b/doc/lispref/internals.texi
@@ -945,7 +945,7 @@ Writing Emacs Primitives
 @anchor{Defining Lisp variables in C}
 @vindex byte-boolean-vars
 @cindex defining Lisp variables in C
-@cindex @code{DEFVAR_INT}, @code{DEFVAR_LISP}, @code{DEFVAR_BOOL}
+@cindex @code{DEFVAR_INT}, @code{DEFVAR_LISP}, @code{DEFVAR_BOOL}, @code{DEFSYM}
   The function @code{syms_of_@var{filename}} is also the place to define
 any C variables that are to be visible as Lisp variables.
 @code{DEFVAR_LISP} makes a C variable of type @code{Lisp_Object} visible
@@ -956,15 +956,71 @@ Writing Emacs Primitives
 defined with @code{DEFVAR_BOOL} are automatically added to the list
 @code{byte-boolean-vars} used by the byte compiler.
 
+  These macros all expect three arguments:
+
+@table @code
+@item lname
+The name of the variable to be used by Lisp programs.
+@item vname
+The name of the variable in the C sources.
+@item doc
+The documentation for the variable, as a C
+comment.  @xref{Documentation Basics} for more details.
+@end table
+
+  By convention, when defining variables of a ``native'' type
+(@code{int} and @code{bool}), the name of the C variable is the name
+of the Lisp variable with @code{-} replaced by @code{_}.  When the
+variable has type @code{Lisp_Object}, the convention is to also prefix
+the C variable name with ``V''.  i.e.
+
+@smallexample
+DEFVAR_INT ("my-int-variable", my_int_variable,
+           doc: /* An integer variable.  */);
+
+DEFVAR_LISP ("my-lisp-variable", Vmy_lisp_variable,
+           doc: /* A Lisp variable.  */);
+@end smallexample
+
+  There are situations in Lisp where you need to refer to the symbol
+itself rather than the value of that symbol.  One such case is when
+temporarily overriding the value of a variable, which in Lisp is done
+with @code{let}.  In C sources, this is done by defining a
+corresponding, constant symbol, and using @code{specbind}.  By
+convention @code{Qmy_lisp_variable} corresponds to
+@code{Vmy_lisp_variable}; to define it, use the @code{DEFSYM} macro.
+i.e.
+
+@smallexample
+DEFSYM (Qmy_lisp_variable, "my-lisp-variable");
+@end smallexample
+
+  To perform the actual binding:
+
+@smallexample
+specbind (Qmy_lisp_variable, Qt);
+@end smallexample
+
+  Another use for constant symbols is when creating a buffer-local
+variable (@pxref{Buffer-Local Variables}).  In C this is done with
+@code{Fmake_variable_buffer_local} in combination with @code{DEFSYM},
+i.e.
+
+@smallexample
+DEFSYM (Qmy_lisp_variable, "my-lisp-variable");
+Fmake_variable_buffer_local (Qmy_lisp_variable);
+@end smallexample
+
 @cindex defining customization variables in C
   If you want to make a Lisp variable that is defined in C behave
 like one declared with @code{defcustom}, add an appropriate entry to
-@file{cus-start.el}.
+@file{cus-start.el}.  @xref{Variable Definitions} for a description of
+the format to use.
 
 @cindex @code{staticpro}, protection from GC
-  If you define a file-scope C variable of type @code{Lisp_Object},
-you must protect it from garbage-collection by calling @code{staticpro}
-in @code{syms_of_@var{filename}}, like this:
+  If you directly define a file-scope C variable of type
+@code{Lisp_Object}, you must protect it from garbage-collection by
+calling @code{staticpro} in @code{syms_of_@var{filename}}, like this:
 
 @example
 staticpro (&@var{variable});



^ permalink raw reply related	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-09  7:19                                                                     ` Robert Pluim
@ 2019-10-09  8:16                                                                       ` Eli Zaretskii
  2019-10-09 12:14                                                                         ` Robert Pluim
  0 siblings, 1 reply; 129+ messages in thread
From: Eli Zaretskii @ 2019-10-09  8:16 UTC (permalink / raw)
  To: Robert Pluim; +Cc: emacs-devel

> From: Robert Pluim <rpluim@gmail.com>
> Cc: emacs-devel@gnu.org
> Date: Wed, 09 Oct 2019 09:19:57 +0200
> 
>     Eli> Bonus points for adding information missing from the above, such as
>     Eli> how to define buffer-local variables (see init_buffer_once), and how
>     Eli> to define custom forms for variables defined in C.
> 
> Youʼre a hard taskmaster Eli :-) .

I've been told that, yes ;-)

> Iʼve done my best, although I donʼt see where init_buffer_once comes
> in.

I meant the likes of this:

  XSETFASTINT (BVAR (&buffer_local_flags, tab_width), idx); ++idx;

Anyone who defines buffer-local variables should generally be familiar
with this stuff.

> +  By convention, when defining variables of a ``native'' type
> +(@code{int} and @code{bool}), the name of the C variable is the name
> +of the Lisp variable with @code{-} replaced by @code{_}.  When the
> +variable has type @code{Lisp_Object}, the convention is to also prefix
> +the C variable name with ``V''.  i.e.
                            ^^^^^
@code{V}

> +  There are situations in Lisp where you need to refer to the symbol
> +itself rather than the value of that symbol.  One such case is when
> +temporarily overriding the value of a variable, which in Lisp is done
> +with @code{let}.  In C sources, this is done by defining a
> +corresponding, constant symbol, and using @code{specbind}.  By
> +convention @code{Qmy_lisp_variable} corresponds to
> +@code{Vmy_lisp_variable}; to define it, use the @code{DEFSYM} macro.
> +i.e.
> +
> +@smallexample
> +DEFSYM (Qmy_lisp_variable, "my-lisp-variable");
> +@end smallexample
> +
> +  To perform the actual binding:
> +
> +@smallexample
> +specbind (Qmy_lisp_variable, Qt);
> +@end smallexample
> +
> +  Another use for constant symbols is when creating a buffer-local
> +variable (@pxref{Buffer-Local Variables}).  In C this is done with
> +@code{Fmake_variable_buffer_local} in combination with @code{DEFSYM},
> +i.e.
> +
> +@smallexample
> +DEFSYM (Qmy_lisp_variable, "my-lisp-variable");
> +Fmake_variable_buffer_local (Qmy_lisp_variable);
> +@end smallexample

This is great, but I think it would be even better if we explained the
general principle: the Qfoo symbol is needed where in Lisp you'd use a
quoted symbol 'foo.

> +@file{cus-start.el}.  @xref{Variable Definitions} for a description of
> +the format to use.                               ^

Comma is missing there, although recent versions of Texinfo no longer
flag this.

Otherwise, this is a very good addition; thank you.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-07  0:14                                                       ` Juanma Barranquero
  2019-10-07  6:54                                                         ` Robert Pluim
@ 2019-10-09 10:51                                                         ` Juanma Barranquero
  1 sibling, 0 replies; 129+ messages in thread
From: Juanma Barranquero @ 2019-10-09 10:51 UTC (permalink / raw)
  To: Yuri D'Elia
  Cc: spacibba, rpluim, stefan, Emacs developers,
	Lars Magne Ingebrigtsen, Eli Zaretskii

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

No more comments received after a couple of days, so I've pushed it to
master. Let the fireworks begin.

[-- Attachment #2: Type: text/html, Size: 129 bytes --]

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-09  8:16                                                                       ` Eli Zaretskii
@ 2019-10-09 12:14                                                                         ` Robert Pluim
  2019-10-09 12:23                                                                           ` Eli Zaretskii
  0 siblings, 1 reply; 129+ messages in thread
From: Robert Pluim @ 2019-10-09 12:14 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

>>>>> On Wed, 09 Oct 2019 11:16:36 +0300, Eli Zaretskii <eliz@gnu.org> said:
    >> Iʼve done my best, although I donʼt see where init_buffer_once comes
    >> in.

    Eli> I meant the likes of this:

    Eli>   XSETFASTINT (BVAR (&buffer_local_flags, tab_width), idx); ++idx;

    Eli> Anyone who defines buffer-local variables should generally be familiar
    Eli> with this stuff.

Thatʼs for variables defined with DEFVAR_PER_BUFFER, not
Fmake_variable_buffer_local, no? Do people add those often enough that
we need to document it?

    >> +  By convention, when defining variables of a ``native'' type
    >> +(@code{int} and @code{bool}), the name of the C variable is the name
    >> +of the Lisp variable with @code{-} replaced by @code{_}.  When the
    >> +variable has type @code{Lisp_Object}, the convention is to also prefix
    >> +the C variable name with ``V''.  i.e.
    Eli>                             ^^^^^
    Eli> @code{V}

Fixed.

    >> +@smallexample
    >> +DEFSYM (Qmy_lisp_variable, "my-lisp-variable");
    >> +Fmake_variable_buffer_local (Qmy_lisp_variable);
    >> +@end smallexample

    Eli> This is great, but I think it would be even better if we explained the
    Eli> general principle: the Qfoo symbol is needed where in Lisp you'd use a
    Eli> quoted symbol 'foo.

Added.

    >> +@file{cus-start.el}.  @xref{Variable Definitions} for a description of
    >> +the format to use.                               ^

    Eli> Comma is missing there, although recent versions of Texinfo no longer
    Eli> flag this.

Fixed.

* doc/lispref/internals.texi (Writing Emacs Primitives): Add
description of DEFVAR_* arguments.  Describe variable naming
conventions.  Explain how to express quoting of symbols in C, plus
'specbind' and how to create buffer-local variables.

diff --git a/doc/lispref/internals.texi b/doc/lispref/internals.texi
index c52999e1cd..c2a15fe8af 100644
--- a/doc/lispref/internals.texi
+++ b/doc/lispref/internals.texi
@@ -945,7 +945,7 @@ Writing Emacs Primitives
 @anchor{Defining Lisp variables in C}
 @vindex byte-boolean-vars
 @cindex defining Lisp variables in C
-@cindex @code{DEFVAR_INT}, @code{DEFVAR_LISP}, @code{DEFVAR_BOOL}
+@cindex @code{DEFVAR_INT}, @code{DEFVAR_LISP}, @code{DEFVAR_BOOL}, @code{DEFSYM}
   The function @code{syms_of_@var{filename}} is also the place to define
 any C variables that are to be visible as Lisp variables.
 @code{DEFVAR_LISP} makes a C variable of type @code{Lisp_Object} visible
@@ -956,15 +956,78 @@ Writing Emacs Primitives
 defined with @code{DEFVAR_BOOL} are automatically added to the list
 @code{byte-boolean-vars} used by the byte compiler.
 
+  These macros all expect three arguments:
+
+@table @code
+@item lname
+The name of the variable to be used by Lisp programs.
+@item vname
+The name of the variable in the C sources.
+@item doc
+The documentation for the variable, as a C
+comment.  @xref{Documentation Basics} for more details.
+@end table
+
+  By convention, when defining variables of a ``native'' type
+(@code{int} and @code{bool}), the name of the C variable is the name
+of the Lisp variable with @code{-} replaced by @code{_}.  When the
+variable has type @code{Lisp_Object}, the convention is to also prefix
+the C variable name with @code{V}.  i.e.
+
+@smallexample
+DEFVAR_INT ("my-int-variable", my_int_variable,
+           doc: /* An integer variable.  */);
+
+DEFVAR_LISP ("my-lisp-variable", Vmy_lisp_variable,
+           doc: /* A Lisp variable.  */);
+@end smallexample
+
+  There are situations in Lisp where you need to refer to the symbol
+itself rather than the value of that symbol.  One such case is when
+temporarily overriding the value of a variable, which in Lisp is done
+with @code{let}.  In C sources, this is done by defining a
+corresponding, constant symbol, and using @code{specbind}.  By
+convention, @code{Qmy_lisp_variable} corresponds to
+@code{Vmy_lisp_variable}; to define it, use the @code{DEFSYM} macro.
+i.e.
+
+@smallexample
+DEFSYM (Qmy_lisp_variable, "my-lisp-variable");
+@end smallexample
+
+  To perform the actual binding:
+
+@smallexample
+specbind (Qmy_lisp_variable, Qt);
+@end smallexample
+
+  In Lisp symbols sometimes need to be quoted, to achieve the same
+effect in C you again use the corresponding constant symbol
+@code{Qmy_lisp_variable}.  For example, when creating a buffer-local
+variable (@pxref{Buffer-Local Variables}) in Lisp you would write:
+
+@smallexample
+(make-variable-buffer-local 'my-lisp-variable)
+@end smallexample
+
+In C the corresponding code uses @code{Fmake_variable_buffer_local} in
+combination with @code{DEFSYM}, i.e.
+
+@smallexample
+DEFSYM (Qmy_lisp_variable, "my-lisp-variable");
+Fmake_variable_buffer_local (Qmy_lisp_variable);
+@end smallexample
+
 @cindex defining customization variables in C
   If you want to make a Lisp variable that is defined in C behave
 like one declared with @code{defcustom}, add an appropriate entry to
-@file{cus-start.el}.
+@file{cus-start.el}.  @xref{Variable Definitions}, for a description of
+the format to use.
 
 @cindex @code{staticpro}, protection from GC
-  If you define a file-scope C variable of type @code{Lisp_Object},
-you must protect it from garbage-collection by calling @code{staticpro}
-in @code{syms_of_@var{filename}}, like this:
+  If you directly define a file-scope C variable of type
+@code{Lisp_Object}, you must protect it from garbage-collection by
+calling @code{staticpro} in @code{syms_of_@var{filename}}, like this:
 
 @example
 staticpro (&@var{variable});



^ permalink raw reply related	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-09 12:14                                                                         ` Robert Pluim
@ 2019-10-09 12:23                                                                           ` Eli Zaretskii
  2019-10-09 13:19                                                                             ` Robert Pluim
  0 siblings, 1 reply; 129+ messages in thread
From: Eli Zaretskii @ 2019-10-09 12:23 UTC (permalink / raw)
  To: Robert Pluim; +Cc: emacs-devel

> From: Robert Pluim <rpluim@gmail.com>
> Cc: emacs-devel@gnu.org
> Date: Wed, 09 Oct 2019 14:14:48 +0200
> 
> >>>>> On Wed, 09 Oct 2019 11:16:36 +0300, Eli Zaretskii <eliz@gnu.org> said:
>     >> Iʼve done my best, although I donʼt see where init_buffer_once comes
>     >> in.
> 
>     Eli> I meant the likes of this:
> 
>     Eli>   XSETFASTINT (BVAR (&buffer_local_flags, tab_width), idx); ++idx;
> 
>     Eli> Anyone who defines buffer-local variables should generally be familiar
>     Eli> with this stuff.
> 
> Thatʼs for variables defined with DEFVAR_PER_BUFFER

Yes.

> Do people add those often enough that we need to document it?

I don't know, but it's a kind of black magic that if you don't know
about, you are in a lot of trouble when you need to add such a
variable.

> * doc/lispref/internals.texi (Writing Emacs Primitives): Add
> description of DEFVAR_* arguments.  Describe variable naming
> conventions.  Explain how to express quoting of symbols in C, plus
> 'specbind' and how to create buffer-local variables.

LGTM, thanks.



^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-09 12:23                                                                           ` Eli Zaretskii
@ 2019-10-09 13:19                                                                             ` Robert Pluim
  0 siblings, 0 replies; 129+ messages in thread
From: Robert Pluim @ 2019-10-09 13:19 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

>>>>> On Wed, 09 Oct 2019 15:23:35 +0300, Eli Zaretskii <eliz@gnu.org> said:

>> * doc/lispref/internals.texi (Writing Emacs Primitives): Add
    >> description of DEFVAR_* arguments.  Describe variable naming
    >> conventions.  Explain how to express quoting of symbols in C, plus
    >> 'specbind' and how to create buffer-local variables.

    Eli> LGTM, thanks.

Pushed as b5fbefdac6

Thanks

Robert




^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: Native line numbers landed on master
  2019-10-08  0:57                                                                   ` Juanma Barranquero
@ 2019-10-19 20:38                                                                     ` Juri Linkov
  0 siblings, 0 replies; 129+ messages in thread
From: Juri Linkov @ 2019-10-19 20:38 UTC (permalink / raw)
  To: Juanma Barranquero
  Cc: spacibba, Robert Pluim, stefan, Emacs developers, Yuri D'Elia,
	Eli Zaretskii, Lars Magne Ingebrigtsen

>> Please set some nice default colors to new faces, something like
>> “grey80” or “grey85”, so after users customize numeric options, the
>> result of customization can be seen immediately, and default colors
>> could be tweaked later.
>
> Done.

Thanks.  Actually I meant background, not foreground :)

> Feel free to change them for better defaults.

Ok, will do.



^ permalink raw reply	[flat|nested] 129+ messages in thread

end of thread, other threads:[~2019-10-19 20:38 UTC | newest]

Thread overview: 129+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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.