From: dana <dana@dana.is>
To: Zsh workers <zsh-workers@zsh.org>
Subject: [PATCH] Completion: Sort lz4 compression levels properly (+ a question)
Date: Sat, 3 Nov 2018 19:13:03 -0500 [thread overview]
Message-ID: <75B26F45-E6E6-44BB-80A4-7301CBE480FE@dana.is> (raw)
This isn't super necessary but it irritated me.
Is there a better way to do this? Off the top of my head i came up with either
this state method or calling compadd from the argument spec... but both of those
involve an awful lot of boiler-plate just to keep some numbers sorted.
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
compadd?
dana
diff --git a/Completion/Unix/Command/_lz4 b/Completion/Unix/Command/_lz4
index d69091d00..4d2721bd5 100644
--- a/Completion/Unix/Command/_lz4
+++ b/Completion/Unix/Command/_lz4
@@ -42,8 +42,8 @@ args=(
'(b t -k --keep)--rm[remove source file]'
'!(b t -c --stdout)--to-stdout'
+ b # Benchmark-mode options
- "(C c d t)-b-[benchmark file using specified compression level]::compression level:(${(j< >)levels//-/})"
- "(C c d t)-e-[specify upper compression level limit (with -b)]:compression level:(${(j< >)levels//-/})"
+ '(C c d t)-b-[benchmark file using specified compression level]:: :->levels'
+ '(C c d t)-e-[specify upper compression level limit (with -b)]: :->levels'
'(C c d t)-i-[specifiy minimum evaluation time (with -b)]:evaluation time (seconds)'
+ c # Compress-mode options
"(b d t ${(j< >)levels} -c0 -c1 -c2 -hc)"${^levels}
@@ -98,6 +98,11 @@ case $state in
_message 'no more arguments' && ret=0
fi
;;
+ levels)
+ _wanted -2V levels expl 'compression level' \
+ compadd - ${(@on)levels//-/} \
+ && ret=0
+ ;;
esac
return ret
next reply other threads:[~2018-11-04 0:13 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-04 0:13 dana [this message]
2018-11-07 10:35 ` Oliver Kiddle
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=75B26F45-E6E6-44BB-80A4-7301CBE480FE@dana.is \
--to=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).