emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 7c5d6a2: Make goto-line keep a separate input history per buffer


From: Lars Ingebrigtsen
Subject: master 7c5d6a2: Make goto-line keep a separate input history per buffer
Date: Tue, 24 Dec 2019 11:40:25 -0500 (EST)

branch: master
commit 7c5d6a2afc6c23a7fff8456f506ee2aa2d37a3b9
Author: Federico Tedin <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>

    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 dde30ce..2c2ef97 100644
--- a/doc/lispref/minibuf.texi
+++ b/doc/lispref/minibuf.texi
@@ -645,6 +645,15 @@ A history list for variable-name arguments read by
 @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 9b60fc4..dd33950 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -65,6 +65,17 @@ GNU General Public License for more details.
 You should have received a copy of the GNU General Public License
 along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.
 
++++
+** '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.
+
 
 Local variables:
 coding: utf-8
diff --git a/lisp/simple.el b/lisp/simple.el
index 6d50300..6219986 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -1212,6 +1212,10 @@ that uses or sets the mark."
 
 ;; 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 @@ rather than line counts."
               "")))
        ;; 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 ed55853..f5b7c98 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -2518,10 +2518,15 @@ by doing (clear-string STRING)."
               ;; 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 @@ This function is used by the `interactive' code letter 
`n'."
     (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))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]