defvar
does not reassign a variable's value in the same way as, say
setq
or setf
. Once a variable has a value, defvar
won't touch it.
From defvar
's docstring:
(defvar SYMBOL &optional INITVALUE DOCSTRING)
Define SYMBOL as a variable, and return SYMBOL.
...
The optional argument INITVALUE is evaluated, and used to set
SYMBOL, only if SYMBOL's value is void. If SYMBOL is
buffer-local, its default value is what is set; buffer-local
values are not affected. If INITVALUE is missing, SYMBOL's
value is not set.
...
Since you presumably defvar
ed the variables in question to give them values when you first loaded the library, re-loading the library won't change the values.
See also the elisp manual node on
Defining Global Variables.
Instead of relying on defvar
, you can always re-assign values with setq
. As an alternative, clunky option, you can unintern
the symbols so that the defvar
s will not find them upon reloading:
(defvar test-1 "test this")
(defvar test-2 "test this one, too")
test-1 ; => "test this"
test-2 ; => "test this one, too"
(defvar test-1 "trying to redefine")
(defvar test-2 "trying to redefine, too")
test-1 ; => "test this"
test-2 ; => "test this one, too"
(mapc #'unintern '(test-1 test-2))
test-1 ; => error!
test-2 ; => error!
(defvar test-1 "trying to redefine")
(defvar test-2 "trying to redefine, too")
test-1 ; => "trying to redefine"
test-2 ; => "trying to redefine, too"
(unload-feature 'myname)
first?eval-defun
it doesn't pick up changes indefvar
.defvar
s in a file or buffer, if I understand correctly.load-file
implies that he wants to evaluate the whole file while making sure that the defvars are reevaluated.