emacs-devel
[Top][All Lists]
Advanced

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

Re: Display window line numbers


From: João Paulo Labegalini de Carvalho
Subject: Re: Display window line numbers
Date: Tue, 6 Dec 2022 11:04:02 -0700

Juri,

You could set `display-line-numbers' to 'absolute and run code below every time the window is scrolled up/down (e.g. with a hook):

(save-excursion
  (move-to-window-line 0)
  (setq display-line-numbers-offset
           (* -1
              (line-number-at-pos))))

Notice that if `display-line-numbers' is 'absolute and narrowing is enabled, you already get your desired behaviour.


On Tue, Dec 6, 2022 at 10:28 AM Juri Linkov <juri@linkov.net> wrote:
I wonder why ‘display-line-numbers’ doesn't provide an option
to display line numbers relative to the window-start?
IMHO, one of the most reasonable excuses to sacrifice the screen space
for line numbers is to display only these short numbers that could be
used to jump to a line visible on the screen.  For that the quickest
key sequence is e.g. 'M-5 M-r'.

Then all possibilities will be covered by these options of
‘display-line-numbers’:

- absolute line numbers can be used by 'M-g M-g' (goto-line);
- relative line numbers - by 'C-u N C-n' and 'C-u N C-p';
- window line numbers - by 'M-r'.



--
João Paulo L. de Carvalho
Ph.D Computer Science |  IC-UNICAMP | Campinas , SP - Brazil
Postdoctoral Research Fellow | University of Alberta | Edmonton, AB - Canada
joao.carvalho@ic.unicamp.br
joao.carvalho@ualberta.ca

reply via email to

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