unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: martin rudalics <rudalics@gmx.at>
Cc: "Richard Copley" <rcopley@gmail.com>,
	"Óscar Fuentes" <ofv@wanadoo.es>,
	"Emacs Development" <emacs-devel@gnu.org>
Subject: Re: goto-line-history should not be buffer local.
Date: Mon, 15 Feb 2021 21:12:59 +0000	[thread overview]
Message-ID: <YCrj25sBB5cPxAZg@ACM> (raw)
In-Reply-To: <c5279048-f97f-f0e9-395f-5e30865ca315@gmx.at>

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
 \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)
@@ -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	other threads:[~2021-02-15 21:12 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-14 19:18 goto-line-history should not be buffer local Alan Mackenzie
2021-02-14 23:08 ` Óscar Fuentes
2021-02-14 23:31   ` Richard Copley
2021-02-15  8:17     ` martin rudalics
2021-02-15 21:12       ` Alan Mackenzie [this message]
2021-02-16 11:46         ` Lars Ingebrigtsen
2021-02-16 17:13         ` Juri Linkov
2021-02-16 20:57           ` Alan Mackenzie
2021-02-16 22:52             ` Matt Armstrong
2021-02-16 22:56               ` Lars Ingebrigtsen
2021-02-18  0:26               ` Rolf Ade
2021-02-18 10:43                 ` Alan Mackenzie
2021-02-18 11:04                   ` Kévin Le Gouguec
2021-02-18 11:38                   ` Rolf Ade
2021-02-18 10:53                 ` Philip Kaludercic
2021-02-18 11:02                 ` Andreas Schwab
2021-02-16 22:56             ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YCrj25sBB5cPxAZg@ACM \
    --to=acm@muc.de \
    --cc=emacs-devel@gnu.org \
    --cc=ofv@wanadoo.es \
    --cc=rcopley@gmail.com \
    --cc=rudalics@gmx.at \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).