From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Filipe Silva Newsgroups: gmane.emacs.devel Subject: Re: Native display of line numbers Date: Thu, 22 Jun 2017 12:02:55 -0300 Message-ID: References: <83lgoqzm0v.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="001a113caa4496f8db05528dc70e" X-Trace: blaine.gmane.org 1498143797 16887 195.159.176.226 (22 Jun 2017 15:03:17 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 22 Jun 2017 15:03:17 +0000 (UTC) Cc: Emacs developers To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jun 22 17:03:08 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 1dO3dU-0003ra-Fy for ged-emacs-devel@m.gmane.org; Thu, 22 Jun 2017 17:03:08 +0200 Original-Received: from localhost ([::1]:59539 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dO3dZ-0006th-Lu for ged-emacs-devel@m.gmane.org; Thu, 22 Jun 2017 11:03:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54573) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dO3dO-0006sC-FC for emacs-devel@gnu.org; Thu, 22 Jun 2017 11:03:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dO3dM-0002S6-R9 for emacs-devel@gnu.org; Thu, 22 Jun 2017 11:03:02 -0400 Original-Received: from mail-oi0-x232.google.com ([2607:f8b0:4003:c06::232]:35531) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dO3dK-0002Pv-L2; Thu, 22 Jun 2017 11:02:58 -0400 Original-Received: by mail-oi0-x232.google.com with SMTP id c189so10455475oia.2; Thu, 22 Jun 2017 08:02:57 -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=LoyRKg6FMGgkytrS+4NYp3AY2LwMqVWS04l46hc9GrY=; b=qwTPNxnbIFc2zVfgQvX4xKvg2GR1WtuMSwjtN5eO+o0/9wfHtrIfKbszg6bR0aHL7U xMipNjvN8DRqPFpEj2mLremUgk28l6Dq4X5zI2l/ypvUNSkN1tPr5AiydItyZ0gB8/Hs oZdOaM7k2f8zZ1deCWT4joqL5KRLCH+IciB0P/GfaT3K4Pdqu6hwT2X60cHhqxR2Ihzh Tp2unqPHoSEzTRMPhMvFxNFCvO+EXxZRPTRJSivrGKdYsiC297hpscm/i1oTEMlKBGH9 ZXZEOLoBAO0325okb4Xi5J8lcNFvb+bkuIUmLawZeVOW8R0Atic66btboqkkkJ5mo4uD +EZQ== 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=LoyRKg6FMGgkytrS+4NYp3AY2LwMqVWS04l46hc9GrY=; b=SOkMyVBbzAZfmqTEDxKPzgkNuy+T4o6+0TjZdJRISbjQoHPdsLFaI3vI+C26xwkxBS h1UKZoaILp7roWiXFdvzqGBmDgNy+LOvNCvn6zIZw/fs2BOvSExfd08YI6cshx6NcIAZ 3Mf9L8/L/d64MJv8Gtl4aASC6oaEoxXMcgchb05YaeL+bCN6OzOTRFLRHMsjSygw9wKr rY4OmxxslIhsFVfsqyiS5ozkNLxeNSib/QE+n9+q1Ty8hLW3hL/H3Mpd7d2+Dv14q+gy 8g2GfHJHwm+Riv1+47LlBE4nj1Dx37LHpLWCbfVVViYANVff2R8tE9Gt+prYiIr4apgr 0kRw== X-Gm-Message-State: AKS2vOz1e+4U4I1I+a0wSsfWo/eEbAU40ByKX0E61xGCk/ZSO2SqdIqG Ezl0C3btIdUczCnWwz8V8Z1AZgQcqg== X-Received: by 10.202.182.11 with SMTP id g11mr1721911oif.98.1498143775977; Thu, 22 Jun 2017 08:02:55 -0700 (PDT) Original-Received: by 10.157.51.8 with HTTP; Thu, 22 Jun 2017 08:02:55 -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:4003:c06::232 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:215883 Archived-At: --001a113caa4496f8db05528dc70e Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Eli =E2=80=8B, 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=E2=80=8B 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" 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 > > --001a113caa4496f8db05528dc70e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Eli
=E2=80=8B, thanks so muc= h for your work on this. I means a lot to have this feature implemented in = the timeless editor.

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

Vim implements=E2=80=8B r= elative line numbers in a way that the "relativity" aspect is bas= ed 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.

<= /div>
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 wa= nt 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: 9= k, 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. Thi= s has all kinds of uses.

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

Again, thanks for all your work in em= acs.

Filipe

On Jun 17, 2017 12:12 PM, "Eli Zar= etskii" <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

--001a113caa4496f8db05528dc70e--