Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: python completion update
- X-seq: zsh-workers 20601
 
- From: Doug Kearns <dougkearns@xxxxxxxxx>
 
- To: zsh-workers@xxxxxxxxxx
 
- Subject: PATCH: python completion update
 
- Date: Thu, 2 Dec 2004 01:35:24 +1100
 
- Mail-followup-to: zsh-workers@xxxxxxxxxx
 
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
 
This updates _python completion for version 2.4.
Regards,
Doug
Index: Completion/Unix/Command/_python
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_python,v
retrieving revision 1.2
diff -u -r1.2 _python
--- Completion/Unix/Command/_python	21 Jan 2004 13:53:29 -0000	1.2
+++ Completion/Unix/Command/_python	1 Dec 2004 14:33:25 -0000
@@ -1,11 +1,15 @@
 #compdef python
 
+local curcontext="$curcontext" state line
+typeset -A opt_args
+
 _arguments -s -S \
   '(1 -)-c+[program passed in as string (terminates option list)]:python command:' \
   '-d[debug output from parser]' \
   '-E[ignore environment variables (such as PYTHONPATH)]' \
   '(1 * -)-h[display help information]' \
   '-i[inspect interactively after running script]' \
+  '(1 * -)-m[run library module as a script (terminates option list)]:module:->modules' \
   '-O[optimize generated bytecode]' \
   '-OO[remove doc-strings in addition to the -O optimizations]' \
   '-Q+[division options]:division option:(old warn warnall new)' \
@@ -20,4 +24,13 @@
   '(-)1:script file:_files -g "*.py(|c|o)(-.)"' \
   '*:script argument:_files' && return
 
+if [[ "$state" = modules ]]; then
+  local -a modules
+  modules=(
+    ${${=${(f)"$(_call_program modules $words[1] -c \
+      'from\ pydoc\ import\ help\;\ help\(\"modules\"\)')"}[2,-3]}:#\(package\)}
+  )
+  _wanted modules expl module compadd -a modules
+fi
+
 return 1
Messages sorted by:
Reverse Date,
Date,
Thread,
Author