I did some testing of this and applied it. It had been me that separated
watch into a module and I know I was dissatisfied with the variable
setup at the time. That may have been more related to importing the
value from the environment. Do you see a way to have this apply a value
of WATCH that has come from the environment.
Do you mean that if WATCH is defined in the environment when Zsh starts (or when the watch module is reloaded), then the WATCH and watch parameters should be auto-loaded and initialized with the environment value of WATCH? In other words, would you like the following?
% WATCH=foo:bar zsh-dev -c 'typeset -p WATCH'
typeset -T WATCH watch=( foo bar )
I guess that the code of add_autoparam could be changed to do what you wish. I would only do it if the existing parameter is at the top-level and if it has the same type as the autoload parameter to be created. In that case, the value of the existing parameter could be saved, the existing parameter could then be replaced with the autoload parameter, which would then be immediately loaded and initialized with the saved value.
Philippe