zsh-users
 help / color / mirror / code / Atom feed
* Lazy loading completions
@ 2013-04-18 22:23 Nicholas Riley
  2013-04-18 23:37 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Nicholas Riley @ 2013-04-18 22:23 UTC (permalink / raw)
  To: zsh-users

I noticed that virtualenvwrapper was taking about 90% of my shell's 
startup time, so I switched to a lazy-loading version. However, it 
doesn't handle completions all that well, with the following:

compctl -K virtualenvwrapper_load $(echo ${_VIRTUALENVWRAPPER_API})

This loads on the first completion request then works on the second one, 
and breaks completions on other commands - $_VIRTUALENVWRAPPER_API is a 
superset of the functions for which completions are defined.

I tried this:

    source /usr/local/bin/virtualenvwrapper_lazy.sh
    _virtualenvwrapper_load_compctl() {
      compctl + ${=_VIRTUALENVWRAPPER_API}
      virtualenvwrapper_load
      eval ${$(compctl | egrep '^'$_comp_command1' -K')[3]}
    }
    compctl -K _virtualenvwrapper_load_compctl ${=_VIRTUALENVWRAPPER_API}

It works much better, except it still requires two completion requests 
for functions for which completions are *not* defined, since the eval 
does nothing in that case. Short of making my own version of 
_VIRTUALENVWRAPPER_API, is there a way to return the default completion 
result in this case?  (Or more generally, can I replace the eval 
entirely?)

Thanks,
-- 
Nicholas Riley <njriley@illinois.edu>


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

* Re: Lazy loading completions
  2013-04-18 22:23 Lazy loading completions Nicholas Riley
@ 2013-04-18 23:37 ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2013-04-18 23:37 UTC (permalink / raw)
  To: zsh-users

On Apr 18,  5:23pm, Nicholas Riley wrote:
} Subject: Lazy loading completions
}
} compctl -K virtualenvwrapper_load $(echo ${_VIRTUALENVWRAPPER_API})

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

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.

}     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 ...?

}     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.


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

end of thread, other threads:[~2013-04-18 23:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-18 22:23 Lazy loading completions Nicholas Riley
2013-04-18 23:37 ` 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).