1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-12-15 09:47:20 +00:00

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".
This commit is contained in:
Alan Mackenzie 2021-02-17 21:15:51 +00:00
parent 6735bb3d22
commit fbc9c59b9e
3 changed files with 28 additions and 1 deletions

View 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

View File

@ -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
+++

View File

@ -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)