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

Re: completion within a function



On Sat, Jan 2, 2021 at 6:54 PM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> 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 --

OK. That works, but it's not particularly useful; there's a difference
between "git checkout<tab>" and "git checkout <tab>".

>> 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
> }

That doesn't seem to work.

For the record getting the output with bash completion is extremely easy:

  local IFS=$'\n'
  echo "${COMPREPLY[*]}"

-- 
Felipe Contreras




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