GNU bug report logs - #42839
[PATCH] Support displaying line numbers in goto-line

Previous Next

Package: emacs;

Reported by: Stefan Kangas <stefan <at> marxist.se>

Date: Thu, 13 Aug 2020 06:31:01 UTC

Severity: normal

Tags: patch

Done: Stefan Kangas <stefan <at> marxist.se>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 42839 in the body.
You can then email your comments to 42839 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#42839; Package emacs. (Thu, 13 Aug 2020 06:31:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stefan Kangas <stefan <at> marxist.se>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 13 Aug 2020 06:31:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefan <at> marxist.se>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] Support displaying line numbers in goto-line
Date: Wed, 12 Aug 2020 23:30:42 -0700
[Message part 1 (text/plain, inline)]
Here's an interesting idea I picked up from Reddit: make goto-line
enable display-line-numbers-mode temporarily when prompting.  Please see
the attached patch.

Comments or thoughts welcome, as always.

Best regards,
Stefan Kangas

PS. I added a new defcustom to enable this behaviour, by default set to
    nil.  But if it seems useful, it would be nifty if we could enable
    it by default.  (I have no idea if display-line-numbers-mode is
    stable enough in all scenarios, however.)
[0001-Support-displaying-line-numbers-in-goto-line.patch (text/x-diff, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#42839; Package emacs. (Thu, 13 Aug 2020 08:31:02 GMT) Full text and rfc822 format available.

Message #8 received at 42839 <at> debbugs.gnu.org (full text, mbox):

From: Robert Pluim <rpluim <at> gmail.com>
To: Stefan Kangas <stefan <at> marxist.se>
Cc: 42839 <at> debbugs.gnu.org
Subject: Re: bug#42839: [PATCH] Support displaying line numbers in goto-line
Date: Thu, 13 Aug 2020 10:30:01 +0200
>>>>> On Wed, 12 Aug 2020 23:30:42 -0700, Stefan Kangas <stefan <at> marxist.se> said:

    Stefan> Here's an interesting idea I picked up from Reddit: make goto-line
    Stefan> enable display-line-numbers-mode temporarily when prompting.  Please see
    Stefan> the attached patch.

    Stefan> Comments or thoughts welcome, as always.

Hmm, if the line youʼre going to is visible, why would
you need goto-line to show line numbers? For that matter, why not just
move to the line using other motion commands?

And if itʼs not visible, what does showing line numbers for the lines
that are visible get you?

You'd have to add some interactive 'scroll window to show target line'
functionality, I think.

Robert




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#42839; Package emacs. (Thu, 13 Aug 2020 08:59:01 GMT) Full text and rfc822 format available.

Message #11 received at 42839 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefan <at> marxist.se>
To: Robert Pluim <rpluim <at> gmail.com>
Cc: 42839 <at> debbugs.gnu.org
Subject: Re: bug#42839: [PATCH] Support displaying line numbers in goto-line
Date: Thu, 13 Aug 2020 01:58:41 -0700
Robert Pluim <rpluim <at> gmail.com> writes:

>>>>>> On Wed, 12 Aug 2020 23:30:42 -0700, Stefan Kangas <stefan <at> marxist.se> said:
>
>     Stefan> Here's an interesting idea I picked up from Reddit: make goto-line
>     Stefan> enable display-line-numbers-mode temporarily when prompting.  Please see
>     Stefan> the attached patch.
>
>     Stefan> Comments or thoughts welcome, as always.
>
> Hmm, if the line youʼre going to is visible, why would
> you need goto-line to show line numbers?

Well, I don't always know the line number of every line in my window.

> For that matter, why not just move to the line using other motion
> commands?

I personally use `goto-line' only when I have a specific line number
that I want to go to.  It is true that there are other movement
commands that are often better to use.

> And if itʼs not visible, what does showing line numbers for the lines
> that are visible get you?

It serves as a reminder of where you're at before you leave.

> You'd have to add some interactive 'scroll window to show target line'
> functionality, I think.

Good idea, thanks.  Maybe I should look into that.

Best regards,
Stefan Kangas




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#42839; Package emacs. (Thu, 13 Aug 2020 09:17:02 GMT) Full text and rfc822 format available.

Message #14 received at 42839 <at> debbugs.gnu.org (full text, mbox):

From: Robert Pluim <rpluim <at> gmail.com>
To: Stefan Kangas <stefan <at> marxist.se>
Cc: 42839 <at> debbugs.gnu.org
Subject: Re: bug#42839: [PATCH] Support displaying line numbers in goto-line
Date: Thu, 13 Aug 2020 11:16:37 +0200
>>>>> On Thu, 13 Aug 2020 01:58:41 -0700, Stefan Kangas <stefan <at> marxist.se> said:

    Stefan> Well, I don't always know the line number of every line in my window.

Neither do I, but if Iʼm going to a specific number that doesnʼt
matter.

    >> For that matter, why not just move to the line using other motion
    >> commands?

    Stefan> I personally use `goto-line' only when I have a specific line number
    Stefan> that I want to go to.  It is true that there are other movement
    Stefan> commands that are often better to use.

    >> And if itʼs not visible, what does showing line numbers for the lines
    >> that are visible get you?

    Stefan> It serves as a reminder of where you're at before you leave.

`goto-line' sets the mark, so thatʼs only a 'C-u C-SPC' away.

Robert




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#42839; Package emacs. (Thu, 13 Aug 2020 13:11:02 GMT) Full text and rfc822 format available.

Message #17 received at 42839 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Kangas <stefan <at> marxist.se>
Cc: 42839 <at> debbugs.gnu.org
Subject: Re: bug#42839: [PATCH] Support displaying line numbers in goto-line
Date: Thu, 13 Aug 2020 16:10:26 +0300
> From: Stefan Kangas <stefan <at> marxist.se>
> Date: Wed, 12 Aug 2020 23:30:42 -0700
> 
> +       (let ((showing display-line-numbers))
> +         (unwind-protect
> +             (progn
> +               (when (not showing)
> +                 (display-line-numbers-mode 1))
> +               (list (read-number (format "Goto line%s: " buffer-prompt)
> +                                  (list default (line-number-at-pos))
> +                                  'goto-line-history)
> +	             buffer))
> +           (when (not showing)
> +             (display-line-numbers-mode -1)))))))

The variable display-line-numbers is not a simple boolean, it can have
several values.  I think you intended to show absolute line numbers in
this case, so just testing whether display-line-numbers is non-nil is
not enough.  Similarly, restoring the original setting needs more than
just a call to display-line-numbers-mode.

And this needs a NEWS entry.

Other than that, if someone wants this optional feature, why not?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#42839; Package emacs. (Thu, 13 Aug 2020 13:19:01 GMT) Full text and rfc822 format available.

Message #20 received at 42839 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Robert Pluim <rpluim <at> gmail.com>
Cc: 42839 <at> debbugs.gnu.org, stefan <at> marxist.se
Subject: Re: bug#42839: [PATCH] Support displaying line numbers in goto-line
Date: Thu, 13 Aug 2020 16:17:57 +0300
> From: Robert Pluim <rpluim <at> gmail.com>
> Date: Thu, 13 Aug 2020 10:30:01 +0200
> Cc: 42839 <at> debbugs.gnu.org
> 
> And if itʼs not visible, what does showing line numbers for the lines
> that are visible get you?

You can make it visible with the likes of "C-M-v".




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#42839; Package emacs. (Thu, 13 Aug 2020 13:25:02 GMT) Full text and rfc822 format available.

Message #23 received at 42839 <at> debbugs.gnu.org (full text, mbox):

From: Robert Pluim <rpluim <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 42839 <at> debbugs.gnu.org, stefan <at> marxist.se
Subject: Re: bug#42839: [PATCH] Support displaying line numbers in goto-line
Date: Thu, 13 Aug 2020 15:24:11 +0200
>>>>> On Thu, 13 Aug 2020 16:17:57 +0300, Eli Zaretskii <eliz <at> gnu.org> said:

    >> From: Robert Pluim <rpluim <at> gmail.com>
    >> Date: Thu, 13 Aug 2020 10:30:01 +0200
    >> Cc: 42839 <at> debbugs.gnu.org
    >> 
    >> And if itʼs not visible, what does showing line numbers for the lines
    >> that are visible get you?

    Eli> You can make it visible with the likes of "C-M-v".

Yes, if itʼs not too far away, in which case that would be tedious
(and entering the line number as an arg to C-M-v means typing it
twice).

Robert




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#42839; Package emacs. (Thu, 13 Aug 2020 14:31:02 GMT) Full text and rfc822 format available.

Message #26 received at 42839 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefan <at> marxist.se>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 42839 <at> debbugs.gnu.org
Subject: Re: bug#42839: [PATCH] Support displaying line numbers in goto-line
Date: Thu, 13 Aug 2020 07:30:40 -0700
Eli Zaretskii <eliz <at> gnu.org> writes:

> The variable display-line-numbers is not a simple boolean, it can have
> several values.  I think you intended to show absolute line numbers in
> this case, so just testing whether display-line-numbers is non-nil is
> not enough.  Similarly, restoring the original setting needs more than
> just a call to display-line-numbers-mode.

Right, you are completely correct of course.  I suppose we would also
have to consider that the user might have nlinum, linum, and possibly
other conflicting modes activated.

I should have been more clear that this was more a proof of concept to
see if the idea would fly.

> And this needs a NEWS entry.

Yup.

> Other than that, if someone wants this optional feature, why not?

Thanks.

Best regards,
Stefan Kangas




Reply sent to Stefan Kangas <stefan <at> marxist.se>:
You have taken responsibility. (Fri, 09 Oct 2020 21:23:01 GMT) Full text and rfc822 format available.

Notification sent to Stefan Kangas <stefan <at> marxist.se>:
bug acknowledged by developer. (Fri, 09 Oct 2020 21:23:01 GMT) Full text and rfc822 format available.

Message #31 received at 42839-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefan <at> marxist.se>
To: 42839-done <at> debbugs.gnu.org
Subject: Re: bug#42839: [PATCH] Support displaying line numbers in goto-line
Date: Fri, 9 Oct 2020 21:22:47 +0000
Stefan Kangas <stefan <at> marxist.se> writes:

> Here's an interesting idea I picked up from Reddit: make goto-line
> enable display-line-numbers-mode temporarily when prompting.  Please see
> the attached patch.
>
> Comments or thoughts welcome, as always.

There were no massive enthusiasm for this idea, and I sort of lost
interest.  It would need some more work, and there are obviously many
other areas where time could be usefully spent.  So I'm closing this bug
for now.

Thanks to Robert and Eli who contributed their thoughts.  Hopefully we
will be able to dig up this thread if we ever return to this idea in the
future.

PS. If anyone wants to pick up the ball, they should feel free to do so.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 07 Nov 2020 12:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 160 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.