Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Grouping and ordering completions with zshcompsys?
- X-seq: zsh-users 24372
- From: dana <dana@xxxxxxx>
- To: Chris Nebel <c.nebel@xxxxxxx>
- Subject: Re: Grouping and ordering completions with zshcompsys?
- Date: Mon, 21 Oct 2019 03:51:22 -0500
- Cc: zsh-users@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dana-is.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=ivbuI1LUI9IB2HiAwB4CK8WtqHwDHMKTkQtVsFykskE=; b=eWRqoXeZ2oOe9ymR+49WEJDnzXsKyIYMdJanWsaF80fkckylJTbN7lBRGQx/bEb9wh hr75o6gKyXZQ9pO+sq9tQUkTtnW1Gp3Hv83NVQoS9XN4d5fLQpPSK/eFFD8pUwnywP0K r+DrKzcvLCznB/cQYv7g+2ljFNvJxyoIaCmOC3bykXW/pB4GYBRRbAjlLvQY81IgbeQ9 6UDhpux4pF6Otbivhp4ZbxL732yg6ZWYeFg/N3IhMZXJjdeHX9MmCzcJdjCEpa48pUSQ FxedjPe3WcTDLROfAQwHBFe0jX91ACz6Okzx3cnzCUUBoAeHY1QcXBCNYuYjCvX0qlCP H+xQ==
- In-reply-to: <4E66F85B-02CC-4F77-A409-5E9C8E21F467@mac.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: <16BF7A2C-A29E-4D80-9040-769414BCC6E6@mac.com> <4E66F85B-02CC-4F77-A409-5E9C8E21F467@mac.com>
On 21 Oct 2019, at 01:57, Chris Nebel <c.nebel@xxxxxxx> wrote:
> Notice the two distinct groups with names, and the serial numbers appearing
> before the names. For bonus points, I’d like the exclusion behavior that
> “_arguments” has, so it won’t complete the same archive more than once, and
> if the user already typed “all” it won’t complete anything more. The
> closest I’ve managed to get this this:
Grouping is usually something you leave up to the user's group-name style. If
they have zsh configured to keep groups separate, they will get that
behaviour. If they don't, they won't. It's possible to force the issue in an
individual completion function, but i think generally you're meant to assume
that it's configured how they want it.
For putting the serial numbers in the names, you can make use of the name2
argument to _describe, like this (just to illustrate the basic concept):
name1=( {'1 omg','2 zomg','4 bbq','42 foobar'}.tgz )
name2=( ${(@)name1##[0-9\ ]##} )
_describe -2Vt archives archive name1 name2
When you add descriptions (to name1), though, it seems to ignore -12JVo and
just put the matches in some random order. I don't understand why, and i can't
look into it right now. Maybe it's expected.
To separate out the meta-archives, i guess just use _alternative:
_alternative \
'archives: :_foo_archives' \
'meta-archives: :_foo_meta_archives'
Where _foo_archives and _foo_meta_archives are your helper functions that
handle completion for those particular matches.
For handling the `all` meta-archive, you can just check to see if `all` is in
$line or $words before deciding how to proceed (again, just to illustrate,
you probably wouldn't do it *exactly* like this):
if (( $line[(I)all] )); then
_message 'no more archives'
else
_alternative ...
fi
On 21 Oct 2019, at 02:02, Chris Nebel <c.nebel@xxxxxxx> wrote:
> Related question: is there a way to get _files to only complete files that
> pass a test of some sort? Specifically, I want files that are in one of
> four (possibly compressed) archive formats.
Usually you give it a pattern that matches file extensions with -g, as in:
_files -g '*.(tgz|txz|...)(#q-.)'
If you can't get the information you need with globbing, there are ways to be
more clever about it, but that's not a super common thing to do.
dana
Messages sorted by:
Reverse Date,
Date,
Thread,
Author