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

Re: possibly useful zsh_directory_name implementation



On Fri, 11 Mar 2011 18:09:57 +0100
Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> Can you really just call a bunch of completions in series and get a
> useful result? The documentation still seems to imply running will
> stop as soon as one hook returns 0 status.

Completion of a set of possibilities is a completely different operation
from turning one, unique, name into one, unique, directory.  You don't
know the first function to be called is the one that will produce the
completion you want.  If the user typed "p", does the user want
"pigbreeder-ahab" from zsh_directory_name_farmers, or "proj:monty" from
zsh_directory_name_projects?  The order of the functions doesn't tell
you.

> More importantly, shouldn't you only run zsh_directory_name if that
> function exists? As it is now, it will be run even if only the array
> is defined.

Yes, I'll fix that.

> Also, why the mix of -n $foo and ${+foo}?

Your $foo is looking for the presence of a function.  I think
${+functions[...]} does work, it just happened not to be done that way
and I didn't change it.  Your ${+foo} is looking for a variable being
set; that's not what -n $foo does, and although -n $foo does the right
thing as far as completion is concerned, testing the presense of the
variable is the right thing to avoid triggering the error message which
should only pop up if there is no defined mechanism for expanding ~[...].

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