zsh-users
 help / color / mirror / code / Atom feed
* dynamic reset of completion widget
@ 2004-11-04 12:42 Francisco Borges
  2004-11-04 13:09 ` Peter Stephenson
  2004-11-04 18:39 ` Bart Schaefer
  0 siblings, 2 replies; 5+ messages in thread
From: Francisco Borges @ 2004-11-04 12:42 UTC (permalink / raw)
  To: Zsh User

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.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-11-05 12:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-04 12:42 dynamic reset of completion widget Francisco Borges
2004-11-04 13:09 ` Peter Stephenson
2004-11-04 20:54   ` Francisco Borges
2004-11-05 12:11     ` Peter Stephenson
2004-11-04 18:39 ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).