* goto-line-history should not be buffer local.
@ 2021-02-14 19:18 Alan Mackenzie
2021-02-14 23:08 ` Óscar Fuentes
0 siblings, 1 reply; 17+ messages in thread
From: Alan Mackenzie @ 2021-02-14 19:18 UTC (permalink / raw)
To: emacs-devel
Hello, Emacs.
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. This was a recent change, at the end of
January.
In my personal use, I sometimes type M-g M-g in the wrong buffer, which
disrupts my flow of thought in that buffer. That's unavoidable. But
now I have the additional inconvenience of having to type in that line
number in full a second time, having gone to the proper buffer. That's
not good.
Also I frequently want to go to the same line repeatedly in the same
file. I mean here file, not buffer. I kill the buffer and reload from
"disk" to ensure that caches are cleared, and suchlike, during testing.
Here, again, I've got to remember that line number and type it in again
in full. That's not good either.
Indeed, I'm not sure whether having a buffer local history is better
than having no history at all. Who wants to go to the same line
repeatedly in the same buffer? OK, others may do, but I don't see the
compelling need.
So, could we have this history variable made global again, please?
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: goto-line-history should not be buffer local.
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
0 siblings, 1 reply; 17+ messages in thread
From: Óscar Fuentes @ 2021-02-14 23:08 UTC (permalink / raw)
To: emacs-devel
Alan Mackenzie <acm@muc.de> writes:
> 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. This was a recent change, at the end of
> January.
It's a bit older:
commit 7c5d6a2afc6c23a7fff8456f506ee2aa2d37a3b9
Author: Federico Tedin
Date: Tue Dec 24 17:38:19 2019 +0100
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).
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: goto-line-history should not be buffer local.
2021-02-14 23:08 ` Óscar Fuentes
@ 2021-02-14 23:31 ` Richard Copley
2021-02-15 8:17 ` martin rudalics
0 siblings, 1 reply; 17+ messages in thread
From: Richard Copley @ 2021-02-14 23:31 UTC (permalink / raw)
To: Alan Mackenzie; +Cc: Óscar Fuentes, Emacs Development
Alan Mackenzie <acm@muc.de> writes:
> 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.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: goto-line-history should not be buffer local.
2021-02-14 23:31 ` Richard Copley
@ 2021-02-15 8:17 ` martin rudalics
2021-02-15 21:12 ` Alan Mackenzie
0 siblings, 1 reply; 17+ messages in thread
From: martin rudalics @ 2021-02-15 8:17 UTC (permalink / raw)
To: Richard Copley, Alan Mackenzie; +Cc: Óscar Fuentes, Emacs Development
>> 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.
martin
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: goto-line-history should not be buffer local.
2021-02-15 8:17 ` martin rudalics
@ 2021-02-15 21:12 ` Alan Mackenzie
2021-02-16 11:46 ` Lars Ingebrigtsen
2021-02-16 17:13 ` Juri Linkov
0 siblings, 2 replies; 17+ messages in thread
From: Alan Mackenzie @ 2021-02-15 21:12 UTC (permalink / raw)
To: martin rudalics; +Cc: Richard Copley, Óscar Fuentes, Emacs Development
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).
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: goto-line-history should not be buffer local.
2021-02-15 21:12 ` Alan Mackenzie
@ 2021-02-16 11:46 ` Lars Ingebrigtsen
2021-02-16 17:13 ` Juri Linkov
1 sibling, 0 replies; 17+ messages in thread
From: Lars Ingebrigtsen @ 2021-02-16 11:46 UTC (permalink / raw)
To: Alan Mackenzie
Cc: Richard Copley, martin rudalics, Óscar Fuentes,
Emacs Development
Alan Mackenzie <acm@muc.de> writes:
> How about this (plus a NEWS entry and some amendments to the Emacs manual)?
Sounds good to me.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: goto-line-history should not be buffer local.
2021-02-15 21:12 ` Alan Mackenzie
2021-02-16 11:46 ` Lars Ingebrigtsen
@ 2021-02-16 17:13 ` Juri Linkov
2021-02-16 20:57 ` Alan Mackenzie
1 sibling, 1 reply; 17+ messages in thread
From: Juri Linkov @ 2021-02-16 17:13 UTC (permalink / raw)
To: Alan Mackenzie
Cc: Richard Copley, martin rudalics, Óscar Fuentes,
Emacs Development
> -(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")
>
> Anybody have any objections to this?
This is not an objection, just sharing a tip that to make
Isearch history buffer-local like it's in web browsers,
where each web page tab uses own local search history,
is possible with a small code snippet:
(make-variable-buffer-local 'search-ring)
(make-variable-buffer-local 'regexp-search-ring)
OTOH, with using defcustom it's easier to customize this, indeed.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: goto-line-history should not be buffer local.
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 ` Stefan Monnier
0 siblings, 2 replies; 17+ messages in thread
From: Alan Mackenzie @ 2021-02-16 20:57 UTC (permalink / raw)
To: Juri Linkov
Cc: Richard Copley, martin rudalics, Óscar Fuentes,
Emacs Development
Hello, Juri.
On Tue, Feb 16, 2021 at 19:13:36 +0200, Juri Linkov wrote:
> > -(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")
> > Anybody have any objections to this?
> This is not an objection, just sharing a tip that to make
> Isearch history buffer-local like it's in web browsers,
> where each web page tab uses own local search history,
> is possible with a small code snippet:
> (make-variable-buffer-local 'search-ring)
> (make-variable-buffer-local 'regexp-search-ring)
> OTOH, with using defcustom it's easier to customize this, indeed.
The point about the approach I've taken is that once a variable has
undergone make-variable-buffer-local, it cannot be changed back to a
non-local variable, except by restarting Emacs (I'm not sure whether or
not this is a design bug). So I've avoided the use of that primitive.
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: goto-line-history should not be buffer local.
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-16 22:56 ` Stefan Monnier
1 sibling, 2 replies; 17+ messages in thread
From: Matt Armstrong @ 2021-02-16 22:52 UTC (permalink / raw)
To: Alan Mackenzie, Juri Linkov
Cc: Richard Copley, martin rudalics, Óscar Fuentes,
Emacs Development
Alan Mackenzie <acm@muc.de> writes:
> Hello, Juri.
>
> On Tue, Feb 16, 2021 at 19:13:36 +0200, Juri Linkov wrote:
>> > -(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")
>
>> > Anybody have any objections to this?
>
>> This is not an objection, just sharing a tip that to make
>> Isearch history buffer-local like it's in web browsers,
>> where each web page tab uses own local search history,
>> is possible with a small code snippet:
>
>> (make-variable-buffer-local 'search-ring)
>> (make-variable-buffer-local 'regexp-search-ring)
>
>> OTOH, with using defcustom it's easier to customize this, indeed.
>
> The point about the approach I've taken is that once a variable has
> undergone make-variable-buffer-local, it cannot be changed back to a
> non-local variable, except by restarting Emacs (I'm not sure whether or
> not this is a design bug). So I've avoided the use of that primitive.
Why the option at all? Why not just make the history global?
I'm not strongly opposed, but I also don't think "make an option for it"
is always the right thing.
Who are the people who would set the option back to buffer local
history?
Note: the feature hasn't escaped to a stable release yet, so no strong
need for an option for backward compatibility reasons.
This is the strongest statement in favor of buffer locality I found:
https://lists.gnu.org/r/bug-gnu-emacs/2019-11/msg01580.html:
> I thought that it might be even better to have the history be
> buffer-local as well; because line numbers from one buffer don't
> really make sense on another.
"it might be better". We've now got people who actively found it
annoying.
FYI we've got a similar, not yet fixed, bug about goto-char's history:
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=6980. I'd say both should
work a similar way, but I'm unconvinced that every such case needs an
option covering a local vs. global choice.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: goto-line-history should not be buffer local.
2021-02-16 20:57 ` Alan Mackenzie
2021-02-16 22:52 ` Matt Armstrong
@ 2021-02-16 22:56 ` Stefan Monnier
1 sibling, 0 replies; 17+ messages in thread
From: Stefan Monnier @ 2021-02-16 22:56 UTC (permalink / raw)
To: Alan Mackenzie
Cc: Richard Copley, martin rudalics, Óscar Fuentes,
Emacs Development, Juri Linkov
> The point about the approach I've taken is that once a variable has
> undergone make-variable-buffer-local, it cannot be changed back to a
> non-local variable, except by restarting Emacs.
In some cases, you can unintern the symbol, but yes, it's basically
impossible :-(
> (I'm not sure whether or not this is a design bug)
I think it's just a feature noone bothered to implement.
I don't think it would require any change to the existing code.
Stefan
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: goto-line-history should not be buffer local.
2021-02-16 22:52 ` Matt Armstrong
@ 2021-02-16 22:56 ` Lars Ingebrigtsen
2021-02-18 0:26 ` Rolf Ade
1 sibling, 0 replies; 17+ messages in thread
From: Lars Ingebrigtsen @ 2021-02-16 22:56 UTC (permalink / raw)
To: Matt Armstrong
Cc: Óscar Fuentes, Emacs Development, Richard Copley,
martin rudalics, Alan Mackenzie, Juri Linkov
Matt Armstrong <matt@rfc20.org> writes:
> Who are the people who would set the option back to buffer local
> history?
*hand*
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: goto-line-history should not be buffer local.
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
` (2 more replies)
1 sibling, 3 replies; 17+ messages in thread
From: Rolf Ade @ 2021-02-18 0:26 UTC (permalink / raw)
To: emacs-devel
Matt Armstrong <matt@rfc20.org> writes:
>
> Who are the people who would set the option back to buffer local
> history?
I will do. (Would prefer it's the default.)
What meaning have a certain line number from one buffer in another
buffer?
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: goto-line-history should not be buffer local.
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
2 siblings, 2 replies; 17+ messages in thread
From: Alan Mackenzie @ 2021-02-18 10:43 UTC (permalink / raw)
To: Rolf Ade; +Cc: emacs-devel
Hello, Rolf.
On Thu, Feb 18, 2021 at 01:26:56 +0100, Rolf Ade wrote:
> Matt Armstrong <matt@rfc20.org> writes:
> > Who are the people who would set the option back to buffer local
> > history?
> I will do. (Would prefer it's the default.)
> What meaning have a certain line number from one buffer in another
> buffer?
When, for example, you accidentally run goto-line in the wrong buffer.
When you switch to the buffer you wanted, you don't want to have to type
in the whole line number again.
When you have several versions of the same file, which happens in SW
development, you may want to goto-line to the same position in a
different version, in a different buffer.
A third case, which is what got on my nerves last weekend, is when you
are repeatedly killing a buffer and loading the same file again, so as
to clear caches, and so on. You want to go to the same place at each
new loading, so as to do testing.
I'm curious as to why somebody would want buffer local goto-line
history. How often does one repeat the same goto-line in the same
buffer, and how does a buffer local history help?
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: goto-line-history should not be buffer local.
2021-02-18 0:26 ` Rolf Ade
2021-02-18 10:43 ` Alan Mackenzie
@ 2021-02-18 10:53 ` Philip Kaludercic
2021-02-18 11:02 ` Andreas Schwab
2 siblings, 0 replies; 17+ messages in thread
From: Philip Kaludercic @ 2021-02-18 10:53 UTC (permalink / raw)
To: Rolf Ade; +Cc: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 506 bytes --]
Rolf Ade <rolf@pointsman.de> writes:
> Matt Armstrong <matt@rfc20.org> writes:
>>
>> Who are the people who would set the option back to buffer local
>> history?
>
> I will do. (Would prefer it's the default.)
Seconding this.
> What meaning have a certain line number from one buffer in another
> buffer?
One argument was that you might accidentally type M-g M-g in the wrong
buffer, and would want to easily switch the buffer and repeat the last
goto-line request.
--
Philip K.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 686 bytes --]
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: goto-line-history should not be buffer local.
2021-02-18 0:26 ` Rolf Ade
2021-02-18 10:43 ` Alan Mackenzie
2021-02-18 10:53 ` Philip Kaludercic
@ 2021-02-18 11:02 ` Andreas Schwab
2 siblings, 0 replies; 17+ messages in thread
From: Andreas Schwab @ 2021-02-18 11:02 UTC (permalink / raw)
To: Rolf Ade; +Cc: emacs-devel
On Feb 18 2021, Rolf Ade wrote:
> What meaning have a certain line number from one buffer in another
> buffer?
Line numbers are not buffer local, they are file local.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: goto-line-history should not be buffer local.
2021-02-18 10:43 ` Alan Mackenzie
@ 2021-02-18 11:04 ` Kévin Le Gouguec
2021-02-18 11:38 ` Rolf Ade
1 sibling, 0 replies; 17+ messages in thread
From: Kévin Le Gouguec @ 2021-02-18 11:04 UTC (permalink / raw)
To: Alan Mackenzie; +Cc: Rolf Ade, emacs-devel
Alan Mackenzie <acm@muc.de> writes:
> A third case, which is what got on my nerves last weekend, is when you
> are repeatedly killing a buffer and loading the same file again, so as
> to clear caches, and so on. You want to go to the same place at each
> new loading, so as to do testing.
Out of curiosity, in this specific case, wouldn't revert-buffer (now
conveniently bound to C-x x g) accomplish the same thing? (Clear
caches, while preserving the buffer-local history)
(Not suggesting that this invalidates your use-cases; just trying to
make sure I understand this one)
> I'm curious as to why somebody would want buffer local goto-line
> history. How often does one repeat the same goto-line in the same
> buffer, and how does a buffer local history help?
🤷 I guess someone could use that buffer-local history as a manually
curated version of the mark ring?
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: goto-line-history should not be buffer local.
2021-02-18 10:43 ` Alan Mackenzie
2021-02-18 11:04 ` Kévin Le Gouguec
@ 2021-02-18 11:38 ` Rolf Ade
1 sibling, 0 replies; 17+ messages in thread
From: Rolf Ade @ 2021-02-18 11:38 UTC (permalink / raw)
To: emacs-devel
Hello Alan,
Alan Mackenzie <acm@muc.de> writes:
> On Thu, Feb 18, 2021 at 01:26:56 +0100, Rolf Ade wrote:
>> Matt Armstrong <matt@rfc20.org> writes:
>
>> > Who are the people who would set the option back to buffer local
>> > history?
>
>> I will do. (Would prefer it's the default.)
>
>> What meaning have a certain line number from one buffer in another
>> buffer?
>
> When, for example, you accidentally run goto-line in the wrong buffer.
> When you switch to the buffer you wanted, you don't want to have to type
> in the whole line number again.
>
> When you have several versions of the same file, which happens in SW
> development, you may want to goto-line to the same position in a
> different version, in a different buffer.
>
> A third case, which is what got on my nerves last weekend, is when you
> are repeatedly killing a buffer and loading the same file again, so as
> to clear caches, and so on. You want to go to the same place at each
> new loading, so as to do testing.
Thanks for explaning. I didn't thought about those cases but see now
why you are glad about a global goto-line history for them.
> I'm curious as to why somebody would want buffer local goto-line
> history. How often does one repeat the same goto-line in the same
> buffer, and how does a buffer local history help?
When I valgrind an app I get line nummers from the output of the memory
debugger. Often the stack trace spread over several source files. While
looking around in the relevant files I would be glad for a local
goto-line history.
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2021-02-18 11:38 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.