emacs-devel
[Top][All Lists]
Advanced

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

Re: Native display of line numbers


From: Filipe Silva
Subject: Re: Native display of line numbers
Date: Thu, 22 Jun 2017 12:02:55 -0300

Eli
​, thanks so much for your work on this. I means a lot to have this feature implemented in the timeless editor.

I'm an evil-mode user and this is one of the features I miss most in vim: relative line numbers. But let me be more clear:

Vim implements​ relative line numbers in a way that the "relativity" aspect is based on the visible lines of the buffer.

This means that, for example, in an org-mode buffer, where you have a bunch of lines collpsed, you would number those visible lines with numbers relative to the line of point, and not based on the "real" relativity.

Why this is useful? because it gives vim/evil-mode users the power to rapidly move through the visible lines in the window. If I want to jump to a line in the buffer that I'm interested in, I just have to take a peek at the relative number and then I know what to do. I just: 9k, to jump 9 lines down. This is actually super powerful.

another very interesting use for this specific implementation of relative line numbers is the remote copy feature of vim ex commands. A very common operation: I'm in an empty line and I want to copy a line that is 17 lines above the line where point is. Example: :-13y to copy the 13th line above the line where point is. This is only the tip of the iceber. This has all kinds of uses.

Also, implementing a toggle that would let me switch between this absolute and relative line numbering would be beyond awesome.

Again, thanks for all your work in emacs.

Filipe

On Jun 17, 2017 12:12 PM, "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.

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.  In any case, given the popularity of the various add-on
modes which insist on displaying line numbers using all kinds of
tricks, I don't think we can ignore this tendency any longer, even if
we agree that this is a disease.  The "epidemic" has spread too far
and too wide for us to continue looking the other way.  And since
Emacs doesn't make it easy for a Lisp program to invade the holy realm
of redisplay, those modes use tricks that make Emacs slower and
frequently interfere with other packages.  They also make demands on
the display engine that make Emacs harder to develop and maintain.

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
advantages:

  . it works significantly faster (almost twice as fast as linum-mode,
    50% faster that relative-line-numbers-mode)
  . it doesn't use the display margins
  . it works with R2L text, something the old modes never did

The main features of the line-numbering modes are all supported by
this new feature.

Please give it a try and report any bugs you find.  I'm sure there
will be quite a few bugs, given the sheer amount of display feature
which could be affected, and which I didn't have time to test.

Once the flood of serious bug reports dries out, I will look into
merging this to master.  If, miraculously, no such flood arrives, I
will merge in a couple of weeks.  When that happens, we will declare
all the other modes which do the same job deprecated.

TIA


reply via email to

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