From: Federico Tedin <federicotedin@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: larsi@gnus.org, 38282@debbugs.gnu.org
Subject: bug#38282: 26.3; goto-line should not share input history with other commands
Date: Tue, 17 Dec 2019 22:19:44 +0100 [thread overview]
Message-ID: <87mubqabv3.fsf@gmail.com> (raw)
In-Reply-To: <837e2z6si5.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 14 Dec 2019 13:44:50 +0200")
[-- Attachment #1: Type: text/plain, Size: 273 bytes --]
> Thanks, I think this variable should be mentioned in the ELisp manual
> (in the "Minibuffer History" node) and in NEWS.
Sorry, forgot to do that. I've now documented both new variables (the
one for `read-number' and the one for `goto-line'). I'm attaching a new
patch.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 4406 bytes --]
From 67e2d243473c52c1b52102203cf069dbed4165cc Mon Sep 17 00:00:00 2001
From: Federico Tedin <federicotedin@gmail.com>
Date: Tue, 17 Dec 2019 22:13:55 +0100
Subject: [PATCH 1/1] Make goto-line keep a separate input history per buffer
* lisp/simple.el (goto-line-history): New history variable.
(goto-line): Use new (buffer-local) variable as input
history (Bug#38282).
* lisp/subr.el (read-number-history): New history variable.
(read-number): Use the new variable as default input history.
* doc/lispref/minibuf.texi (Minibuffer History): Document
read-number-history and goto-line-history variables.
* etc/NEWS: Announce changes.
---
doc/lispref/minibuf.texi | 9 +++++++++
etc/NEWS | 11 +++++++++++
lisp/simple.el | 7 ++++++-
lisp/subr.el | 9 +++++++--
4 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/doc/lispref/minibuf.texi b/doc/lispref/minibuf.texi
index dde30ce67f..2c2ef9747b 100644
--- a/doc/lispref/minibuf.texi
+++ b/doc/lispref/minibuf.texi
@@ -645,6 +645,15 @@ Minibuffer History
@code{read-variable}.
@end defvar
+@defvar read-number-history
+A history list for numbers read by @code{read-number}.
+@end defvar
+
+@defvar goto-line-history
+A history list for arguments to @code{goto-line}. This variable is
+buffer local.
+@end defvar
+
@c Less common: coding-system-history, input-method-history,
@c command-history, grep-history, grep-find-history,
@c read-envvar-name-history, setenv-history, yes-or-no-p-history.
diff --git a/etc/NEWS b/etc/NEWS
index cf4e705a52..dc17445757 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -533,6 +533,17 @@ The HIST argument of 'read-from-minibuffer' now works correctly with
buffer-local variables. This means that different buffers can have
their own separated input history list if desired.
++++
+** 'read-number' now has its own history variable.
+Additionally, the function now accepts a HIST argument which can be
+used to specify a custom history variable.
+
++++
+** Input history for 'goto-line' is now local to every buffer.
+Each buffer will keep a separate history of line numbers used with
+'goto-line'. This should help making faster the process of finding
+line numbers that were previously jumped to.
+
\f
* Editing Changes in Emacs 27.1
diff --git a/lisp/simple.el b/lisp/simple.el
index 6d5030073b..6219986da0 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -1212,6 +1212,10 @@ mark-whole-buffer
;; Counting lines, one way or another.
+(defvar goto-line-history nil
+ "History of values entered with `goto-line'.")
+(make-variable-buffer-local 'goto-line-history)
+
(defun goto-line (line &optional buffer)
"Go to LINE, counting from line 1 at beginning of buffer.
If called interactively, a numeric prefix argument specifies
@@ -1256,7 +1260,8 @@ goto-line
"")))
;; 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)))
+ (list default (line-number-at-pos))
+ 'goto-line-history)
buffer))))
;; Switch to the desired buffer, one way or another.
(if buffer
diff --git a/lisp/subr.el b/lisp/subr.el
index ed55853bb2..f5b7c98f50 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -2518,10 +2518,15 @@ read-passwd
;; And of course, don't keep the sensitive data around.
(erase-buffer))))))))
-(defun read-number (prompt &optional default)
+(defvar read-number-history nil
+ "The default history for the `read-number' function.")
+
+(defun read-number (prompt &optional default hist)
"Read a numeric value in the minibuffer, prompting with PROMPT.
DEFAULT specifies a default value to return if the user just types RET.
The value of DEFAULT is inserted into PROMPT.
+HIST specifies a history list variable. See `read-from-minibuffer'
+for details of the HIST argument.
This function is used by the `interactive' code letter `n'."
(let ((n nil)
(default1 (if (consp default) (car default) default)))
@@ -2535,7 +2540,7 @@ read-number
(while
(progn
(let ((str (read-from-minibuffer
- prompt nil nil nil nil
+ prompt nil nil nil (or hist 'read-number-history)
(when default
(if (consp default)
(mapcar 'number-to-string (delq nil default))
--
2.17.1
next prev parent reply other threads:[~2019-12-17 21:19 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-19 21:48 bug#38282: 26.3; goto-line should not share input history with other commands Federico Tedin
2019-11-21 13:51 ` Lars Ingebrigtsen
2019-11-21 14:41 ` Robert Pluim
2019-11-21 15:20 ` Michael Albinus
2019-11-21 17:51 ` Lars Ingebrigtsen
2019-11-21 18:43 ` Federico Tedin
2019-11-21 22:06 ` Federico Tedin
2019-11-22 7:35 ` Eli Zaretskii
2019-11-22 12:09 ` Lars Ingebrigtsen
2019-11-23 17:05 ` Federico Tedin
2019-11-27 11:48 ` Lars Ingebrigtsen
2019-12-06 22:14 ` Federico Tedin
2019-12-14 11:44 ` Eli Zaretskii
2019-12-17 21:19 ` Federico Tedin [this message]
2019-12-24 16:39 ` Lars Ingebrigtsen
2019-12-24 23:21 ` Federico Tedin
2019-11-22 7:57 ` Michael Albinus
2019-11-22 8:40 ` Robert Pluim
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87mubqabv3.fsf@gmail.com \
--to=federicotedin@gmail.com \
--cc=38282@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=larsi@gnus.org \
/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 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.