Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: _git: Improve handling of aliases
- X-seq: zsh-workers 46146
- From: Miroslav Koškár <mk@xxxxxxxxxxx>
- To: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- Subject: Re: _git: Improve handling of aliases
- Date: Sat, 27 Jun 2020 11:04:36 +0200
- Arc-authentication-results: i=1; mx.zohomail.com; dkim=pass header.i=mkoskar.com; spf=pass smtp.mailfrom=mk@xxxxxxxxxxx; dmarc=pass header.from=<mk@xxxxxxxxxxx> header.from=<mk@xxxxxxxxxxx>
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593248686; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=CTtdY2Onhc0OT/7pg/UuM6P5P4AKiq36lMIqrn1Ka20=; b=AT4CpwJzbhmhy22e0oDa8KGNuMxrLf2s+ZdxgGxBmFtPWHPxjSfRfvj7FruMCjodmiO9MMecI+kF/pl+vH6LpfvIIlArEkfpR7X27LFR8sT4U191cf+Q3NLF6ba8EJUO/LzS9X+Ew0RDBaz+VAK+5FAlP1OKa2hAAzAoO4cXM0U=
- Arc-seal: i=1; a=rsa-sha256; t=1593248686; cv=none; d=zohomail.com; s=zohoarc; b=bf/Vqnwdv9AiRggdQ8HKKuzt9F1AkubaAJF6qv1cgkDzUL5qKdO00D0G3ET+0KBGxWrBMAcXShtnpz4pPZDcXAWQhxzix59EeAWwxjbe0KvtinezOPekEJ7TYirQPubJgtnjr5bzCstiEKIbFhW2WvmcwBEyQ+LpwEbaO94fnis=
- Cc: zsh-workers@xxxxxxx
- In-reply-to: <20200626170003.49d91fff@tarpaulin.shahaf.local2>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <7f7706bd28646cf47d77a0e1b5f89cff40ed9ffe.1592995874.git.mk@mkoskar.com> <20200624115630.GA25495@tarpaulin.shahaf.local2> <20200626101704.lhzsaqrdov5rhbr7@mkoskar.com> <20200626170003.49d91fff@tarpaulin.shahaf.local2>
- Sender: zsh-workers@xxxxxxx
Hi Daniel,
bellow to things not addressed in my recent patchset.
On Jun 26, Daniel Shahaf wrote:
> Sure. Alternatively, we could continue to retrieve all aliases but
> cache that list between calls (see _store_cache; there are examples in
> _subversion).
I see, good to know. It seems fast enough to me as is so *shrug*.
> Well, yes and no. The arguments to shell aliases seem to be handled
> similarly to arguments to «eval»: joined by spaces and then passed to
> system(3). That means it's valid to pass the entire string in a single
> shell word, or to translate any of the spaces in the desired result
> string into word breaks at the shell input level, just like «eval hello
> world» and «eval 'hello world'» are equivalent.
>
> So, how about completing this the same way «eval -- <TAB>» is completed?
> Currently ${_comps[eval]} is _precommand, which just calls _normal, but
> that's incomplete¹. If we write the code to do something along the
> lines of «words=(eval -- …); CURRENT=…; _normal», it'll automatically
> grow support for completing both variants once such support is added to
> «eval»'s completion.²
>
> ¹ For example, «eval 'git -c' <TAB>» completes files rather than
> configuration options, because it takes 'git -c' rather than just 'git'
> to be the command word.
>
> ² That'd be something along the lines of «words=( ${=:-"${words}"} )»,
> I guess? Plus adjusting $CURRENT, etc..
Right, I understand your points generally. I see the similarity to eval,
even though there is an important distinction I think:
(git alias) test = !echo hello
$ git test \; world
hello ; world
So git executes aliases more akin to:
sh -c 'echo hello "$@"' arg0 \; world
As for doing 'words=(eval ...); _normal', it doesn't work for complex
commands e.g., eval cd dir '&&' ls -<TAB>.
I understand you would like to have that work in future and I agree what
would be cool and would certainly help here. With my limited knowledge
of zsh internals and complexity of completion I'll leave this to others
:). While proposed split on simple command separators might seem crude
it actually works quite fine.
> As above, I'd prefer to delegate to «eval»'s completion. Alternatively,
> my previous point about supporting comments stands.
Ahhh, so that's (Z+C+) instead of (z), forgot about that.
Well it's not like a common case to use comments there, mind you it's
a bit weird to even use them in gitconfig, managed to make an example:
test = !echo hello \n \
"#" let this be a commented line \n \
echo world
Ok, I'll wait for your comments on the patchset I've sent before and
this too and then either incorporate (Z+C+) with other changes or sent
it separately.
Regards,
Miro
Messages sorted by:
Reverse Date,
Date,
Thread,
Author