Not exactly sure what the question is, but this might help. It's hard to add to what is said in the doc section you cite - I think that section describes the situation well.
A buffer is in a (major) mode. When the major mode is turned on (becomes active), one of the things that happens (by the major-mode function's code) is that all (buffer) local variables are killed (using kill-all-local-variables
). That clears the slate. (That's not directly important to the question, but it is important to realize, in general.)
Code that is executed while the given buffer is current sets the (buffer) local value of a variable by first declaring the variable to be buffer local, using make-local-variable
. E.g.:
(make-local-variable 'foo)
Then, whenever that buffer is current and you set that variable, it is the buffer-local value that gets set. E.g.:
(setq foo 42)
make-local-variable
returns the variable, so you often see the two operations combined in one sexp:
(set (make-local-variable 'foo) 42)
A different declaration, make-variable-buffer-local
declares a variable to become local to every buffer where it is set. So if you do this:
(make-variable-buffer-local 'bar)
Then whenever bar
is given a value, that value is local to the buffer that is current when the setting takes place.
(I feel, without looking, that I am no doubt repeating what the doc says, using other words. Dunno what else to say, to make things clear.)