Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Path with spaces in _canonical_paths
- X-seq: zsh-workers 51043
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- Cc: zsh-workers@xxxxxxx, Thomas Gläßle <thomas@xxxxxxxxxx>
- Subject: Re: Path with spaces in _canonical_paths
- Date: Wed, 23 Nov 2022 13:36:00 -0800
- Archived-at: <https://zsh.org/workers/51043>
- In-reply-to: <20221123141357.GL27622@tarpaulin.shahaf.local2>
- List-id: <zsh-workers.zsh.org>
- References: <sympa.1668791373.628329.85325.773@zsh.org> <CAH+w=7ZBYX3-X2AD_iDR6T4Yz8OdA1TE+YeC2qZmHdk+W=VbgA@mail.gmail.com> <cd447ee7-d991-a4fd-c155-ca1b6bb96d72@coldfix.de> <CAH+w=7ZHODk-ZKPLvXiyd6s17uO+fnC-vgxnHvyGnnrqzr7vrQ@mail.gmail.com> <45820bd7-fab6-70f5-5abb-dc444f6f1075@coldfix.de> <CAH+w=7a1_O7nBO4jUH2otCnjvcW+tJmzPHqm_Zw+CVJtM_PyJw@mail.gmail.com> <20221123141357.GL27622@tarpaulin.shahaf.local2>
On Wed, Nov 23, 2022 at 6:14 AM Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
>
> Bart Schaefer wrote on Mon, Nov 21, 2022 at 13:32:41 -0800:
> > On Mon, Nov 21, 2022 at 9:41 AM Thomas Gläßle <thomas@xxxxxxxxxx> wrote:
> > >
> > > + local -a tmp_buffer
> > > + compadd -A tmp_buffer "$__gopts[@]" -a files
> > > [...]
> > > + matches+=( "${(@)tmp_buffer/$canpref/$origpref}" )
> > > else
> > > # ### Ideally, this codepath would do what the 'if' above does,
> > > # ### but telling compadd to pretend the "word on the command line"
> > > # ### is ${"the word on the command line"/$origpref/$canpref}.
> > > - matches+=(${${(M)files:#$canpref*}/$canpref/$origpref})
> > > + matches+=(${${(M)tmp_buffer:#$canpref*}/$canpref/$origpref})
> > > fi
>
> The comment quoted above concerns how the candidate completions are
> compared to the word on the command line. The comment says that,
> instead of applying s/foo/bar/ to the word on the command line and
> comparing the result against the raw candidate completions, the reverse
> is done — s/bar/foo/ is applied to the candidate completions and that's
> compared to the raw word on the command line
Hrm, but in both cases (even before the diff) the substitution is
s/$canpref/$origpref/ ? Your explanation here would seem to imply
that in at least the second case the substitution should look like
s/$origpref/$canpref/. The difference is that in the first case
$tmp_buffer is the result of filtering with "compadd ... files" and in
the second case we're altering the elements of $files directly.
> Adding or removing -Q or {(@)} (or ${(b)}, cf. workers/39080) might well
> be independent of that issue, though.
I believe the difference here is also compadd -- it performs the
quoting changes that -Q then has to account for. So when we modify
$files directly in the second branch, we have to also emulate the
quote behavior of compadd. My previous suggested patch perhaps didn't
go far enough in that direction?
Messages sorted by:
Reverse Date,
Date,
Thread,
Author