Zsh Mailing List Archive
Messages sorted by:
Re: _complete: insert unambiguous when globbing
- X-seq: zsh-users 27452
- From: Tomasz Pala <gotar@xxxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Cc: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: _complete: insert unambiguous when globbing
- Date: Wed, 5 Jan 2022 21:15:23 +0100
- Archived-at: <https://zsh.org/users/27452>
- In-reply-to: <20220105194643.GA13958@polanet.pl>
- List-id: <zsh-users.zsh.org>
- References: <20220103123903.GA20434@polanet.pl> <CAH+w=7YobgajzubM-nhbr39cHUn=WcaKMG4oXRkZiorWgdvbjg@mail.gmail.com> <20220105194643.GA13958@polanet.pl>
On Wed, Jan 05, 2022 at 20:46:43 +0100, Tomasz Pala wrote:
> However since it sacrifices ZLE-provided pattern it's not perfect.
> $ cd empty
> $ touch 2021.12.29-14:41:02.xz 2021.12.29-19:41:02.xz 2021.12.30-03:41:03.xz 2021.12.30-14:41:04.xz 2021.12.30-19:41:02.xz 2021.12.31-03:41:02.xz 2021.12.31-14:41:04.xz 2021.12.31-19:41:03.xz
> $ ls 2*04[tab] => 2021.12.3
> 2021.12.30-14:41:04.xz 2021.12.31-14:41:04.xz
> so the compstate[old_list]=keep was required for the second [tab] not to
> follow the updated ZLE contents. It works like a charm, but I wonder -
> what cases would be broken by compstate[old_list]=keep with such a weak
> condition? It would be much safer to have something like:
> if [[ $PREFIX = *'*'* ]]; then
> elif [ "$compstate[eat_globbing]" = 'true' ]; then
> but I can't find a way to pass this down.
OK, this was pretty straightforward:
if [[ $PREFIX = *'*'* ]]; then
elif [ "$_eat_asterisk" = 'true' ]; then
It sacrifices *-using glob only (more robust test required?) because
that signals rough pattern (we do not want to break some refined ones).
And the problem is "provided pattern" vs "unambiguous prefix"...
In general this problem is not trivial, since preserving the ZLE-provided
pattern while completing unambiguous part would require to distinguish,
how much of that pattern was already consumed and needs to be
dropped, preserving the rest; the remaining part must match the same
items being prepended by the unambiguous part.
Having said that - does this behaviour deserve upstreaming with it's own
zstyle, or is it too hacky?
This allows for incremental completion with repeating (manual) globbing
provisioning, which seems fine for some quick and dirty patterns like *z
(for *.xz files), tastes best with undo/redo in finger memory.
Tomasz Pala <gotar@xxxxxxxxxxxxx>
Messages sorted by: