* Definition reasoning of revert-buffer-function, should it be defvar-local?
@ 2021-08-10 13:51 Daniel Nagy
2021-08-10 14:34 ` Andreas Schwab
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Nagy @ 2021-08-10 13:51 UTC (permalink / raw)
To: emacs-devel
Hello,
I want to understand the reasoning behind the definition and the intention of
the variable `revert-buffer-function`.
In `files.el` I see the following definition:
> (put 'revert-buffer-function 'permanent-local t)
> (defvar revert-buffer-function #'revert-buffer--default)
The first line suggests to me, that the intention of the variable is that it is
supposed to be buffer-local, but `defvar-local` was not used. This means, that
if I open a new buffer and `(setq revert-buffer-function #'something)` then that
variable is assigned globally, breaking its behaviour. I know that I can use
`setq-local`, but using `defvar-local` would prevent accidents.
My question is, why was `defvar-local` not used? Should we change it ? Should we
change all these constructs where it says `(put ... 'permanent-local t)(defvar
...)`?
In `bookmark.el` I can also see the invocation `(setq revert-buffer-function
...)` but that instance does not leak out its value to global Emacs because its
mode is derived from `tabulated-list-mode` and that already uses `setq-local` to
make the value buffer-local.
Thank you already for your help.
For the more curious, this question sparked during this GitHub issue:
https://github.com/magit/magit/issues/4432
Best,
Daniel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Definition reasoning of revert-buffer-function, should it be defvar-local?
2021-08-10 13:51 Definition reasoning of revert-buffer-function, should it be defvar-local? Daniel Nagy
@ 2021-08-10 14:34 ` Andreas Schwab
2021-08-10 14:46 ` Tassilo Horn
0 siblings, 1 reply; 3+ messages in thread
From: Andreas Schwab @ 2021-08-10 14:34 UTC (permalink / raw)
To: Daniel Nagy; +Cc: emacs-devel
On Aug 10 2021, Daniel Nagy wrote:
> I want to understand the reasoning behind the definition and the intention of
> the variable `revert-buffer-function`.
>
> In `files.el` I see the following definition:
>
>> (put 'revert-buffer-function 'permanent-local t)
>> (defvar revert-buffer-function #'revert-buffer--default)
>
> The first line suggests to me, that the intention of the variable is that it is
> supposed to be buffer-local, but `defvar-local` was not used.
When these lines were written, defvar-local didn't exist.
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] 3+ messages in thread
* Re: Definition reasoning of revert-buffer-function, should it be defvar-local?
2021-08-10 14:34 ` Andreas Schwab
@ 2021-08-10 14:46 ` Tassilo Horn
0 siblings, 0 replies; 3+ messages in thread
From: Tassilo Horn @ 2021-08-10 14:46 UTC (permalink / raw)
To: Andreas Schwab; +Cc: emacs-devel, Daniel Nagy
Andreas Schwab <schwab@linux-m68k.org> writes:
>> I want to understand the reasoning behind the definition and the
>> intention of the variable `revert-buffer-function`.
>>
>> In `files.el` I see the following definition:
>>
>>> (put 'revert-buffer-function 'permanent-local t)
>>> (defvar revert-buffer-function #'revert-buffer--default)
>>
>> The first line suggests to me, that the intention of the variable is that it is
>> supposed to be buffer-local, but `defvar-local` was not used.
>
> When these lines were written, defvar-local didn't exist.
Hehe, sure. But why hasn't `make-variable-buffer-local' been used? I
agree with Daniel that nobody should ever alter the global value of
`revert-buffer-function' but it is easy to do that accidentally.
Bye,
Tassilo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-08-10 14:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-10 13:51 Definition reasoning of revert-buffer-function, should it be defvar-local? Daniel Nagy
2021-08-10 14:34 ` Andreas Schwab
2021-08-10 14:46 ` Tassilo Horn
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.