11

I was experimenting with local variables and set:

(defvar-local foo nil "Buffer local foo")

I later redesigned my program to use a global variable instead using:

(defvar foo nil "Not buffer local foo")

but the variable is still buffer local and even (kill-local-variable 'foo) didn't kill it.

Basically, how can I "undo" make-local-variable?

  • 1
    Just FWI, defvar-local uses make-variable-buffer-local not make-local-variable. – Malabarba Oct 10 '14 at 22:09
11

The comment from @Malabarba explains your problem.

kill-local-variable does get rid of the local variable binding. But since in your case the variable is automatically local in any buffer, when you reassign it a value, that value is local.

AFAIK, there is no way to counter make-variable-buffer-local, except to use unintern on the symbol. (makunbound does not help.)

If you use unintern then you're OK. But keep in mind that uninterning removes the symbol altogether, so if you used the symbol for something else, besides a variable, then there might be negative consequences.

So the only answer I have is to use unintern and then reassign the variable whatever value you want - it will be a global value.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.