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

Re: Yet another completion question

    Hi William :)

 * William Scott <wgscott@xxxxxxxxxxxxxxxxxx> dixit:
> I have a completion that works in the old form and would like
> to write a completion function.
> and I am using compctl to read in a file it produces, since this takes
> awhile to produce:
>  compctl -f  -x 'c[-1,-a] p[2,2]' -s "$(cat ~/.zshapplist)" \
>           -M 'm:{A-Za-z}={a-zA-Z} r: ||[^ ]=**' -- open
> This works.  I figured out the -s was critical to getting this to
> work right with the applications having escaped spaces.
> But what I would like to do is use the new completion system and cache
> these completions in the proper z-shell manner.

    I'm NOT an expert in completion. In fact, I'm NOT even a NEWBIE.
I'll just tell you what I would do. If your compctl code works, keep
on using it. If, by all means, you really want to write that code in
the compsys way, do it at the higher level possible, using _arguments
and the like, but don't use compadd directly. Otherwise you will need
to write a lot more of code just to make compadd work as compctl
worked, and all that code is already written for you thanks to zsh
developers and contributors. There is no real point in rewriting code
written by clever programmers, unless you're (as I am) pathologically
impulsed to do so O:)))

    Probably you will be able to rewrite your compctl recipe using
the new system in a couple of lines of code if you use the higher
level functions (_wanted, _arguments, etc.). I don't know how to use
them, but AFAIK they are documented properly in the zsh user's

> I can't seem to figure out how to use compadd syntax in analogy to the -s
> option of compctl.

    You don't need it: when you're writing a shell function to do the
completion, if compsys doesn't have already one that suits you to do
the same job, you can simply use shell constructions to do the job,
create a list (an array will do) and use compadd to add such list to
the completion list.

    BTW: do you really need -s? won't you get the same result with

    Raúl Núñez de Arenas Coronado

Linux Registered User 88736
http://www.dervishd.net & http://www.pleyades.net/

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