Subject: Re: _history-complete-older problems with $(
From: Sebastian Gniazdowski <[email-masked]>
To: Bart Schaefer <[email-masked]>
Cc: Zsh hackers list <[email-masked]>
Date: Thu, 14 Jan 2016 12:37:52 +0100
List-Id: Zsh Workers List <zsh-workers.zsh.org>

Better movie, I tried Tab multiple times with "ls" with no space after
it. I test "ls" and "$(" with and without spaces after them.

https://asciinema.org/a/bhslks3h04x328c72az3ugawz

Best regards,
Sebastian

On 14 January 2016 at 12:30, Sebastian Gniazdowski
<[email-masked]> wrote:
> On 14 January 2016 at 05:48, Bart Schaefer <[email-masked]> wrote:
>> On Jan 13,  5:40pm, Sebastian Gniazdowski wrote:
>> Ah.  Another wrinkle I overlooked.  You need to store the original
>> values of $PREFIX and $SUFFIX somewhere, e.g.
>>
>>     local origPREFIX=$PREFIX origSUFFIX=$SUFFIX
>>
>> Then, after "compadd -O found" but before trimming PREFIX and SUFFIX
>> off of $found, you need
>>
>>     PREFIX=${PREFIX#$origPREFIX}
>>     SUFFIX=${SUFFIX%$origSUFFIX}
>>
>> This is because compadd will still try to replace the original word
>> prefix ("wid") with whatever you pass to that second compadd, so if
>> there was an original prefix/suffix you must NOT trim those off.  I
>> didn't test my original version with anything other than an empty
>> $PREFIX so didn't think of this.
>>
>> } The same problem is with "ls" about which I wrote to you earlier. So
>> } it seems that the second compadd isn't fully working.
>>
>> When _history returns nonzero, your debugging line
>>
>>     echo >> /tmp/wfhistory
>>
>> is clobbering that with its own zero return, so completion stops even
>> if no matches were found.  Move that last "echo" into the block that
>> is after "always" (right before "unfunction compadd").
>
> Bart the menucomplete option has something to do with all those
> things. I don't have the option set. When I set it it can be observed
> how your code helps or harms $(<Tab> and ls<Tab>
>
> https://asciinema.org/a/1qyjrg38s411m8rbsvmtnfwgl
>
> Best regards,
> Sebastian Gniazdowski