From 92e53481ccfbc3a853ace5b8d4b570591513e343 Mon Sep 17 00:00:00 2001 From: Michael Bujol Date: Wed, 3 Dec 2014 23:14:40 -0600 Subject: [PATCH] use zsh completion cache for costly python module completions --- plugins/python/_python | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/plugins/python/_python b/plugins/python/_python index f517d480..d80e670e 100644 --- a/plugins/python/_python +++ b/plugins/python/_python @@ -44,10 +44,17 @@ _arguments -C -s -S "$args[@]" \ if [[ "$state" = modules ]]; then local -a modules - modules=( - ${${=${(f)"$(_call_program modules $words[1] -c \ - 'from\ pydoc\ import\ help\;\ help\(\"modules\"\)')"}[2,-3]}:#\(package\)} - ) + if ( [[ ${+python_modules} -eq 0 ]] || _cache_invalid python_modules ) \ + && ! _retrieve_cache python_modules; then + + modules=( + ${${=${(f)"$(_call_program modules $words[1] -c \ + 'from\ pydoc\ import\ help\;\ help\(\"modules\"\)')"}[2,-3]}:#\(package\)} + ) + + _store_cache python_modules modules + fi + _wanted modules expl module compadd -a modules && return fi