Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] Completion: Sort lz4 compression levels properly (+ a question)
- X-seq: zsh-workers 43758
- From: dana <dana@xxxxxxx>
- To: Zsh workers <zsh-workers@xxxxxxx>
- Subject: [PATCH] Completion: Sort lz4 compression levels properly (+ a question)
- Date: Sat, 3 Nov 2018 19:13:03 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dana-is.20150623.gappssmtp.com; s=20150623; h=from:content-transfer-encoding:mime-version:subject:message-id:date :to; bh=r81KESnsiyVVbIUy3lXCEl3QK+4S93Akitb26wX8tPg=; b=f5YmW5teP2th/iPzX+omR+MR0vpu//nIpVNsUJ/t3Va5j3i9Y5d+G88hyaG6xa6kbZ 647BKaDt3KwdHJCEERoEcgLb6YPLV25+IODMcoNi+uMRSZgkkSHy8HRKOXAk66k9UbX7 o6+IKwj7gm5ibDTzB3si8cWagRecByV2Q1tFgPfpGEqBiSb3IXgKpYa4aVJYTkepbz90 hNfeAtp0lpgO4Svtn7cvjt3OKiHG0sDCnlS2Ky7n5VuZEfleSK0SQxiVy42JwABVaQl7 mXotxhKUZ8Y/n+FtuJYCmhMYW44q/6EWgtYvPbBSiHUC3cKyrghqhqpSKLoHXPH868qA GDsg==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author