From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Mathias Dahl Newsgroups: gmane.emacs.devel Subject: Re: Native display of line numbers Date: Sat, 17 Jun 2017 23:32:13 +0200 Message-ID: References: <83lgoqzm0v.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="f403043edffcca935f05522ea3f5" X-Trace: blaine.gmane.org 1497735169 22941 195.159.176.226 (17 Jun 2017 21:32:49 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 17 Jun 2017 21:32:49 +0000 (UTC) Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Jun 17 23:32:45 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dMLKm-0005hR-QN for ged-emacs-devel@m.gmane.org; Sat, 17 Jun 2017 23:32:45 +0200 Original-Received: from localhost ([::1]:36283 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMLKs-0003dw-6o for ged-emacs-devel@m.gmane.org; Sat, 17 Jun 2017 17:32:50 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38622) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMLKh-0003dX-GR for emacs-devel@gnu.org; Sat, 17 Jun 2017 17:32:41 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dMLKf-0002Mc-Ew for emacs-devel@gnu.org; Sat, 17 Jun 2017 17:32:39 -0400 Original-Received: from mail-ua0-x231.google.com ([2607:f8b0:400c:c08::231]:35341) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dMLKc-0002KX-Kp; Sat, 17 Jun 2017 17:32:34 -0400 Original-Received: by mail-ua0-x231.google.com with SMTP id j53so28121276uaa.2; Sat, 17 Jun 2017 14:32:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=fe8I7TkS2HYQz7tJdapIZx9mBx4UcrstUPKlRzV7b3E=; b=kIVGJro3qnnWvdvO6dHcDn//OPWRwAG2pvE5beOhmLZx2xSoe+huwfcz6tp418scdK nA5y4Pt8gi14OMkfieBaXdFEpSyeuaG0sZRSmjBYDa0VHIeZ/kZqjD06+PvukU55XK4F iL4h5qXO/sOVAdAzg43Fkyh0Hkmnd97nfpn+Lw0O/Fmfwqahr1inRGXaPghF9bNsBuGK QksSfES9lwxbvbubPNK8MIEW3IZQmPxsXEeqy8gc2nga772KA6/iblGLWJHWZ7AimezW plYJCwU30g4/+pcv4YoZXZLCbx3h35D19xYIvt+i2mpWAcE2GaLQZXjM3nl77QiGWbhH B4yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=fe8I7TkS2HYQz7tJdapIZx9mBx4UcrstUPKlRzV7b3E=; b=sdM5i6utdv4/osucmEj+2aiBqoZWqy/A1NgGOYySyMapKY9XuMcEfHQxD/d4HcmCou X4W/2IMofRofyjQ+1eE7+Q+8NSJSTZtwos8FlMYbJSegEgzmBFeIjLk9U5lE6SI6P4bY UIJbEYJlze4glJUdeDu2jwBbirCpS9/aKK7+wZ3zO6JZS2clxD5rJACYRTCnwUEDZ9rZ tz+VFBZHmw4Qi27AFO1nuU9nlmwaxWZu5x4TSbt/GJPlMVpOvCA2/UlYQeCeaYfKr5lJ H2CENAd5ALb4pqJ9z/CaStFxd3daAETEB1ukn08H479VDlC05TWAvIuKJ0tJftcIbek9 iHBA== X-Gm-Message-State: AKS2vOwlsZ74uuQcSq3tcy7ozv4GVIymkQXcKuyNEaHYZfcbf6VybGtU n2yl4MaM/no9ZvFeckqV11BhiWJIVC2TlNw= X-Received: by 10.176.94.104 with SMTP id a40mr5866151uah.85.1497735153486; Sat, 17 Jun 2017 14:32:33 -0700 (PDT) Original-Received: by 10.176.16.239 with HTTP; Sat, 17 Jun 2017 14:32:13 -0700 (PDT) In-Reply-To: <83lgoqzm0v.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400c:c08::231 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:215720 Archived-At: --f403043edffcca935f05522ea3f5 Content-Type: text/plain; charset="UTF-8" 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 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 > > --f403043edffcca935f05522ea3f5 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,

I have a few comments:

> I generally consider display of line numbers f= or each line in the
> buffer un-Emacsy, something that came fr= om the dark era when we needed
> to count lines to be able to = tell the then existing editors something
> like "move dow= n N lines, then DO SOMETHING".

In my 20 years= or so using Emacs, I can probably count on one hand the
number o= f 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
mai= nly been what Kaushal Modi also mentions, as a quick way to refer to
<= div>one or more lines of code, immediately.

That b= eing said, when playing around with Evil some time back, I
realiz= ed that suddenly relative line numbers (see below) were quite
use= ful. 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-keys= trokes perspective.

> Emacs pioneered today'= ;s world where all this is unnecessary, and the
> rest is hist= ory.

Are you thinking now about the difference bet= ween line editors
and... whatever Emacs is (screen editor?) And, = wasn't Emacs too
influenced by the limited display devices th= at existed back then? I
understand this is not your main point he= re, 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. =C2=A0I
> don't know why they want it= , perhaps they were "spoiled" by other IDEs
> or som= ething.

Yes, many editors have it and when I use t= hem I seldom find the need
there either. So yes, I think that mig= ht be one reason, that people have
"got used to" (it so= unds friendlier than "spoiled", I think) line
numbers f= rom there. But, I think also the recent growth of Evil (the Vim
e= mulator 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 num= bers using all kinds of tricks, I don't
> think we can ign= ore 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 t= hat 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 Lis= p program to invade the
> holy realm of redisplay, those modes= use tricks that make Emacs slower
> and frequently interfere = with other packages.=C2=A0 They also make demands
> on the dis= play engine that make Emacs harder to develop and maintain.

<= /div>
Again, this sounds really good, and a pragmatic way to solve thin= gs.

I will include here a comment from a later rep= ly:

> > Can you please add support for highl= ighting the current line number,
> > using a different face= (See the highlighted line number by nlinum on
> > the righ= t hand side)?

> Is it really important?=C2=A0 W= hy? do people really have difficulty finding
> the line where = point/cursor is?

I think it is a useful visual hel= p/guide and probably is extra useful
when your cursor is not clos= e to the left side of the window. When
moving up and down to a ce= rtain line, your eyes can look at the line
number in the edge tha= t changes color, instead of trying to match where
the cursor is c= ompared to the numbers in the edge. Of course, that exact
scenari= o 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
<= div>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:
relat= ive line numbers seems like a useful tool to some people. For those
who haven't tried it, it works like this:

= =C2=A03 ...
=C2=A02 Other line
=C2=A01 Other line
=
=C2=A00 This is the line I am on...
=C2=A01 Other line
=
=C2=A02 Other line
=C2=A03 ...

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

The= re is a risk now, when commenting on these "little things", that = the focus
shifts from the primary goal you had, to show line numb= ers in a more efficient
and stable manner, to only discuss the sm= all things. It is not my meaning,
and I am glad to see you are th= inking to add such a feature to Emacs since
I think many users wi= ll 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 <eliz@gnu.org> 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".=C2=A0 Emacs pioneere= d today's
world where all this is unnecessary, and the rest is history.

However, many users want line numbers to be displayed in Emacs.=C2=A0 I
don't know why they want it, perhaps they were "spoiled" by o= ther IDEs
or something.=C2=A0 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.=C2=A0 The "epidemic" has spread = too far
and too wide for us to continue looking the other way.=C2=A0 And since
Emacs doesn't make it easy for a Lisp program to invade the holy realm<= br> of redisplay, those modes use tricks that make Emacs slower and
frequently interfere with other packages.=C2=A0 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.=C2=A0 You can find it in the scratch/line-numbers<= br> branch of the Emacs repository.=C2=A0 Compared with linum-mode,
nlinum-mode, and other similar modes, it has the following main
advantages:

=C2=A0 . it works significantly faster (almost twice as fast as linum-mode,=
=C2=A0 =C2=A0 50% faster that relative-line-numbers-mode)
=C2=A0 . it doesn't use the display margins
=C2=A0 . 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.=C2=A0 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.=C2=A0 If, miraculously, no such flood arrives, I will merge in a couple of weeks.=C2=A0 When that happens, we will declare all the other modes which do the same job deprecated.

TIA


--f403043edffcca935f05522ea3f5--