Zsh Mailing List Archive
Messages sorted by:
Re: Questions about completion matchers
- X-seq: zsh-users 27130
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Marlon Richert <marlon.richert@xxxxxxxxx>
- Cc: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: Questions about completion matchers
- Date: Wed, 22 Sep 2021 16:25:41 -0700
- Archived-at: <https://zsh.org/users/27130>
- In-reply-to: <CAHLkEDuT6iGYEivrHcML-dEaTMJUiGy-p39=2=kDEw1gL0i=Ew@mail.gmail.com>
- List-id: <zsh-users.zsh.org>
- References: <CAHLkEDuT6iGYEivrHcML-dEaTMJUiGy-p39=2=kDEw1gL0i=Ew@mail.gmail.com>
On Tue, Sep 21, 2021 at 2:23 AM Marlon Richert <marlon.richert@xxxxxxxxx> wrote:
> How can I make a matcher that completes the right-most part (and only
> the right-most part) of each subword?
I would not try to do this with a matcher specification ... someone
else (Oliver?) may be able to give a more accurate answer, but I don't
think matchers are very good at splitting up words unless there is an
anchor character ("." or "-" for example) to subdivide the words. I
know there's an example that purports to handle a similar situation,
but the more you want to constrain it ("only the right-most part") the
uglier it gets.
Instead I'd probably write a completer function that creates a
modified words array using match-words-by-style, then compset the
appropriate prefix and suffix. But I haven't gone very far down that
> * What is the exact difference between l:lanchor||ranchor=tpat and
> r:lanchor||ranchor=tpat ?
Again I'm not the ultimate expert here, but "lanchor" always has to
appear on the command line and with "l:" it has to appear to the left
of the matched substring (but not inside it) and with "r:" it has to
appear to the right of the matched substring (but again not inside
it). In both cases ranchor has to appear in the potential completion
result (the "trial completion") but might bound a range on the command
line if it does match there.
In practice I've nearly always seen these to be empty strings.
> * Why do the examples in the manual add r:|=* to the end of each
> matcher? This appears to make no difference at all.
All of my real-life uses are "r:|=**" ... I don't know the answer to this one.
> * How are the match descriptions inside a matcher evaluated
> and what causes the difference between these?
I believe they're applied left to right and each one constrains the
possibilities seen by the next, based on what's already on the command
line when you invoke completion.
Messages sorted by: