Skip to main content
took away conditional evaluation of makunbound
Source Link
nispio
  • 8.3k
  • 2
  • 38
  • 74

The problem is not that the line is not getting re-evaluated. The problem is that defvar defines a variable and its default value. If a variable already exists, then changing its default value does not modify the current value. Unfortunately, I think you will need to run a setq for every variable whose value you wish to update.

This may be overkill, but you could update your file like this if you want to be able to easily update foo to its new default value.

(defvar foo 2)
(setq foo 2)

but that requires that you maintain the default value in two places in your code. You could also do this:

(when (boundp 'foo)
    (makunbound 'foo))
(defvar foo 2)

but if there is a chance that foo is declared elsewhere you may have some side effects to deal with.

The problem is not that the line is not getting re-evaluated. The problem is that defvar defines a variable and its default value. If a variable already exists, then changing its default value does not modify the current value. Unfortunately, I think you will need to run a setq for every variable whose value you wish to update.

This may be overkill, but you could update your file like this if you want to be able to easily update foo to its new default value.

(defvar foo 2)
(setq foo 2)

but that requires that you maintain the default value in two places in your code. You could also do this:

(when (boundp 'foo)
    (makunbound 'foo))
(defvar foo 2)

but if there is a chance that foo is declared elsewhere you may have some side effects to deal with.

The problem is not that the line is not getting re-evaluated. The problem is that defvar defines a variable and its default value. If a variable already exists, then changing its default value does not modify the current value. Unfortunately, I think you will need to run a setq for every variable whose value you wish to update.

This may be overkill, but you could update your file like this if you want to be able to easily update foo to its new default value.

(defvar foo 2)
(setq foo 2)

but that requires that you maintain the default value in two places in your code. You could also do this:

(makunbound 'foo)
(defvar foo 2)

but if there is a chance that foo is declared elsewhere you may have some side effects to deal with.

Source Link
nispio
  • 8.3k
  • 2
  • 38
  • 74

The problem is not that the line is not getting re-evaluated. The problem is that defvar defines a variable and its default value. If a variable already exists, then changing its default value does not modify the current value. Unfortunately, I think you will need to run a setq for every variable whose value you wish to update.

This may be overkill, but you could update your file like this if you want to be able to easily update foo to its new default value.

(defvar foo 2)
(setq foo 2)

but that requires that you maintain the default value in two places in your code. You could also do this:

(when (boundp 'foo)
    (makunbound 'foo))
(defvar foo 2)

but if there is a chance that foo is declared elsewhere you may have some side effects to deal with.