emacs-diffs
[Top][All Lists]
Advanced

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

master fbc9c59: Make goto-line-history buffer local only when so customi


From: Alan Mackenzie
Subject: master fbc9c59: Make goto-line-history buffer local only when so customized
Date: Wed, 17 Feb 2021 16:21:31 -0500 (EST)

branch: master
commit fbc9c59b9eb02d49f426341ee32334784d224ce4
Author: Alan Mackenzie <acm@muc.de>
Commit: Alan Mackenzie <acm@muc.de>

    Make goto-line-history buffer local only when so customized
    
    * 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 |  5 +++++
 etc/NEWS             |  5 +++++
 lisp/simple.el       | 19 ++++++++++++++++++-
 3 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/doc/emacs/basic.texi b/doc/emacs/basic.texi
index 8bf52d5..4a34fd3 100644
--- a/doc/emacs/basic.texi
+++ b/doc/emacs/basic.texi
@@ -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
diff --git a/etc/NEWS b/etc/NEWS
index b96bcd9..7665d47 100644
--- 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
 
 +++
diff --git a/lisp/simple.el b/lisp/simple.el
index e54cbed..363a0f2 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -1278,7 +1278,19 @@ that uses or sets the mark."
 
 ;; 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)



reply via email to

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