Re: [PATCH v2] completion: Handle '!f() { ... }; f' aliases

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Steffen Prohaska <prohaska@xxxxxx> writes:

> '!f() { ... }; f' is a recommended pattern to declare more complex
> aliases (see git wiki [1]).  This commit teaches the completion to
> handle them.

Hmm, I've never endorsed nor recommended such a notation myself ;-)
I tend to prefer writing it like so instead:

    sh -c '...' -

so that I won't clobber "f" (or any other name).  I wonder if you
can help users of this other pattern as well.

> When determining which completion to use for an alias, the opening brace
> is now ignored in order to continue the search for a git command inside
> the function body.  For example, the alias '!f() { git commit ... }' now
> triggers commit completion.

I suspect that "scanning" is error-prone.  I like this one for its
cuteness very much, though:

> Furthermore, the null command ':' is now skipped, so that it can be used
> as a workaround to declare the desired completion style.  For example,
> the alias '!f() { : git commit ; if ...  ' now triggers commit
> completion.



> +test_expect_success 'completion uses <cmd> completion for alias !f() { VAR=val git <cmd> ... }' '
> +	test_config alias.co "!f() { VAR=val git checkout ... ; } f" &&

Is it only "f" that is completed, or can I spell it using another
arbitrary token, e.g.

	test_config alias.co "!co () { git checkout ... } co"

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]