[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Native display of line numbers

From: Kaushal Modi
Subject: Re: Native display of line numbers
Date: Sat, 17 Jun 2017 16:52:11 +0000

Hi Eli,

First of all, thank you for working on this!

On Sat, Jun 17, 2017 at 11:12 AM Eli Zaretskii <address@hidden> wrote:
I generally consider display of line numbers for each line in the
buffer un-Emacsy, something that came from the dark era when we needed
to count lines to be able to tell the then existing editors something
like "move down N lines, then DO SOMETHING".  Emacs pioneered today's
world where all this is unnecessary, and the rest is history.

While I don't use the line numbers that way, it's very useful to pinpoint a colleague directly to a piece of code, especially when not sharing the code visually; like when over a phone call: "Hey, open up the "foo" file and look at line 1534.". Nothing beats the precision of that.
However, many users want line numbers to be displayed in Emacs.  I
don't know why they want it, perhaps they were "spoiled" by other IDEs
or something. 

So with that in mind, I came up with an implementation of a native
display of line numbers.  You can find it in the scratch/line-numbers
branch of the Emacs repository. 

Compared with linum-mode,
nlinum-mode, and other similar modes, it has the following main

  . it works significantly faster (almost twice as fast as linum-mode,
    50% faster that relative-line-numbers-mode)

How does it compare to nlinum.el in your initial testing? I will also test it out over next few days.
Please give it a try and report any bugs you find. 

Here's my first observation after building from that branch.

In the below image, on the left I have emacs -Q running that has the new line number feature enabled, and on the right I have older emacs instance running with nlinum.el enabled.

Can you please add support for highlighting the current line number, using a different face (See the highlighted line number by nlinum on the right hand side)?

About the code:

+(defun toggle-display-line-numbers ()
+ (interactive)
+ (if display-line-numbers
+ (setq display-line-numbers nil)
+ (setq display-line-numbers t))
+ (force-mode-line-update))

Instead of this, about about a minor mode with an intuitive name like "line-numbers-mode"? Above also has an issue, I believe.. If user has set display-line-numbers to 'relative, toggling it will always set it back to t.

How about leaving the buffer local display-line-numbers definition as it is, but replacing toggle-display-line-numbers function with a minor mode line-numbers-mode?


Kaushal Modi

reply via email to

[Prev in Thread] Current Thread [Next in Thread]