Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Matching Control with anchors between characters



Felix Rosencrantz wrote:

> I don't completely understand matching control.  I use it and it's wonderful,
> but it's still a mystery to me.  I did attempt to read the manual a bit when I
> was first converting over to zsh.  One thing that seemed to be missing, was the
> ability to specify anchors between characters.  In particular, I wanted to
> configure anchors between numbers and non-numbers so that f2 could match
> something like filesystem2.  None of the examples seemed to talk about this.  
> 
> Since, there is some discussion about patterns that match the gaps between
> characters, it would be nice if this would also work for the anchor patterns of
> matching control. 

Yes, I've been thinking about adding something like this to the
manual, too -- and then forgot, as usual. I would have used the match
spec used by the functions that complete X colour names as an example, 
which allows to use the uppercase letters (and digits) as shortcuts.

The same is possible with digits. The point is that, different from
what the examples we give seem to imply, the anchor need not be
anything special:

  % ls
  foo1 foo2 foo3
  % zstyle ':completion:*:*:foo:*' matcher 'r:|[0-9]=* r:|=*'
  % foo f2<TAB>
 ->
  % foo foo2

See? The colour thing:

  % xterm -fg IR<TAB>
 ->
  % xterm IndianRed
  IndianRed   IndianRed1  IndianRed2  IndianRed3  IndianRed4

or

  % xterm -fg IR4<TAB>
 ->
  % xterm -fg IndianRed4

Isn't live just fun? Sometimes.

> Or maybe someone will just point out my misunderstanding and supply a matching
> specification that does what I want.  I'd be willing to add the example to the
> manual.

Wow, someone offers to improve the manual... I'd be very thankful.

Bye
 Sven


--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



Messages sorted by: Reverse Date, Date, Thread, Author