emacs-devel
[Top][All Lists]
Advanced

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

Re: goto-line-history should not be buffer local.


From: Alan Mackenzie
Subject: Re: goto-line-history should not be buffer local.
Date: Mon, 15 Feb 2021 21:12:59 +0000

Hello, Martin.

On Mon, Feb 15, 2021 at 09:17:18 +0100, martin rudalics wrote:
>  >> Why is goto-line-history buffer local?  This seems to me to be a step
>  >> backwards, for precisely the reason that making search history buffer
>  >> local would be a bad thing.

>  > I agree. I've been locally patching out that part of the commit since
>  > a few months after it was introduced, which was at the end of 2019, as
>  > Óscar points out.

> Then this feature should be made optional.

How about this (plus a NEWS entry and some amendments to the Emacs manual)?



diff --git a/lisp/simple.el b/lisp/simple.el
index 0c5bcb6672..b2b559ed13 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -1274,7 +1274,19 @@ mark-whole-buffer
 
 ;; 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)
@@ -1292,6 +1304,11 @@ goto-line-read-args
             (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)


Anybody have any objections to this?

> martin

-- 
Alan Mackenzie (Nuremberg, Germany).



reply via email to

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