all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Display window line numbers
@ 2022-12-06 17:10 Juri Linkov
  2022-12-06 18:04 ` João Paulo Labegalini de Carvalho
  2022-12-06 18:14 ` Eli Zaretskii
  0 siblings, 2 replies; 6+ messages in thread
From: Juri Linkov @ 2022-12-06 17:10 UTC (permalink / raw)
  To: emacs-devel

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



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Display window line numbers
  2022-12-06 17:10 Display window line numbers Juri Linkov
@ 2022-12-06 18:04 ` João Paulo Labegalini de Carvalho
  2022-12-06 18:43   ` Juri Linkov
  2022-12-06 18:14 ` Eli Zaretskii
  1 sibling, 1 reply; 6+ messages in thread
From: João Paulo Labegalini de Carvalho @ 2022-12-06 18:04 UTC (permalink / raw)
  To: Juri Linkov; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1358 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 2365 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Display window line numbers
  2022-12-06 17:10 Display window line numbers Juri Linkov
  2022-12-06 18:04 ` João Paulo Labegalini de Carvalho
@ 2022-12-06 18:14 ` Eli Zaretskii
  2022-12-06 18:44   ` Juri Linkov
  1 sibling, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2022-12-06 18:14 UTC (permalink / raw)
  To: Juri Linkov; +Cc: emacs-devel

> From: Juri Linkov <juri@linkov.net>
> Date: Tue, 06 Dec 2022 19:10:43 +0200
> 
> I wonder why ‘display-line-numbers’ doesn't provide an option
> to display line numbers relative to the window-start?

Because no one asked for it.

And I don't really see the importance, FWIW: why isn't the 'visual' variety
not what you want?  Then "C-u N C-p" and "C-u n C-n" will do what you want.

What am I missing?

> - relative line numbers - by 'C-u N C-n' and 'C-u N C-p';

This is only true if you turn off line-move-visual.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Display window line numbers
  2022-12-06 18:04 ` João Paulo Labegalini de Carvalho
@ 2022-12-06 18:43   ` Juri Linkov
  0 siblings, 0 replies; 6+ messages in thread
From: Juri Linkov @ 2022-12-06 18:43 UTC (permalink / raw)
  To: João Paulo Labegalini de Carvalho; +Cc: emacs-devel

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

Thanks, adding this to `window-scroll-functions' displays correct
line numbers.  But only when the same buffer is not displayed
in two windows.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Display window line numbers
  2022-12-06 18:14 ` Eli Zaretskii
@ 2022-12-06 18:44   ` Juri Linkov
  2022-12-06 18:53     ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Juri Linkov @ 2022-12-06 18:44 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

>> I wonder why ‘display-line-numbers’ doesn't provide an option
>> to display line numbers relative to the window-start?
>
> Because no one asked for it.
>
> And I don't really see the importance, FWIW: why isn't the 'visual' variety
> not what you want?  Then "C-u N C-p" and "C-u n C-n" will do what you want.
>
> What am I missing?

`M-N M-p' is easy to type, and also it's easier to read numbers incrementally
going from top to bottom, not in reverse order as 'visual' does for lines
before the current line.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Display window line numbers
  2022-12-06 18:44   ` Juri Linkov
@ 2022-12-06 18:53     ` Eli Zaretskii
  0 siblings, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2022-12-06 18:53 UTC (permalink / raw)
  To: Juri Linkov; +Cc: emacs-devel

> From: Juri Linkov <juri@linkov.net>
> Cc: emacs-devel@gnu.org
> Date: Tue, 06 Dec 2022 20:44:44 +0200
> 
> > And I don't really see the importance, FWIW: why isn't the 'visual' variety
> > not what you want?  Then "C-u N C-p" and "C-u n C-n" will do what you want.
> >
> > What am I missing?
> 
> `M-N M-p' is easy to type

So is "C-3 C-p" or "C-5 C-n".

> and also it's easier to read numbers incrementally going from top to
> bottom, not in reverse order as 'visual' does for lines before the current
> line.

Very strange to hear that.  Line addressing was always relative to the
current line, back when editors needed that.



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-12-06 18:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-06 17:10 Display window line numbers Juri Linkov
2022-12-06 18:04 ` João Paulo Labegalini de Carvalho
2022-12-06 18:43   ` Juri Linkov
2022-12-06 18:14 ` Eli Zaretskii
2022-12-06 18:44   ` Juri Linkov
2022-12-06 18:53     ` Eli Zaretskii

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.