Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: How to get compadd to not sort words?



Many thanks.

This does the trick. I'm happy with getting this in the order given without
special formatting of negative numbers.

On Sun, Dec 14, 2014 at 9:50 PM, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
wrote:

> On Dec 14,  8:35pm, Rocky Bernstein wrote:
> }
> } For example, if I enter
> }
> }     compadd --  1 2 -1 -2  -3 0
> }
> } The completions come out in the order:
> }
> }            -3   -2  -1   0    1  2
> }
> } But what I really want is the order I gave.
>
> "compadd" is actually one of the better-documented bits of the completion
> system.  Some of the "support builtins" aren't documented at all.
>
> } How can I tell compadd not to sort the completions?
>
> You need to put them in a named unsorted group.
>
>         compadd -V numbers 1 2 -1 -2  -3 0
>
> Group names end up being referenced via the "tag" slot in the six-part
> completion context string, e.g., with the compadd above you might use
>
>         zstyle ':completion:*:*:*:*:numbers' list-colors '=-*=7'
>
> to show negative numbers in reverse video.  However, to make that work
> you have to initialize the style mechanism by calling _description:
>
>         local expl
>         _description -V numbers expl 'Some Numbers'
>         compadd "$expl[@]" - 1 2 -1 -2 -3 0
>
> The _description function does all the style processing and fills in
> the $expl variable with the corresponding compadd options.  The example
> in the zsh manual isn't as clear as it could be because it uses
>
>         _description files expl file
>         compadd "$expl[@]" - "$files[@]"
>
> and although expl in the _description call maps to $expl in the compadd
> call, the two uses of "files" are unrelated.
>


Messages sorted by: Reverse Date, Date, Thread, Author