Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Setting the 'completer' style - _match and **
- X-seq: zsh-users 21950
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: Setting the 'completer' style - _match and **
- Date: Tue, 20 Sep 2016 08:54:31 +0000
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=/91x0jvsBt2xwdEP ODM6voxqWO8=; b=fz0iWQbnJKXoC7A19E7Shz2Kxc5H35dKB1qlG1TD03KitXVh jKIFuxpZjWd13azz5JVqyh2+iyIFQbWJ1zMTTI1M8EY9EeItdT46KzubNTEQSEiH GHa7PS5pwTEQxzi76/2WYZPVKZDI3GPQS2S4nQgqodM1I+vthTNRAl3yl8w=
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=/91x0jvsBt2xwdE PODM6voxqWO8=; b=Xjc19MyaxhVzSWJ2e1d0TGzIYnoA7JQl8OlKOwYOdIJG6DJ 0cbGYJ0mOGH86UPBsln+Ck38Q67vQSLBtGrLEyzafJgYAMtxEMh5barr41fHX7Xf r9AJXjpqoWiTSavlYPcHbNWr+0s5QPBv0oCr8y+t+d44ppBcsv7Rf9Ub7PbA=
- In-reply-to: <160919074515.ZM28018__10595.0927398682$1474296416$gmane$org@torch.brasslantern.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <20160912233028.GA17257@fujitsu.shahaf.local2> <160919074515.ZM28018__10595.0927398682$1474296416$gmane$org@torch.brasslantern.com>
[ Your MUA seems to have changed the subject: your email has a hyphen
where the email you reply to had an em dash. ]
Bart Schaefer wrote on Mon, Sep 19, 2016 at 07:45:15 -0700:
> On Sep 12, 11:30pm, Daniel Shahaf wrote:
> }
> } I've come up with the following:
> } .
> } bindkey $'\t' complete-word
> } zstyle ':completion:*' completer _all_matches _match-ds _expand _complete _ignored
> } _match-ds() {
> } [[ $PREFIX$SUFFIX != *[*][*]* ]] && _match "$@"
> } }
> } .
> } The idea is that if a pattern contains "**" then _match('s wrapper) will
> } leave it for _expand to process.
> }
> } Is there another way to implement this?
>
> You could probably come up with a "zstyle -e" formulation that would only
> include_match in the completer value in the right circurmstances.
How would I do that? I think the "right circumstances" are [[ $curtag
== *(file|dir)* ]], but the 'completer' style is looked up under the
context :completion:::::, before tags are known.
I tried to workaround that by defining a compadd() wrapper function that
checks $curtag before calling the builtin compadd, but that caused
«: **/generic*<TAB>» to complete nothing.
> I'll note in passing that _match is supposed to be used after _complete,
The documentation says so too, but gives no rationale, and empirically
it works before _complete too. Why should _match be later than _complete?
> not before _expand. Might it be better to suppress the _expand completer
> in the cases where you want _match rather than the other way around?
Perhaps I could do something like this:
.
_match-ds2() {
_match "$@"
if that added no matches; then
curcontext=${curcontext/:match-ds2:/expand}
_expand "$@"
fi
}
.
where the condition is implemented using $? or $compstate[nmatches], and
remove _expand from the 'completer' style entirely. I'll give this
a shot later.
I want _match basically everywhere; when I want _expand I can invoke it
directly with ^X* <expand-word>. I even use _match as
.
rsync -[ap]<TAB>
.
to get the description of the -p option without getting a screenful of
other options.
Thanks for the answer,
Daniel
Messages sorted by:
Reverse Date,
Date,
Thread,
Author