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

I have one idea. It's generally about detecting a syntax error that
makes shell word unbound. By appending " x" to shell word and running
(Z+n+) one can obtain either 1 or 2 elements and first signals a
syntax error. For such case, SUFFIX would consist only from a space
delimited part of the regular right part.

Best regards,
Sebastian Gniazdowski

On 14 January 2016 at 11:14, Sebastian Gniazdowski
<[email-masked]> wrote:
> On 14 January 2016 at 10:52, Sebastian Gniazdowski
> <[email-masked]> wrote:
>> PS. I used the "find LBUFFER myself" approach to handle following case
>> better ("|" is cursor):
>>
>> % $(( 0 |+ 1 ))
>>
>> Doing ${(z)LBUFFER} and then (z) on right part of BUFFER would produce
>> SUFFIX="+" instead of "+ 1 ))".  If I find the word in ${(z)BUFFER}
>
> That turned out to be not true, (z) isn't done on right part, instead
> words[CURRENT] is utilized and chopped to obtain right part of shell
> word.
>
>     local -a left=( "${(z)LBUFFER}" )
>     local right="${words[CURRENT]#${left[-1]}}"
>
> So still clarifying things, maybe it's good idea to do (z) on right
> part to obtain ${|a case behavior.
>
> Best regards,
> Sebastian Gniazdowski