aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFederico Tedin2019-12-24 17:38:19 +0100
committerLars Ingebrigtsen2019-12-24 17:40:15 +0100
commit7c5d6a2afc6c23a7fff8456f506ee2aa2d37a3b9 (patch)
treee870880eba7be66662614f8e0efa7d13b208ba5f
parent0d2a711dc9a65dc8eb6e995369e70cddbcd7d9a4 (diff)
downloademacs-7c5d6a2afc6c23a7fff8456f506ee2aa2d37a3b9.tar.gz
emacs-7c5d6a2afc6c23a7fff8456f506ee2aa2d37a3b9.zip
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.
-rw-r--r--doc/lispref/minibuf.texi9
-rw-r--r--etc/NEWS11
-rw-r--r--lisp/simple.el7
-rw-r--r--lisp/subr.el9
4 files changed, 33 insertions, 3 deletions
diff --git a/doc/lispref/minibuf.texi b/doc/lispref/minibuf.texi
index dde30ce67f7..2c2ef9747b4 100644
--- a/doc/lispref/minibuf.texi
+++ b/doc/lispref/minibuf.texi
@@ -645,6 +645,15 @@ A history list for variable-name arguments read by
645@code{read-variable}. 645@code{read-variable}.
646@end defvar 646@end defvar
647 647
648@defvar read-number-history
649A history list for numbers read by @code{read-number}.
650@end defvar
651
652@defvar goto-line-history
653A history list for arguments to @code{goto-line}. This variable is
654buffer local.
655@end defvar
656
648@c Less common: coding-system-history, input-method-history, 657@c Less common: coding-system-history, input-method-history,
649@c command-history, grep-history, grep-find-history, 658@c command-history, grep-history, grep-find-history,
650@c read-envvar-name-history, setenv-history, yes-or-no-p-history. 659@c read-envvar-name-history, setenv-history, yes-or-no-p-history.
diff --git a/etc/NEWS b/etc/NEWS
index 9b60fc49538..dd339507c77 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -65,6 +65,17 @@ GNU General Public License for more details.
65You should have received a copy of the GNU General Public License 65You should have received a copy of the GNU General Public License
66along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. 66along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
67 67
68+++
69** 'read-number' now has its own history variable.
70Additionally, the function now accepts a HIST argument which can be
71used to specify a custom history variable.
72
73+++
74** Input history for 'goto-line' is now local to every buffer.
75Each buffer will keep a separate history of line numbers used with
76'goto-line'. This should help making faster the process of finding
77line numbers that were previously jumped to.
78
68 79
69Local variables: 80Local variables:
70coding: utf-8 81coding: utf-8
diff --git a/lisp/simple.el b/lisp/simple.el
index 6d5030073bb..6219986da0f 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -1212,6 +1212,10 @@ that uses or sets the mark."
1212 1212
1213;; Counting lines, one way or another. 1213;; Counting lines, one way or another.
1214 1214
1215(defvar goto-line-history nil
1216 "History of values entered with `goto-line'.")
1217(make-variable-buffer-local 'goto-line-history)
1218
1215(defun goto-line (line &optional buffer) 1219(defun goto-line (line &optional buffer)
1216 "Go to LINE, counting from line 1 at beginning of buffer. 1220 "Go to LINE, counting from line 1 at beginning of buffer.
1217If called interactively, a numeric prefix argument specifies 1221If called interactively, a numeric prefix argument specifies
@@ -1256,7 +1260,8 @@ rather than line counts."
1256 ""))) 1260 "")))
1257 ;; Read the argument, offering that number (if any) as default. 1261 ;; Read the argument, offering that number (if any) as default.
1258 (list (read-number (format "Goto line%s: " buffer-prompt) 1262 (list (read-number (format "Goto line%s: " buffer-prompt)
1259 (list default (line-number-at-pos))) 1263 (list default (line-number-at-pos))
1264 'goto-line-history)
1260 buffer)))) 1265 buffer))))
1261 ;; Switch to the desired buffer, one way or another. 1266 ;; Switch to the desired buffer, one way or another.
1262 (if buffer 1267 (if buffer
diff --git a/lisp/subr.el b/lisp/subr.el
index ed55853bb27..f5b7c98f50d 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -2518,10 +2518,15 @@ by doing (clear-string STRING)."
2518 ;; And of course, don't keep the sensitive data around. 2518 ;; And of course, don't keep the sensitive data around.
2519 (erase-buffer)))))))) 2519 (erase-buffer))))))))
2520 2520
2521(defun read-number (prompt &optional default) 2521(defvar read-number-history nil
2522 "The default history for the `read-number' function.")
2523
2524(defun read-number (prompt &optional default hist)
2522 "Read a numeric value in the minibuffer, prompting with PROMPT. 2525 "Read a numeric value in the minibuffer, prompting with PROMPT.
2523DEFAULT specifies a default value to return if the user just types RET. 2526DEFAULT specifies a default value to return if the user just types RET.
2524The value of DEFAULT is inserted into PROMPT. 2527The value of DEFAULT is inserted into PROMPT.
2528HIST specifies a history list variable. See `read-from-minibuffer'
2529for details of the HIST argument.
2525This function is used by the `interactive' code letter `n'." 2530This function is used by the `interactive' code letter `n'."
2526 (let ((n nil) 2531 (let ((n nil)
2527 (default1 (if (consp default) (car default) default))) 2532 (default1 (if (consp default) (car default) default)))
@@ -2535,7 +2540,7 @@ This function is used by the `interactive' code letter `n'."
2535 (while 2540 (while
2536 (progn 2541 (progn
2537 (let ((str (read-from-minibuffer 2542 (let ((str (read-from-minibuffer
2538 prompt nil nil nil nil 2543 prompt nil nil nil (or hist 'read-number-history)
2539 (when default 2544 (when default
2540 (if (consp default) 2545 (if (consp default)
2541 (mapcar 'number-to-string (delq nil default)) 2546 (mapcar 'number-to-string (delq nil default))