Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Lazy loading completions



In article 
<130418163739.ZM8718__6202.1464844749$1366328467$gmane$org@torch.brassla
ntern.com>,
 Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:

> compctl has been mostly deprecated for several years.  You should look
> into running compinit from your shell startup to set up more modern
> completions.

Yeah, I already do use the modern completions a lot elsewhere.  I'm just 
trying to get this to work here :-)

> In fact, someone should suggest to Doug Hellmann that he stop using
> compctl commands in virtualenvwrapper.sh ... compctl won't work at all
> for someone using compinit unless they've configured it to fall through
> to old-style completions when no modern completion is found.

Huh, sounds like it's worth a bug report.  I don't have any mention of 
compctl in my compinit but maybe I got lucky.

> }     source /usr/local/bin/virtualenvwrapper_lazy.sh
> }     _virtualenvwrapper_load_compctl() {
> }       compctl + ${=_VIRTUALENVWRAPPER_API}
> }       virtualenvwrapper_load
> }       eval ${$(compctl | egrep '^'$_comp_command1' -K')[3]}
> }     }
> 
> ??  Where is the value of $_comp_command1 coming from here?  It's not set
> by virtualenvwrapper_load or virtualenvwrapper.sh as far as I can tell,
> so that egrep is doing nothing ...?

It's being set by the completion system, I guess.  I inserted a 'set' 
into the completion and grabbed the variable which contained the 
function name whose argument was being completed.  In any case, if I can 
do without it using compdef, I'm all for it...

> }     compctl -K _virtualenvwrapper_load_compctl ${=_VIRTUALENVWRAPPER_API}
> 
> With compinit loaded, I believe what you want here is
> 
>     _virtualenvwrapper_load_compctl() {
>       unset '_comps['${(k)^_comps[(R)_virtualenvwrapper_load_compctl]}']'
>       virtualenvwrapper_load
>       # Until Doug gets his act together
>       zmodload -i zsh/compctl
>       zstyle ':completion:*' use-compctl yes
>       _default
>       # After togetherness
>       # _normal
>     }
>     compdef _virtualenvwrapper_load_compctl ${=_VIRTUALENVWRAPPER_API}
> 
> but I'm not entirely confident.

Works great, thanks, though I now need to move the above to below where 
I call compinit; that may break a lot of users of virtualenvwrapper.
-- 
Nicholas Riley <njriley@xxxxxxxxxxxx>



Messages sorted by: Reverse Date, Date, Thread, Author