From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Native display of line numbers Date: Sat, 17 Jun 2017 20:41:05 +0300 Message-ID: <83injuzf4e.fsf@gnu.org> References: <83lgoqzm0v.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1497721327 28676 195.159.176.226 (17 Jun 2017 17:42:07 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 17 Jun 2017 17:42:07 +0000 (UTC) Cc: emacs-devel@gnu.org To: Kaushal Modi Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Jun 17 19:42:01 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 1dMHjT-00071z-6T for ged-emacs-devel@m.gmane.org; Sat, 17 Jun 2017 19:41:59 +0200 Original-Received: from localhost ([::1]:35839 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMHjY-0000qT-K5 for ged-emacs-devel@m.gmane.org; Sat, 17 Jun 2017 13:42:04 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34264) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMHiv-0000qO-OH for emacs-devel@gnu.org; Sat, 17 Jun 2017 13:41:26 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dMHis-0000yy-Jb for emacs-devel@gnu.org; Sat, 17 Jun 2017 13:41:25 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:44093) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMHis-0000yu-Fi; Sat, 17 Jun 2017 13:41:22 -0400 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:2398 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1dMHiq-0001iu-NQ; Sat, 17 Jun 2017 13:41:22 -0400 In-reply-to: (message from Kaushal Modi on Sat, 17 Jun 2017 16:52:11 +0000) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e 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:215706 Archived-At: > From: Kaushal Modi > Date: Sat, 17 Jun 2017 16:52:11 +0000 > > . 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. nlinum performed so poorly in my benchmarks that I was ashamed of publishing the data. The benchmark entails scrolling through xdisp.c one line at a time. The code is at the end of this message (it was posted by Dmitry Antipov), you can try it yourself. The first run is always slow because Emacs fontifies on the fly, so I timed only the second run. > 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 could add this feature if it's deemed important, but it will slow down redisplay to some extent, because cursor motion can no longer be considered affecting the cursor alone. > 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. The menu bar is for simple uses, I see no reason to put all the complexity of a defcustom on the menu bar. > 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? Minor mode is probably due anyway, but that is independent of the menu bar. Anyway, these are simple things that can always be fixed later. If those are the only issues with this new feature, then I'm very lucky (yeah, right). Thanks for taking time to try the branch. ====================================================================== (defun scroll-up-benchmark () (interactive) (let ((oldgc gcs-done) (oldtime (float-time))) (condition-case nil (while t (scroll-up) (redisplay)) (error (message "GCs: %d Elapsed time: %f seconds" (- gcs-done oldgc) (- (float-time) oldtime))))))