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: Mathias Dahl
Subject: Re: Native display of line numbers
Date: Sat, 17 Jun 2017 23:32:13 +0200

Hi,

I have a few comments:

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

In my 20 years or so using Emacs, I can probably count on one hand the
number of times I have really wanted/needed to see line numbers
alongside the source code. And when I have had need for it the use has
mainly been what Kaushal Modi also mentions, as a quick way to refer to
one or more lines of code, immediately.

That being said, when playing around with Evil some time back, I
realized that suddenly relative line numbers (see below) were quite
useful. Perhaps this is what you refered to with the dark era. Seems
quite popular nowadays too though, even if I personally have not got the
hang of it. I prefer to "arrow down" (or up) to the line I want to, even
if it might be less optimal from a counting-keystrokes perspective.

> Emacs pioneered today's world where all this is unnecessary, and the
> rest is history.

Are you thinking now about the difference between line editors
and... whatever Emacs is (screen editor?) And, wasn't Emacs too
influenced by the limited display devices that existed back then? I
understand this is not your main point here, but you mentioned it in
your post, so... Not meaning to start an argument, by the way, I'm
mostly curious on your thinking.

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

Yes, many editors have it and when I use them I seldom find the need
there either. So yes, I think that might be one reason, that people have
"got used to" (it sounds friendlier than "spoiled", I think) line
numbers from there. But, I think also the recent growth of Evil (the Vim
emulator mode, to be clear), Spacemacs and whatnot might have helped
too.

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

A pragmatic way to look at it, I think many will welcome it.

> The "epidemic" has spread too far and too wide for us to continue
> looking the other way.

I think by now people understood that you really see no need in showing
line numbers alongside the source code... :) Let's not bash those that
do anymore.

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

Again, this sounds really good, and a pragmatic way to solve things.

I will include here a comment from a later reply:

> > 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)?

> Is it really important?  Why? do people really have difficulty finding
> the line where point/cursor is?

I think it is a useful visual help/guide and probably is extra useful
when your cursor is not close to the left side of the window. When
moving up and down to a certain line, your eyes can look at the line
number in the edge that changes color, instead of trying to match where
the cursor is compared to the numbers in the edge. Of course, that exact
scenario can be done with Emacs traditional way to show line numbers on
the mode line as well. Anyway, I can easily see that it is useful to
highlight the current line number, even if I am not using it myself
much. It's a visual help, simply.

Some have touched on this subject here, but I will do it anyway:
relative line numbers seems like a useful tool to some people. For those
who haven't tried it, it works like this:

 3 ...
 2 Other line
 1 Other line
 0 This is the line I am on...
 1 Other line
 2 Other line
 3 ...

With relative line numbers it is quite easy to use a numeric argument to
move a certain number of lines up or down.

There is a risk now, when commenting on these "little things", that the focus
shifts from the primary goal you had, to show line numbers in a more efficient
and stable manner, to only discuss the small things. It is not my meaning,
and I am glad to see you are thinking to add such a feature to Emacs since
I think many users will like it, even if the reason is they are "spoiled" (now I
said it too... :)

Thanks for listening!

/Mathias


On Sat, Jun 17, 2017 at 5: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]