Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH] Fix WATCH/watch tying



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 )

Currently this doesn't work because add_autoparam doesn't create an autoload parameter if a parameter with the same name already exists. Interestingly checkaddparam only emits a warning if the already existing parameter isn't a top-level one. I'm not sure why that is. Maybe that should be changed. However, that's why the example above fails without any warning.

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



Messages sorted by: Reverse Date, Date, Thread, Author