From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10020 invoked from network); 4 Nov 2004 12:45:19 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 4 Nov 2004 12:45:19 -0000 Received: (qmail 6011 invoked from network); 4 Nov 2004 12:45:12 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 4 Nov 2004 12:45:12 -0000 Received: (qmail 11533 invoked by alias); 4 Nov 2004 12:44:20 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8168 Received: (qmail 11516 invoked from network); 4 Nov 2004 12:44:19 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 4 Nov 2004 12:44:19 -0000 Received: (qmail 4786 invoked from network); 4 Nov 2004 12:44:19 -0000 Received: from dep.let.rug.nl (129.125.8.60) by a.mx.sunsite.dk with SMTP; 4 Nov 2004 12:44:17 -0000 Received: from dep.let.rug.nl ([129.125.8.60]) by dep.let.rug.nl (SAVSMTP 3.1.0.29) with SMTP id M2004110413441610012 for ; Thu, 04 Nov 2004 13:44:16 +0100 Received: from loki (postfix@loki.let.rug.nl [129.125.8.86]) by dep.let.rug.nl (8.12.10/8.12.10) with ESMTP id iA4CiFkG026060 for ; Thu, 4 Nov 2004 13:44:15 +0100 (MET) Received: by loki (Postfix, from userid 7006) id 03184EA94; Thu, 4 Nov 2004 13:42:25 +0100 (CET) Date: Thu, 4 Nov 2004 13:42:24 +0100 From: Francisco Borges To: Zsh User Subject: dynamic reset of completion widget Message-ID: <20041104124224.GA9979@let.rug.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Operating-System: Linux/2.6.8-1-686 (i686) X-Editor: GNU Emacs 21.3.50.2 Organization: Alfa Informatica - Rijksuniversiteit Groningen User-Agent: Mutt/1.5.6+20040722i X-Whitelist: OK X-Scanned-By: milter-spamc/0.25.321 (dep.let.rug.nl [129.125.8.60]); Thu, 04 Nov 2004 13:44:16 +0100 X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=0.0 required=6.0 tests=none autolearn=no version=2.63 X-Spam-Hits: 0.0 I hope the subject wasn't that confusing... I want to automatically create zsh widgets for python programs using python's standard option parser framework (optparse) and I want also to be able to make and set this widget on-the-fly. ---------------------------------------------------------------- Here is the full story... Yesterday I made a small script that, called from inside my foo.py script, outputs a zsh completion widget to a file _foo.py. This gives me a fast completion widget but it involves some shell configuration every time I change options. [...] This guy has done a python module (http://furius.ca/optcomplete/) that will provide bash directly with option completion through bash's 'completion protocol', e.g. setting COMP_(CWORD|LINE|POINT|WORDS) and COMPREPLY. So appart from a stable _foo.py file, I think it would also be good to have a on-the-fly completion widget for zsh, like the one done for bash. Wondering how to do it, I saw two possibilities: 1. Do the same as optcomplete does for bash, e.g. talk to the shell by setting the correspondent variables; OR (don't know if this is possible, but it seems easier) 2. Have a default widget for my python script, say _optparse, that makes a new custom widget and rebinds the completion of foo.py to _foo.py # I start with compdef _optparse foo.py compdef _optparse bozo.py [etc] # I'm not a zsh programmer, so please have patience here... _optparse(){ # discover the name of the command we are completing set bar=`give the command name I'm completing` eval "`$bar --make-zsh-widget`" # which would return something like: # "_foo.py() { compadd Scooby Dooby Doo; }" compdef _$bar $bar } Is this possible? Can I just rebind like this? I imagine I'm not taking care of all details yet... Any ideas, comments or suggestions? All welcome. Any example of something similar? (I must confess that I find zsh documentation a bit overwhelming...) Peace, Francisco.