unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "João Paulo Labegalini de Carvalho" <jaopaulolc@gmail.com>
To: Juri Linkov <juri@linkov.net>
Cc: emacs-devel@gnu.org
Subject: Re: Display window line numbers
Date: Tue, 6 Dec 2022 11:04:02 -0700	[thread overview]
Message-ID: <CAGjvy297GM4t_5cOHJ3n1d4yTEX8DMV=6a6F8P8NAb4wu8A6Fw@mail.gmail.com> (raw)
In-Reply-To: <86tu2apdio.fsf@mail.linkov.net>

[-- 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 --]

  reply	other threads:[~2022-12-06 18:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-06 17:10 Display window line numbers Juri Linkov
2022-12-06 18:04 ` João Paulo Labegalini de Carvalho [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAGjvy297GM4t_5cOHJ3n1d4yTEX8DMV=6a6F8P8NAb4wu8A6Fw@mail.gmail.com' \
    --to=jaopaulolc@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=juri@linkov.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).