GNU Emacs Lisp Reference Manual
The buffer-local value of variable starts out as the same value variable previously had. If variable was void, it remains void.
;; In buffer `b1': (setq foo 5) ; Affects all buffers. => 5 (make-local-variable 'foo) ; Now it is local in `b1'. => foo foo ; That did not change => 5 ; the value. (setq foo 6) ; Change the value => 6 ; in `b1'. foo => 6 ;; In buffer `b2', the value hasn't changed. (save-excursion (set-buffer "b2") foo) => 5
Making a variable buffer-local within a let-binding for that variable does not work. This is because let does not distinguish between different kinds of bindings; it knows only which variable the binding was made for.
If the variable is terminal-local, this function signals an error. Such variables cannot have buffer-local bindings as well. See Multiple Displays.
Note: do not use make-local-variable for a hook variable. Instead, use make-local-hook. See Hooks.
The value returned is variable.
t if variable is buffer-local in buffer buffer (which defaults to the current buffer); otherwise, nil.(make-local-variable 'foobar) (makunbound 'foobar) (make-local-variable 'bind-me) (setq bind-me 69)
(setq lcl (buffer-local-variables)) ;; First, built-in variables local in all buffers: => ((mark-active . nil) (buffer-undo-list nil) (mode-name . "Fundamental") ... ;; Next, non-built-in local variables. ;; This one is local and void: foobar ;; This one is local and nonvoid: (bind-me . 69))
Note that storing new values into the CDRs of cons cells in this list does not change the local values of the variables.
If you kill the local binding of a variable that automatically becomes local when set, this makes the global value visible in the current buffer. However, if you set the variable again, that will once again create a local binding for it.
kill-local-variable returns variable.
This function is a command because it is sometimes useful to kill one buffer-local variable interactively, just as it is useful to create buffer-local variables interactively.
This function also resets certain other information pertaining to the buffer: it sets the local keymap to nil, the syntax table to the value of standard-syntax-table, and the abbrev table to the value of fundamental-mode-abbrev-table.
Every major mode command begins by calling this function, which has the effect of switching to Fundamental mode and erasing most of the effects of the previous major mode. To ensure that this does its job, the variables that major modes set should not be marked permanent.
kill-all-local-variables returns nil.
A local variable is permanent if the variable name (a symbol) has a permanent-local property that is non-nil. Permanent locals are appropriate for data pertaining to where the file came from or how to save it, rather than with how to edit the contents.