One thing that may be unexpected with defvar
is that (from its docstring):
The optional argument INITVALUE is evaluated, and used to set SYMBOL,
only if SYMBOL’s value is void.
That is, if you change the initvalue in the defvar and evaluate it again (eg with eval-last-sexp
, the new initvalue is not taken into account. However, you can use the command eval-defun
(bound to C-M-x
in elisp-mode
)
If the current defun is actually a call to ‘defvar’ or ‘defcustom’,
evaluating it this way resets the variable using its initial value
expression (using the defcustom’s :set function if there is one), even
if the variable already has some other value.
Note that defconst
does not have this behavior (from its docstring):
The ‘defconst’ form always sets the value of SYMBOL to the result of
evalling INITVALUE.