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

Re: [PATCH] Add _gradle for gradle and gradlew completion.



On 24 March 2012 23:04, Jesper Nygårds <jesper.nygards@xxxxxxxxx> wrote:
> 2012/3/24 Mikael Magnusson <mikachu@xxxxxxxxx>:
>> You're defining a single function with the same name as the autoloaded
>> function, and then calling it, that serves no purpose so you can just
>> remove that indirection.
>
> Good call. I'll just remove it.
>
>> You could move the _gradle_caching_policy to
>> the toplevel and then this pattern would make sense. (There's no
>> namespaces for functions, so even though you define it inside _gradle
>> now, it stays around after _gradle returns.)
>
> I did know that functions are global, but I must define the function
> where I do, because I can only set it once I know what build file is
> to be parsed, i.e. the $build_file is a local variable, but the
> _gradle_caching_policy needs to know its value. In some other
> languages, I would call this a closure.

There is no such thing as closures in zsh, you can define it anywhere
you want using a variable called $build_file and it will use the
definition of the variable at the call site, not the definition site.
Ie, the body of a function is completely ignored by zsh until you
invoke the function (but the syntax has to be correct of course).

>> zstyle -T ":completion:*:*:$service:*" gradle-inspect || gradle_inspect=no
>> can probably be
>> zstyle -b ":completion:*:*:$service:*" gradle-inspect gradle_inspect
>> but I didn't test. :)
>
> Unless I misunderstand something, this doesn't seem to work as I'd
> like it to. It works if the style is set, but I want the
> gradle_inspect variable to default to be true if the gradle-inspect
> style is unset, and this doesn't seem to happen with your suggestion.

Okay, never mind that then :).

>> You need to quote the ? in -?,-h,--help. (The completion system sets
>> the nullglob option, so the whole argument just disappears without
>> errors).
>
> Thanks, I had overlooked that one.
>
>> Other than that it looks pretty good to me.
>
> Great. I'll submit a new patch tomorrow, unless I have any other
> errors pointed out by you or someone else.

-- 
Mikael Magnusson



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