diff options
| author | Federico Tedin | 2019-12-24 17:38:19 +0100 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2019-12-24 17:40:15 +0100 |
| commit | 7c5d6a2afc6c23a7fff8456f506ee2aa2d37a3b9 (patch) | |
| tree | e870880eba7be66662614f8e0efa7d13b208ba5f | |
| parent | 0d2a711dc9a65dc8eb6e995369e70cddbcd7d9a4 (diff) | |
| download | emacs-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.texi | 9 | ||||
| -rw-r--r-- | etc/NEWS | 11 | ||||
| -rw-r--r-- | lisp/simple.el | 7 | ||||
| -rw-r--r-- | lisp/subr.el | 9 |
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 | ||
| 649 | A history list for numbers read by @code{read-number}. | ||
| 650 | @end defvar | ||
| 651 | |||
| 652 | @defvar goto-line-history | ||
| 653 | A history list for arguments to @code{goto-line}. This variable is | ||
| 654 | buffer 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. |
| @@ -65,6 +65,17 @@ GNU General Public License for more details. | |||
| 65 | You should have received a copy of the GNU General Public License | 65 | You should have received a copy of the GNU General Public License |
| 66 | along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. | 66 | along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. |
| 67 | 67 | ||
| 68 | +++ | ||
| 69 | ** 'read-number' now has its own history variable. | ||
| 70 | Additionally, the function now accepts a HIST argument which can be | ||
| 71 | used to specify a custom history variable. | ||
| 72 | |||
| 73 | +++ | ||
| 74 | ** Input history for 'goto-line' is now local to every buffer. | ||
| 75 | Each buffer will keep a separate history of line numbers used with | ||
| 76 | 'goto-line'. This should help making faster the process of finding | ||
| 77 | line numbers that were previously jumped to. | ||
| 78 | |||
| 68 | 79 | ||
| 69 | Local variables: | 80 | Local variables: |
| 70 | coding: utf-8 | 81 | coding: 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. |
| 1217 | If called interactively, a numeric prefix argument specifies | 1221 | If 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. |
| 2523 | DEFAULT specifies a default value to return if the user just types RET. | 2526 | DEFAULT specifies a default value to return if the user just types RET. |
| 2524 | The value of DEFAULT is inserted into PROMPT. | 2527 | The value of DEFAULT is inserted into PROMPT. |
| 2528 | HIST specifies a history list variable. See `read-from-minibuffer' | ||
| 2529 | for details of the HIST argument. | ||
| 2525 | This function is used by the `interactive' code letter `n'." | 2530 | This 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)) |