From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: dana <dana@dana.is>, Zsh workers <zsh-workers@zsh.org>
Subject: Re: [PATCH] Completion: Sort lz4 compression levels properly (+ a question)
Date: Wed, 07 Nov 2018 11:35:59 +0100 [thread overview]
Message-ID: <88812-1541586959.338018@YaNA.ZOZt.NKaA> (raw)
In-Reply-To: <75B26F45-E6E6-44BB-80A4-7301CBE480FE@dana.is>
On 3 Nov, dana wrote:
>
> Is there a better way to do this? Off the top of my head i came up with either
You can do:
_arguments '-b-:level: compadd "${(@)expl/#-J/-2V}" ${(on)levels}'
But what you have is perhaps better, especially as it's duplicated for
-b and -e.
I was thinking that you just needed to put - in where you wanted
_arguments to add the options but it's actually _sequence that does
that.
> If there's no generic way to do it, would it make sense to have some kind of
> spec modifier that tells action forms like `(item ...)` that -V should be used,
> or, if that's too weird, a helper function (_presorted maybe) that just wraps
I'm not especially enthused about adding more special syntax to
_arguments.
The compadd interface perhaps isn't ideal. If -V was a standalone option
like -1 and -2, intended to be used in combination with -J (to specify
the group name), then it would be easier to modify the sort order.
There's also the -o option which (per-match rather than per-group) says
that the display string should be used when comparing matches for the
purpose of sorting. As far as I can tell, -o has never been used.
Sorting by the description part of the display string would be useful.
Can we improve it without breaking backward compatibility. -o with an
argument could allow for more sorting options, e.g. -o numeric to do
numeric sorting. Do we need to be concerned that someone somewhere may
actually be using -o?
The help descriptions in compadd completion had things the wrong way
around for -o which this fixes. Also, the help for -V is perhaps
somewhat confusing. "unsorted" was used to mean "will not be sorted" but
is often used when you have already pre-sorted the matches.
Oliver
diff --git a/Completion/Zsh/Command/_compadd b/Completion/Zsh/Command/_compadd
index a7036d027..e709e400e 100644
--- a/Completion/Zsh/Command/_compadd
+++ b/Completion/Zsh/Command/_compadd
@@ -14,9 +14,9 @@ _arguments -C -s -S -A "-*" \
'(-a)-k[matches are keys of specified associative arrays]' \
'-d+[specify display strings]:array:_parameters -g "*array*"' \
'-l[list display strings one per line, not in columns]' \
- '-o[order matches by display string not by match string]' \
- '(-1 -E)-J+[specify match group]:group' \
- '-V+[specify unsorted match group]:group' \
+ '-o[order matches by match string not by display string]' \
+ '(-1 -E)-J+[specify match group which will be sorted]:group' \
+ '-V+[specify pre-ordered match group]:group' \
'(-J -E)-1[remove only consecutive duplicates from group]' \
'-2[preserve all duplicates]' \
'(-x)-X[specify explanation]:explanation' \
next prev parent reply other threads:[~2018-11-07 10:43 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-04 0:13 dana
2018-11-07 10:35 ` Oliver Kiddle [this message]
2018-11-07 17:52 ` dana
2018-11-26 1:25 ` completion match ordering Oliver Kiddle
2018-11-26 3:09 ` Daniel Shahaf
2018-11-26 5:18 ` dana
2018-11-26 9:37 ` Peter Stephenson
2018-11-26 23:07 ` dana
2019-05-06 21:16 ` PATCH: " Oliver Kiddle
2019-05-07 0:10 ` dana
2019-05-07 12:39 ` Oliver Kiddle
2019-08-22 8:39 ` Daniel Hahler
2019-08-23 19:05 ` Oliver Kiddle
2019-08-25 14:25 ` Daniel Hahler
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=88812-1541586959.338018@YaNA.ZOZt.NKaA \
--to=okiddle@yahoo.co.uk \
--cc=dana@dana.is \
--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).