Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Help Request/Bug Report: comparguments causes _arguments to fail in certain cases
- X-seq: zsh-users 24843
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: Dan Arad <dan1994@xxxxxxxxx>
- Subject: Re: Help Request/Bug Report: comparguments causes _arguments to fail in certain cases
- Date: Sat, 16 May 2020 20:48:40 +0000
- Cc: zsh-users@xxxxxxx
- In-reply-to: <CAPPzoJD-DqObF630EAF63Ptn-=ftiEmnywSb-w6KmfhBQ7DCkw@mail.gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CAPPzoJDB3jB7pHUfE7UjY09OHk+r_pgLeYxuaoXhMFGHf-3UCQ@mail.gmail.com> <20200503165802.6540ad48@tarpaulin.shahaf.local2> <CAPPzoJDyK35bSMTyYKovEbRZNhDpKs1aeY2ZRjzBTxgdgCuGww@mail.gmail.com> <20200504131830.3572e317@tarpaulin.shahaf.local2> <CAPPzoJC6MYg8CEqsmLRPvPRYPLYP+dJxA4BCR0Cue6xTdZ9Q9g@mail.gmail.com> <20200505164934.3f6b7f42@tarpaulin.shahaf.local2> <CAPPzoJDeGo_gzn9DFCv1Zd=m6bDO34AK1K-KSmxwu-9mQHcKtg@mail.gmail.com> <20200507204007.7487332d@tarpaulin.shahaf.local2> <CAPPzoJD-DqObF630EAF63Ptn-=ftiEmnywSb-w6KmfhBQ7DCkw@mail.gmail.com>
Dan Arad wrote on Fri, 15 May 2020 17:39 +0300:
> I got it working using the hook method: I added another script with
> `#compdef -first-` that saves the words array.
>
Nice :)
> The thing is, that now I'm faced with a different problem:
> When the command line is `./ps.py`, completions are generated correctly.
> When the command line is `python ps.py`, the actual completions are joined
> by the list of files in the current directory.
>
> This appears to be a byproduct of going through the `_python`
> auto-completion script.
>
> I was wondering if there is a way to remove existing completion matches
> before adding my own to make sure I provide only correct matches.
I don't think there's a way to remove already-added matches.
How would that help if it existed? I assume -first- runs before
_python, not after, so you should look for a way to prevent _python from
running when your function has added matches. For starters, does your
function return 0 when it has added matches?
Or you could arrange for «python ps.py» to call your script without
a -first- completion function. That should prevent _python from
falling back to completing files. Additionally, overwriting -first- is
not a composable approach: users who already overwrite -first- won't be
able to install your completion function alongside their existing
configuration.
> Also, might this be a bug in the `_python` completion script?
I don't see how. It's normal for completion to offer files as a
fallback for unknown commands, as in «nosuchcommand <TAB>».
I don't recall offhand how to disable or modify the fallback behaviour.
> Thanks for all the help,
> Dan
You're welcome.
Cheers,
Daniel
P.S. While I wrote the above I ran into this:
diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo
index 98ab46d8a..8d2813c5a 100644
--- a/Doc/Zsh/compsys.yo
+++ b/Doc/Zsh/compsys.yo
@@ -1685,6 +1685,9 @@ example(zstyle ':completion:*' group-name '')
All matches for which no group name is defined will be put in a group
named tt(-default-).
+
+To display the group name in the output, see the tt(format) style (q.v.)
+under the tt(descriptions) tag.
)
kindex(group-order, completion style)
item(tt(group-order))(
Messages sorted by:
Reverse Date,
Date,
Thread,
Author