zsh-workers
 help / color / mirror / code / Atom feed
From: Abhijeet Rastogi <abhijeet.1989@gmail.com>
To: okiddle@yahoo.co.uk
Cc: zsh-workers@zsh.org
Subject: Re: String partial match from both left and right.
Date: Sun, 2 Sep 2018 10:07:32 +0530	[thread overview]
Message-ID: <CACXxYfzMDMZR7h_YoRD2uh_guuN-bVwkZsJwb91+xk52VdBScQ@mail.gmail.com> (raw)
In-Reply-To: <23890-1535713868.126845@ueVC.nT4d.iPhW>

[-- Attachment #1: Type: text/plain, Size: 2045 bytes --]

Hi,

Thanks, Peter.
And special thanks to Oliver for the excellent explanation so I could up on
what you gave me. I ended up using your approach.

On Fri, Aug 31, 2018 at 4:41 PM Oliver Kiddle <okiddle@yahoo.co.uk> wrote:

> Abhijeet Rastogi wrote:
> > function _hello {
> >     _values -s ' ' 'dashboards' foo bar foo-bar
> > }
> > compdef _hello hello
> >
> > And what I want is, if I do:-
> >
> > $hello bar<TAB>
> >
> > I want `foo-bar` to come in the completion menu. I figured that it has
> > something to do with mater-list but I can't seem to get it working.
>
> You're right that the matching control is the way to achieve this and in
> particular the 'l:|=*' specification.
>
> > zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'l:|=* r:|=*'
>
> That sets a global matcher to apply for all completions. It will first
> try case-insensitive matching and then try again with extra characters
> allowed at both the beginning (left) and end (right) of what has been
> typed. When you complete bar<tab>, the "bar" candidate will match when
> doing the initial case-insensitive match and is accepted. It then never
> gets to try the second matching rule.
>
> You need the l: spec in the first argument so it would work with either:
>   zstyle ':completion:*' matcher-list 'l:|=*'
> or:
>   zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z} l:|=* r:|=*'
>
> That assumes you don't have any other matcher-list styles with a more
> specific context.
>
> Also, as I mentioned setting matcher-list is a fairly global setting. If
> you only want this for hello then the matcher style might be more
> appropriate:
>   zstyle ':completion:*:hello:values:*' matcher 'l:|=*'
>
> Alternatively you might want to specify the matcher directly in the
> _hello function. For example:
>
>   function _hello {
>     _wanted dashboards expl 'dashboard' compadd -M 'l:|=*' foo bar foo-bar
>   }
>
> There are other things you might try, for example r:|-=* allows f-b to
> match foo-bar.
>
> Oliver
>


-- 
Cheers,
Abhijeet Rastogi (shadyabhi)

      reply	other threads:[~2018-09-02  4:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20180831102508epcas4p4e1fdd60db2ae6336248268c887908f23@epcas4p4.samsung.com>
2018-08-31 10:24 ` Abhijeet Rastogi
2018-08-31 11:01   ` Peter Stephenson
2018-08-31 11:11   ` Oliver Kiddle
2018-09-02  4:37     ` Abhijeet Rastogi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CACXxYfzMDMZR7h_YoRD2uh_guuN-bVwkZsJwb91+xk52VdBScQ@mail.gmail.com \
    --to=abhijeet.1989@gmail.com \
    --cc=okiddle@yahoo.co.uk \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).