geometry-zsh/geometry

A variable `fun` gets defined

psprint opened this issue · 8 comments

Hello,
zplugin report revealed that a rather unintentional variable gets defined:

geometry-env-report-2

hmm I wonder if there are better solutions than

. <(cat "${GEOMETRY_ROOT}"/functions/geometry_*.zsh)

or

for fun ("${GEOMETRY_ROOT}"/functions/geometry_*.zsh(N.)) . $fun; unset fun

You can declare the fun var local :)

Hmm I had to do geometry::load() { local fun; for fun ("${GEOMETRY_ROOT}"/functions/geometry_*.zsh(N.)) . $fun }; geometry::load for local to stick. Wish I could just have it be an anonymously invoked function.

What is the difference between loading in a plugin manager and sourcing?

Right now, when you source geometry.zsh, it will source everything in functions. I am open to doing something with fpath/autoload if there are tangible benefits but all my previous tries have failed using those.

Plugin manager will load with a function, so local parameters will go out of scope.

Ahh yeah but we want all local parameters to go out of scope if possible I think. Does the current version of geometry have other obvious deficiencies?

Out of that list of variables, ideally the user would only see GEOMETRY_PROMPT, GEOMETRY_RPROMPT, and GEOMETRY_INFO. I wonder if there are good ways to hide the other variables. Unfortunately they are all state that needs to exist outside of the prompt render loop.

I've recently drastically reduced the number of variables used in Zplugin by changing A_MAP[A_$KEY] into ONE_MAIN_MAP[A_MAP__A_$KEY]. Basically, with this technique, all possible variables can be put into a single map. I've had the comfort that I was having only maps, not integer-indexed arrays to reduce this way, so I've even used vim patterns with \(…\) in them and substituted, but in general, even integer-indexed arrays are possible to be reduced with this method. For arrays I would however rather serialize/deserialize them rather than use the above method.