Search code examples
emacsspacemacs

In Emacs revert to global buffer registers


I'm using Emacs 26.3 with Spacemacs 0.300 and the registers don't cross from buffer to buffer (global registers). From what I read on the EmacsWiki this is supposed to be global by default. Mine apparently is not, I can't find anywhere it's being set to local but it's behaving as such. However, while this:

(make-variable-buffer-local 'register-alist)

makes a variable local to the buffer, I can't find what to do to make it back global, there's no make-variable-global function.

Hope someone has a suggestion, it's frustrating to insert a register I just saved and have it tell me there's nothing there!


Solution

  • You can't make a variable global that's been declared to always be buffer-local.

    This is why this hammer is used relatively infrequently - when you know that the variable should always be buffer local.

    Instead, you typically just use setq-local or set with make-local-variable, which assign a buffer-local value only for the given buffer. Nothing then prevents some other buffer from not having any buffer-local value.

    You can of course use makunbound to, in effect, start over with your variable unbound. But that's hardly a great solution for a situation where a variable has already been declared to always be buffer-local and you want it to not have a buffer-local value in some buffer.