From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Jo=C3=A3o_Paulo_Labegalini_de_Carvalho?= Newsgroups: gmane.emacs.devel Subject: Re: Display window line numbers Date: Tue, 6 Dec 2022 11:04:02 -0700 Message-ID: References: <86tu2apdio.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000aae02905ef2ca18d" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7533"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Juri Linkov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Dec 06 19:05:11 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p2cJb-0001cE-Fb for ged-emacs-devel@m.gmane-mx.org; Tue, 06 Dec 2022 19:05:11 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p2cIr-0006eS-KK; Tue, 06 Dec 2022 13:04:25 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p2cIk-0006Zu-MA for emacs-devel@gnu.org; Tue, 06 Dec 2022 13:04:18 -0500 Original-Received: from mail-ed1-x52c.google.com ([2a00:1450:4864:20::52c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p2cIi-0000wP-7O for emacs-devel@gnu.org; Tue, 06 Dec 2022 13:04:18 -0500 Original-Received: by mail-ed1-x52c.google.com with SMTP id c17so12872080edj.13 for ; Tue, 06 Dec 2022 10:04:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=GDosJqu/jev8hX9GPQ8BFBvvv/li1UUbjeOvOF7i7AY=; b=UHgeNk/6MiWSV/cnCQe3YXOvwQgOFgFeGfu9mO2AwZf8tJ0nb6ODBvV1U669xp6B8E dI1dA9vXgwASuqVguYiZUAvR79TgeQ0+Z5GDF2biTe3mEY45MjKdSpmVxfiw5Q20A/6R ZQ1sT+Kq7NGWb7OOdq1d9MC7R/TaAf9GqfHSq+HUHshKHTa/dolscozpiGJFyXstmbcV 23JpQlZWG94ugpQbp2ZhtAkLWbn3Ycg69C57YUTiBy3rTvlOFVdmjGdQ/ulI5x3dBNUm 8bHi0GawigvgqBG8is8whHYRJ8NPpmLhe2xUn5w7ZteNNqz6f/tg5e30pP4vAdl5DCWm QVdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=GDosJqu/jev8hX9GPQ8BFBvvv/li1UUbjeOvOF7i7AY=; b=yTJVL/FzMW4FxkWSegoPLA0w8v822wdOai7NAYRYioULjezjSfVH29iKlrzMmMsGGl 1eqRopIBBVhwHE4yq1nGjw4MPiaeHgUSAZ5jnXAxd+7vYLEdQ1GoQCgV+eSZgWkVkwO4 S4qpaSJ9a+zgUxS7xzW5XookUIivjF8C/Qhs6z6vcWsPQfEZt30XLk2sayo48sizr4zZ 03Cbc1YREIShmnORBBtDEDVsoSape/TugUerGWCba4z3GnaDNHazi9sSp6aIo0yb/XhI aZMo7Qnn060wV1+yitpm2yolznOR7zjoVvCe3nu0TlOg5rEwbROCk71h191odESJlECH lMaQ== X-Gm-Message-State: ANoB5pk0Epz7fSvqB1rUAm/Buu1xgurxUw9SDdhkPjiD7rGL4wGVJZRF hiAY8LDdh928zx0ql4MY6gNiRa+47zNLLQ8y1zE= X-Google-Smtp-Source: AA0mqf7H7/3FVBGoHjk40P3b77qnqcob29YkXHn13om2D5R4ajjroOyPOgrMrYkvHkPKr3iZ3rrNtpqaBS9XOdk3MNo= X-Received: by 2002:a05:6402:3808:b0:468:c911:d843 with SMTP id es8-20020a056402380800b00468c911d843mr79285696edb.422.1670349853481; Tue, 06 Dec 2022 10:04:13 -0800 (PST) In-Reply-To: <86tu2apdio.fsf@mail.linkov.net> Received-SPF: pass client-ip=2a00:1450:4864:20::52c; envelope-from=jaopaulolc@gmail.com; helo=mail-ed1-x52c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:300975 Archived-At: --000000000000aae02905ef2ca18d Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 wrote: > I wonder why =E2=80=98display-line-numbers=E2=80=99 doesn't provide an op= tion > 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 > =E2=80=98display-line-numbers=E2=80=99: > > - 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'. > > --=20 Jo=C3=A3o Paulo L. de Carvalho Ph.D Computer Science | IC-UNICAMP | Campinas , SP - Brazil Postdoctoral Research Fellow | University of Alberta | Edmonton, AB - Canad= a joao.carvalho@ic.unicamp.br joao.carvalho@ualberta.ca --000000000000aae02905ef2ca18d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Juri,

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

(save-excursion
=C2=A0= (move-to-window-line 0)
=C2=A0 (= setq display-line-numbers-offset
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(* -1
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (line-numbe= r-at-pos))))

Notice that if `display-line-numbers' is = 9;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 =E2=80=98dis= play-line-numbers=E2=80=99 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.=C2=A0 For that the quickest key sequence is e.g. 'M-5 M-r'.

Then all possibilities will be covered by these options of
=E2=80=98display-line-numbers=E2=80=99:

- 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= =C3=A3o Paulo L. de Carvalho
Ph.D Computer Science | =C2=A0IC-UNICAMP | = Campinas , SP - Brazil
Postdoctoral Research Fellow | University of Albe= rta | Edmonton, AB - Canada
--000000000000aae02905ef2ca18d--