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

Re: completion within a function



On Sun, Jan 3, 2021 at 3:16 PM Felipe Contreras
<felipe.contreras@xxxxxxxxx> wrote:
>
> [...] your version seems to take longer to load, slowing the tests.

I don't know what your version is loading or whether a .zcompdump file
might be getting used to speed that part up.  When I try it (with the
zsh-dist-provided git completions) it spends more of its time
populating git data than anything else.

> [...] it still doesn't work correctly: I can't pass empty arguments
> in the middle of a command-line.

What does an empty argument in the middle of the line mean to the
completion result?  Which word are you trying to complete?

I thought you were passing a single string as the only argument to my
"complete" function?  If that's true, how is the empty argument
represented in that string?

> Also, I don't understand why is there an argv there:
>
>   vared -M __complete -i __init_complete ${${argv:+argv}:-reply}
>   (( ARGC )) || print -nrl -- "~~~${(@)reply}~~~"
>
> Isn't "reply" always used? And ARGC is always 0?

The ARGC/argv stuff is there so that you can call run-complete directly:

  % run-complete "git checkout -- "

which only works from an interactive command line, and just prints the
completion without forking off a zpty.

Called as the zpty command from complete, yes, ARGC is always zero and
reply is used.




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