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

Add some tips in `compadd` docs about groups



Recently I wrote a zsh completion script to complete like `_pids`, which is 
public via the link below:
https://github.com/dbgbgtf1/Ceccomp/blob/92c99eb/completions/_ceccomp

I checked out `_pids` but found that the completion is not that enough: I need 
to include all processes except kernel threads. So I wrote another module to 
do that (L44-L50 in the link above). But when I'm writing it, I found that `-o 
nosort` didn't work.


Anyway, for my script part, `compadd -o nosort -ld lines -a pids` does not 
work, but `compadd -V NOKERNEL_PIDS -ld lines -a pids` works. Though I consult 
manual and see that `-o nosort` could treat my input as sorted, only set up 
this flag still sort `lines` and `pids`. At first I guessed it was because of 
parse errors, so I went for `-V` flag which implicitly set *NOSORT* and it 
worked.

But after digging into it, I find the problem a bit complicated. Tracing into 
`bin_compadd` function, it successfully resolves `-o nosort` flag and set 
`CAF_NOSORT`. However, stepping into `addmatches`, it dropps all flags if no 
group is set (/Zle/compcore.c#L2103-L2109). But adding matches will not 
perform any change on input. Later in `permmatches` and then `makearray`, if 
group is not set, "default" is select and `g->flags` is 0, so matches will be 
sorted which leads to my situation (compcore.c#L3451).

Go back to manual, in `-o` descriptions, **group** is not emphasized and the 
only related statement is:
> Note that the order forms part of the group name space so matches with
> different orderings will not be in the same group.
I also checked main description about `compadd`, no **group** emphasis either.


In conclusion, the manual is bit confusing and doesn't mention about 
completion **group**; only `-o nosort` without setting group will not work.

Should we add some tips in manual, or inherit flags in `addmatches`? I'm 
willing to make contributions, please reply to me if I could help any.

Cheers,
Rocket

*pubkey digest: A7ACCC386C15E3C554D34B3EAB08F98092A456BB

Attachment: signature.asc
Description: This is a digitally signed message part.



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