aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorFederico Tedin2019-12-24 17:38:19 +0100
committerLars Ingebrigtsen2019-12-24 17:40:15 +0100
commit7c5d6a2afc6c23a7fff8456f506ee2aa2d37a3b9 (patch)
treee870880eba7be66662614f8e0efa7d13b208ba5f /lisp
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.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/simple.el7
-rw-r--r--lisp/subr.el9
2 files changed, 13 insertions, 3 deletions
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))