I must be going crazy. Here is my latest sanity check code in viper-check-state in viper-cmd.el
(when (eq (default-value 'viper-current-state) 'vi-state)
(message "Doomed going in"))
(setq-local viper-current-state new-state)
(when (eq (default-value 'viper-current-state) 'vi-state)
(message "Doomed. viper-current-state is now vi-state"))
The setq-local replaces a simple setq at about line 380. When the problem starts I see the “Doomed. Viper-current-state is now vi-state”, but I do *not* see the “Doomed going in” message. This implies that setq-local is setting the default value of the variable and that really shouldn’t be possible. Either I’m nuts or this is an emacs bug.