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

Re: completion within a function



On Sat, Jan 2, 2021 at 4:28 PM Felipe Contreras <felipe.contreras@xxxxxxxxx> wrote:

I'm trying it like this:

  ZDOTDIR=/tmp/empty-home zsh /tmp/complete-bart 'git --'

Don't pass a single, quoted argument; quote each word separately if needed.

ZDOTDIR=/tmp/empty-home zsh /tmp/complete-bart git --

The symptom I experienced is that the command never ends,
apparently because the end marker never arrives.

I ran into this a couple of times myself.  It seems to have something to do with the definition of "whole string":

     If a PATTERN is given as well, output is read until the whole
     string read matches the PATTERN, even in the non-blocking case.

If there's anything after the end marker, the "whole string" may not match.  I had to try several different variations to find one that gave consistent results.

At a guess, you might try:

zle_complete () {
zle list-choices
BUFFER='print -n "<END-CHOICES>"'
zle .accept-line
}


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