Subject: Re: _history-complete-older problems with $(
From: Daniel Shahaf <[email-masked]>
To: Sebastian Gniazdowski <[email-masked]>
Cc: Bart Schaefer <[email-masked]>, Zsh hackers list <[email-masked]>
Date: Wed, 13 Jan 2016 01:01:36 +0000
List-Id: Zsh Workers List <zsh-workers.zsh.org>

Sebastian Gniazdowski wrote on Tue, Jan 12, 2016 at 14:09:47 +0100:
> On 12 January 2016 at 01:15, Bart Schaefer <[email-masked]> wrote:
> >   _widen_for_history () {
> >     local -a left=( "${(z)LBUFFER}" )

Strictly speaking, ${(z)} should always be applied to $PREBUFFER$LBUFFER
or $PREBUFFER$BUFFER, not merely to $BUFFER, otherwise things like
string literals with embedded newlines can confuse the result.

> > This needs some work around the issue of empty words, i.e., when
> > completing in empty parens such as $(<TAB>) then $words[CURRENT] is
> > empty and the trailing paren must be copied from $RBUFFER to SUFFIX.
> > I haven't dived into that detail.
> 
> I would gladly perform the work but the code is quite difficult. Could
> you state in one sentence what it is doing?

Bart's function runs the _history completer with $words modified to
reflect the entire command-line "list"¹ rather than only the "simple
command"¹ the cursor happens to be in.

Cheers,

Daniel

¹ Terms from zshmisc(1).