]> git.eshelyaron.com Git - emacs.git/commitdiff
Make goto-line-history buffer local only when so customized
authorAlan Mackenzie <acm@muc.de>
Wed, 17 Feb 2021 21:15:51 +0000 (21:15 +0000)
committerAlan Mackenzie <acm@muc.de>
Wed, 17 Feb 2021 21:15:51 +0000 (21:15 +0000)
* lisp/simple.el (goto-line-history-local): New customizable option.
(goto-line-history): Define this simply with defvar, not defvar-local.
(goto-line-read-args): Handle goto-line-history-local, and changes to it.

* doc/emacs/basic.texi (Moving Point): Add a paragraph about
goto-line-history-local.

* etc/NEWS: Add an item under "Editing Changes in Emacs 28.1".

doc/emacs/basic.texi
etc/NEWS
lisp/simple.el

index 8bf52d5dd30af1ed065ce8676c987a156e04712a..4a34fd36c5d25cec624fabab7e7f5a0cce1fcb4c 100644 (file)
@@ -331,6 +331,11 @@ a plain prefix argument.  Alternatively, you can use the command
 @code{goto-line-relative} to move point to the line relative to the
 accessible portion of the narrowed buffer.
 
+@code{goto-line} has its own history list (@pxref{Minibuffer
+History}).  You can have either a single list shared between all
+buffers (the default) or a separate list for each buffer, by
+customizing the user option @code{goto-line-history-local}.
+
 @item M-g @key{TAB}
 @kindex M-g TAB
 @findex move-to-column
index b96bcd9eccdca3c3338dc8f089abce2e75a89419..7665d4740f9fc6aff3a874666fad0dd5e568e5bc 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -345,6 +345,11 @@ trying to be non-destructive.
 This command opens a new buffer called "*Memory Report*" and gives a
 summary of where Emacs is using memory currently.
 
++++
+** The history list for the 'goto-line' command is now a single list
+for all buffers by default.  You can configure a separate list for
+each buffer by customizing the user option 'goto-line-history-local'.
+
 ** Outline
 
 +++
index e54cbed7a7656c63dd587ae2f5a3c136a289f450..363a0f26d5d864235b6a408a279f9c50f383a202 100644 (file)
@@ -1278,7 +1278,19 @@ that uses or sets the mark."
 \f
 ;; Counting lines, one way or another.
 
-(defvar-local goto-line-history nil
+(defcustom goto-line-history-local nil
+  "If this option is nil, `goto-line-history' is shared between all buffers.
+if it is non-nil, each buffer has its own value of this history list.
+
+Note that on changing from non-nil to nil, the former contents of
+`goto-line-history' for each buffer are discarded on use of
+`goto-line' in that buffer."
+  :group 'editing
+  :type 'boolean
+  :safe #'booleanp
+  :version "28.1")
+
+(defvar goto-line-history nil
   "History of values entered with `goto-line'.")
 
 (defun goto-line-read-args (&optional relative)
@@ -1296,6 +1308,11 @@ that uses or sets the mark."
             (if buffer
                 (concat " in " (buffer-name buffer))
               "")))
+      ;; Has the buffer locality of `goto-line-history' changed?
+      (cond ((and goto-line-history-local (not (local-variable-p 'goto-line-history)))
+             (make-local-variable 'goto-line-history))
+            ((and (not goto-line-history-local) (local-variable-p 'goto-line-history))
+             (kill-local-variable 'goto-line-history)))
       ;; Read the argument, offering that number (if any) as default.
       (list (read-number (format "Goto%s line%s: "
                                  (if (buffer-narrowed-p)