Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: list units in brackets at the end of completion group descriptions
> 2021/11/07 10:16, Oliver Kiddle <opk@xxxxxxx> wrote:
>
> Do you see an issue with the behaviour of the following:
> local alts
> [[ -z $PREFIX ]] && alts=( 'sign:sign:((-\:"print all but the last specified bytes/lines" +\:"print the first specified bytes/lines (default)"))' )
> compset -P '+'
> alts+=( 'numbers: :_numbers number b\:512 K\:1024 KB\:1000 M\:1024\^2 MB\:1000\^2 G\:1024\^3 GB\:1000\^3 T\:1024\^4 TB\:1000\^4' )
> _alternative $alts
It works if we use either "compset -P '[-+]'" or "_numbers -N".
>> Or is it better to set them to 0 so that %(M etc. works?
>
> The absence of any M: spec is treated as 0, unfortunately.
Oops, sorry. I thought I've tested that %(M is false if M: is not
given, but it seems I did the test in a wrong way.
> Perhaps we should add an option to
> zformat so that we can simply use $(m. %(m).) with no need for the
> uppercase spec.
(snip)
> An option to zformat would not be backward
> compatible for the format style (not that we ever used the feature but
> someone might).
(snip)
> Or should we just stick
> with M:1 and needing the else branch or a 1.
I think %1(M is enough for the current purpose.
(or set %M to 0 if unit is given, and nonzero otherwise; i.e., never leave
it undefined).
But, in zshcompsys(1), neither the section for the 'format' style nor the
section for '_description' says that the ternary expression of zformat can
be used (or is it mentioned somewhere?). So if adding a new option to
zformat would have wider use, then I think adding the option and using it in
_description would not break the compatibility.
The format for the unit-suffixes tag accepts %d that is set to 0 if
the suffix is marked as the default (such as :k:kilo) and 1 otherwise.
This may cause some confusion, but I feel it is OK.
---
Jun
Messages sorted by:
Reverse Date,
Date,
Thread,
Author