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

Re: completion, sorting of options



From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
Date: Sun, 5 Nov 2023 07:58:59 -0800

> On Sun, Nov 5, 2023 at 7:03?AM Thomas Lauer <thomas.lauer@xxxxxxxxxx> wrote:
> >
> > From: Mikael Magnusson <mikachu@xxxxxxxxx>
> > Date: Sat, 4 Nov 2023 16:49:25 +0100
> > >
> > > If you give -V foo it will create an unsorted group, but it is a bit
> > > unconventional to do this for sorting regular options by usage. You
> > > could also consider adding the common options with a -J common and the
> > > other ones with a -J rare, or something to that effect.
> >
> > Thanks, Mikael. Alas, I am not going to pretend that I understand what
> > you've written.
> 
> He's referring to completion grouping controls, passed to compadd.  If
> you're not calling compadd directly, you'll need to show us what you
> are doing to be able to get a clear explanation of what to do
> differently.

I am not calling compadd directly. Should I?

I have a file called _cmd with basically this (cut down to the important
bits):

#compdef cmd
_arguments \
	"-a=[value can be a b c d]" \
	"-b=[value can be e f g h]" \
	.... many more options
	"-y[do this]" \
	"-z[do that]" \
	....
	"1: :_files -/" \
	"2: :_files -/" \
	"3: :_cmd_commands"

_cmd_commands(){
	local cmds=("aa:do aa" "bb:do bb" ....)
	_describe -t cmds "commands" cmds
}

This file sits in usr/share/zsh/vendor-completions/. Everything but the
sort order for the options works as expected.

HTH. T




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