emacs-devel
[Top][All Lists]
Advanced

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

Re: Why is not end-of-defun-function buffer local?


From: Lennart Borgman (gmail)
Subject: Re: Why is not end-of-defun-function buffer local?
Date: Sun, 09 Dec 2007 02:45:11 +0100
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071031 Thunderbird/2.0.0.9 Mnenhy/0.7.5.666

Stefan Monnier wrote:
Looking at some code that is a bit older it looks like some of it uses
make-local-variable where it is not needed since the variables in question
are always buffer local. From that I draw the conclusion that the code in
Emacs uses make-variable-buffer-local more often now. Is not that the case?

make-variable-buffer-local has the following downsides:
1 - it cannot be reverted.
2 - it may be done too late.
3 - when you see `setq' it's not obvious that the setting is buffer-local
    unless you remember seeing the call to make-variable-buffer-local.
The second problem may also explain what you're seeing: some code may
set a variable before the make-variable-buffer-local gets run.
It's actually "common" to introduce bugs this way, because people see
"this is automatically buffer-local" in the C-h v info, so they just use
`setq' without realizing that the setq may occur before the package
gets loaded.
make-variable-buffer-local is not evil, but make-local-variable is much
tamer and more explicit, and it works just as well in most cases.


Thanks, that was a good explanation. Why not add this to the doc string of make-variable-buffer-local?




reply via email to

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