Here you go:
(defun endless/reset-var-at-point ()
"Revaluate the definition of variable at point."
(interactive)
(save-window-excursion
(save-excursion
(let ((buf (current-buffer)))
(find-variable-at-point)
(when (looking-at-p "(def\\(var\\|custom\\|const\\) ")
(eval-defun nil))
(unless (equal buf (current-buffer))
(bury-buffer (current-buffer)))))))
As others have stated, the initial value of a defvar
is not stored
anywhere. However, the location of its definition does get stored by
Emacs, so you can visit it and reevaluate it.
Note that this will only work if the location of the variable is
known, and if it is defined in a conventional way (not as part of a
wierd macro or something).
It will also leave a buffer hanging around.
So it is very much not designed for used in lisp code. For
interactive use, it should do just fine.