From: "Miroslav Koškár" <mk@mkoskar.com>
To: Daniel Shahaf <d.s@daniel.shahaf.name>
Cc: zsh-workers@zsh.org
Subject: Re: _git: Improve handling of aliases
Date: Sat, 27 Jun 2020 11:04:36 +0200 [thread overview]
Message-ID: <20200627090436.nus5tsql3awqpqew@mkoskar.com> (raw)
In-Reply-To: <20200626170003.49d91fff@tarpaulin.shahaf.local2>
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
next prev parent reply other threads:[~2020-06-27 9:05 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-24 11:12 [PATCH] " Miroslav Koškár
2020-06-24 11:56 ` Daniel Shahaf
2020-06-26 10:17 ` Miroslav Koškár
2020-06-26 17:00 ` Daniel Shahaf
2020-06-27 6:12 ` [PATCH 0/4] " Miroslav Koškár
2020-06-27 6:12 ` [PATCH 1/4] _git: Remove hanging whitespaces Miroslav Koškár
2020-06-27 6:12 ` [PATCH 2/4] _git: Fix insufficiently quoted pattern Miroslav Koškár
2020-06-27 6:12 ` [PATCH 3/4] _git: Fix handling of aliases Miroslav Koškár
2020-06-27 6:12 ` [PATCH 4/4] _git: Don't shadow global aliases Miroslav Koškár
2020-06-27 9:04 ` Miroslav Koškár [this message]
2020-06-27 20:39 ` _git: Improve handling of aliases Daniel Shahaf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200627090436.nus5tsql3awqpqew@mkoskar.com \
--to=mk@mkoskar.com \
--cc=d.s@daniel.shahaf.name \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).