Subject: bug#42839: closed (Re: bug#42839: [PATCH] Support displaying line numbers in goto-line)

From: [email-masked] (GNU bug Tracking System)
Date: Fri, 09 Oct 2020 21:23:01 +0000

Your bug report

#42839: [PATCH] Support displaying line numbers in goto-line

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
42839: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=42839
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#42839: [PATCH] Support displaying line numbers in goto-line
From: Stefan Kangas <[email-masked]>
To: [email-masked]
Date: Fri, 9 Oct 2020 21:22:47 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

Stefan Kangas <[email-masked]> 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.

Subject: [PATCH] Support displaying line numbers in goto-line
From: Stefan Kangas <[email-masked]>
To: [email-masked]
Date: Wed, 12 Aug 2020 23:30:42 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

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.)
From 97a45a3fc4765b3b36d8df3df2c5d43505cbece9 Mon Sep 17 00:00:00 2001
From: Stefan Kangas <[email-masked]>
Date: Thu, 13 Aug 2020 08:19:42 +0200
Subject: [PATCH] Support displaying line numbers in goto-line

* lisp/simple.el (goto-line): Support temporarily enabling
display-line-numbers-mode when prompting.
(goto-line-display-line-numbers): New defcustom to enable this new
behaviour.
---
 lisp/simple.el | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/lisp/simple.el b/lisp/simple.el
index 6f72c3b81b..8766a194e1 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -1227,6 +1227,12 @@ mark-whole-buffer
 
 ;; Counting lines, one way or another.
 
+(defcustom goto-line-display-line-numbers nil
+  "If non-nil, `goto-line' temporarily displays line numbers."
+  :type 'boolean
+  :version "28.1"
+  :group 'editing-basics)
+
 (defvar goto-line-history nil
   "History of values entered with `goto-line'.")
 (make-variable-buffer-local 'goto-line-history)
@@ -1274,10 +1280,17 @@ goto-line
 		 (concat " in " (buffer-name buffer))
 	       "")))
        ;; Read the argument, offering that number (if any) as default.
-       (list (read-number (format "Goto line%s: " buffer-prompt)
-                          (list default (line-number-at-pos))
-                          'goto-line-history)
-	     buffer))))
+       (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)))))))
   ;; Switch to the desired buffer, one way or another.
   (if buffer
       (let ((window (get-buffer-window buffer)))
-- 
2.28.0