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

Re: How to do completion of toggle flag sequences separated by +/-



On Mon, 2 May 2011 11:16:06 +0200
Haakon Riiser <haakon.riiser@xxxxxxxxxx> wrote:
>  By the way: When defining sub-functions inside a completion
> function, is it recommended to test for their existence before
> defining them? E.g.,
> 
>  (( $+functions[_ffmpeg_foo] )) || _ffmpeg_foo() {
>    ...
>  }
> 
>  I see this in a lot of completers included with zsh, and I assumed
> it was done for performance reasons (although it seems strange that
> the performance hit could be significant, considering that the code
> is only executed once per TAB keypress).

That's certainly normal, but I think it's less for performance reasons
than to allow you to overrided _ffmpeg_foo (or whatever) in another
file.  Note that the (( ... )) expression is true even if _ffmpeg_foo is
marked for autoload.

-- 
Peter Stephenson <pws@xxxxxxx>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK
 



Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom



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