use zsh completion cache for costly python module completions

This commit is contained in:
Michael Bujol 2014-12-03 23:14:40 -06:00
parent 43aa3783f8
commit 92e53481cc

View File

@ -44,10 +44,17 @@ _arguments -C -s -S "$args[@]" \
if [[ "$state" = modules ]]; then if [[ "$state" = modules ]]; then
local -a modules local -a modules
if ( [[ ${+python_modules} -eq 0 ]] || _cache_invalid python_modules ) \
&& ! _retrieve_cache python_modules; then
modules=( modules=(
${${=${(f)"$(_call_program modules $words[1] -c \ ${${=${(f)"$(_call_program modules $words[1] -c \
'from\ pydoc\ import\ help\;\ help\(\"modules\"\)')"}[2,-3]}:#\(package\)} 'from\ pydoc\ import\ help\;\ help\(\"modules\"\)')"}[2,-3]}:#\(package\)}
) )
_store_cache python_modules modules
fi
_wanted modules expl module compadd -a modules && return _wanted modules expl module compadd -a modules && return
fi fi