summary refs log tree commit diff
path: root/Completion/Unix/Command/_pydoc
diff options
context:
space:
mode:
authorJun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>2015-01-28 23:58:23 +0900
committerJun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>2015-01-28 23:58:23 +0900
commit1faf2888e9617c7bade0a45a4b09648c8da9f6e3 (patch)
tree827b3ecd583dbf2a111da9c7056f3ca736f2d0b6 /Completion/Unix/Command/_pydoc
parentf591458321362ab0b3d7b383e9343b1d33f98218 (diff)
downloadzsh-1faf2888e9617c7bade0a45a4b09648c8da9f6e3.tar.gz
zsh-1faf2888e9617c7bade0a45a4b09648c8da9f6e3.tar.xz
zsh-1faf2888e9617c7bade0a45a4b09648c8da9f6e3.zip
34415: cache list of all python modules
Diffstat (limited to 'Completion/Unix/Command/_pydoc')
-rw-r--r--Completion/Unix/Command/_pydoc41
1 files changed, 28 insertions, 13 deletions
diff --git a/Completion/Unix/Command/_pydoc b/Completion/Unix/Command/_pydoc
index f85ab0c2d..677c96ad6 100644
--- a/Completion/Unix/Command/_pydoc
+++ b/Completion/Unix/Command/_pydoc
@@ -1,19 +1,34 @@
-#compdef pydoc
+#compdef -P pydoc[0-9.]#
 
-local context state line ret=1
+local curcontext=$curcontext state state_descr line ret=1
 typeset -A opt_args
+local -a args
 
-_arguments \
-  '(-)-k[search keyword]:keyword' \
-  '(- *)-p[start web server on specified port]:port number' \
-  '(- *)-g[start gui]' \
-  '(-)-w[write out HTML]:file or dir:_files' \
-  '(- *)-h[show help information]' \
-  '*: :->lookup' && ret=0
+args=(
+  '(- *)-k[search keyword]:keyword'
+  '(-k -g -w *)-p[start web server on specified port]:port number'
+  '(-)-w[write out HTML in current directory]'
+  '(-)*: :->lookup'
+)
 
-[[ -n $state ]] && _alternative -C $context \
-  'keywords:keyword:compadd ${=${${(f)"$(_call_program keywords pydoc keywords)"}[2,-1]}}' \
-  'topics:topic:compadd ${=${${(f)"$(_call_program topics pydoc topics)"}[2,-1]}}' \
-  'modules:module:' && ret=0
+if _pick_variant pydoc3='pydoc3 -b' pydoc2 -h; then
+  args+=( '(-k -w *)-b[start server and open browser]' )
+else
+  args+=( '(- *)-g[start gui]' )
+fi
+
+_arguments -C : $args && return 0
+
+case $state in
+(lookup)
+  if [[ $words[CURRENT] = */* ]]; then
+    _files && ret=0
+  else
+    _alternative \
+      'keywords:keyword:compadd ${=${${(f)"$(_call_program keywords $words[1] keywords)"}[2,-1]}}' \
+      'topics:topic:compadd ${=${${(f)"$(_call_program topics $words[1] topics)"}[2,-1]}}' \
+      'modules:module:_python_modules' && ret=0
+  fi
+esac
 
 return ret