From: Felipe Contreras <felipe.contreras@gmail.com>
To: "SZEDER Gábor" <szeder.dev@gmail.com>,
"Felipe Contreras" <felipe.contreras@gmail.com>
Cc: git@vger.kernel.org, David Aguilar <davvid@gmail.com>,
Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH] completion: zsh: trivial improvement
Date: Tue, 08 Jun 2021 00:37:27 -0500 [thread overview]
Message-ID: <60bf0217e0a90_198bd720828@natae.notmuch> (raw)
In-Reply-To: <20210608050115.GC6312@szeder.dev>
SZEDER Gábor wrote:
> On Mon, Jun 07, 2021 at 09:38:07PM -0500, Felipe Contreras wrote:
> > $words has basically all the words we need, except the first one: git.
> >
> > Lets simply add that instead of passing the original, which contains
> > options we don't want to pass downstream (like --git-dir).
>
> In our Bash completion script $words contains all words of the current
> command on the command line, including 'git -C tmp -c foo.bar=baz'.
>
> Why should zsh completion behave differently?
Because we use the _arguments function [1]. It changes the $words array
and removes all the arguments it was able to parse. All that remains is
that which it didn't understand.
If you do:
git --git-dir=x show --<tab>
_arguments will remove 'git --git-dir=x'. And there is no point in
passing '--git-dir=x' to _git_show. It provides no useful information,
and it was already processed by __git_zsh_main and __git_dir is set.
__git_main doesn't need to change $words, but it does increase
__git_cmd_idx to match the position of the command.
But since in the zsh case _argments already modified $words, we can just
add 'git' to the start and always use __git_cmd_idx=1.
[1] https://zsh.sourceforge.io/Doc/Release/Completion-System.html#Completion-Functions
--
Felipe Contreras
prev parent reply other threads:[~2021-06-08 5:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-08 2:38 [PATCH] completion: zsh: trivial improvement Felipe Contreras
2021-06-08 5:01 ` SZEDER Gábor
2021-06-08 5:37 ` Felipe Contreras [this message]
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=60bf0217e0a90_198bd720828@natae.notmuch \
--to=felipe.contreras@gmail.com \
--cc=davvid@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=szeder.dev@gmail.com \
/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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.