Make a variable have a local value in the current buffer.
Make a variable use its global value in the current buffer.
Mark a variable so that setting it will make it local to the buffer that is current at that time.
You can make any variable local to a specific Emacs buffer. This means that the variable’s value in that buffer is independent of its value in other buffers. A few variables are always local in every buffer. All other Emacs variables have a global value which is in effect in all buffers that have not made the variable local.
Major modes always make the variables they set local to the buffer. This is why changing major modes in one buffer has no effect on other buffers.
M-x make-local-variable reads the name of a variable and makes it local to the current buffer. Further changes in this buffer will not affect others, and changes in the global value will not affect this buffer.
M-x make-variable-buffer-local reads the name of a variable and
changes the future behavior of the variable so that it automatically
becomes local when it is set. More precisely, once you have marked a
variable in this way, the usual ways of setting the
variable will automatically invoke
make-local-variable first. We
call such variables per-buffer variables.
Some important variables have been marked per-buffer already. They
truncate-lines. Some other variables are
always local in every buffer, but they are used for internal
Note: the variable
auto-fill-function was formerly named
If you want a variable to cease to be local to the current buffer, call M-x kill-local-variable and provide the name of a variable to the prompt. The global value of the variable is again in effect in this buffer. Setting the major mode kills all the local variables of the buffer.
To set the global value of a variable, regardless of whether the
variable has a local value in the current buffer, you can use the
setq-default. It works like
If there is a local value in the current buffer, the local value is
not affected by
setq-default; thus, the new global value may
not be visible until you switch to another buffer, as in the case of:
(setq-default fill-column 75)
setq-default is the only way to set the global value of a variable
that has been marked with
Programs can look at a variable’s default value with
This function takes a symbol as an argument and returns its default value.
The argument is evaluated; usually you must quote it explicitly, as in
the case of: