zsh-users
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: "Zsh Users' List" <zsh-users@sunsite.dk>
Subject: Re: Completing a unique prefix of "script" completes "script"
Date: Sun, 13 Aug 2006 17:34:53 +0100	[thread overview]
Message-ID: <200608131634.k7DGYr8V002934@pwslaptop.csr.com> (raw)
In-Reply-To: Message from "Nikolai Weibull" <now@bitwi.se>  of "Sun, 13 Aug 2006 16:59:54 +0200." <dbfc82860608130759t7d67f5c5w152184322272becf@mail.gmail.com>

"Nikolai Weibull" wrote:
> On 8/10/06, Peter Stephenson <p.w.stephenson@ntlworld.com> wrote:
> 
> > zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[.,_-]=**r:|=
> **'
> 
> What exactly are the 'r's doing here?

That's become a bit garbled: the bit we're referring to should look like

'r:|[.,_-]=** r:|=**'

There's a fairly full description of this in MATCHING CONTROL in the
zshcompwid manual page---in something of the sense of "I couldn't walk
across the English Channel because the sea was fairly full", so I'll
summarise here.  The general form is

r:LPAT|RANCHOR=TPAT

where LPAT has to occur on the left of the string already on the command
line, RANCHOR indicates something at the right hand end of the string on
the line, and TPAT says what sort of pattern to use to try to match the
stuff in the middle when looking for possible completions.  The LPAT
isn't commonly used and if it's empty it has no particularly special
meaning.  The [.,_-] says look for any part of the code on the command
line which has any of the those characters to the right.  The ** then
says match anything there; a single * wouldn't allow the anchor,
i.e. the character out of that set in square brackets, to be matched
itself, so you'd have to have typed any anchor characters yourself.

The result is that something like u-l-o-h is matched as u*-l*-o*-h.
(If we'd used r:|[.,_-]=* those *'s wouldn't have matched further -'s,
as we've doubled the * they can.)

The r:|=** matches at the end of the string:  that's only necessary if
you're completing in the middle and want to act as if there was a *
there.  In other words, without it, u-l-o<CURSOR>-h would have been
treated as u*-l*-o*-h, with it it's treated as u*-l*-o*-h*.  (This
supposedly depends on COMPLETE_IN_WORD being set; if it isn't completion
always takes place at the end.)

Quite why this forces a distinction between script as an executablle and
script as a directory is one of the great mysteries of the modern world.

-- 
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


  reply	other threads:[~2006-08-13 16:35 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <now@bitwi.se>
2006-08-10 20:17 ` Nikolai Weibull
2006-08-10 21:41   ` Peter Stephenson
2006-08-13 14:49     ` Nikolai Weibull
2006-08-14 12:12       ` Peter Stephenson
2006-08-14 22:36         ` Nikolai Weibull
2006-08-13 14:59     ` Nikolai Weibull
2006-08-13 16:34       ` Peter Stephenson [this message]
2006-08-13 17:01         ` Nikolai Weibull
2006-11-21 22:57 ` Problem with _arguments Nikolai Weibull
2006-11-21 23:42   ` Peter Stephenson
2006-11-22  8:35     ` Nikolai Weibull
2006-11-22 10:39       ` Peter Stephenson
2006-11-22 15:55         ` Bart Schaefer
2006-11-22 22:22           ` Nikolai Weibull
2006-11-24 20:56             ` Bart Schaefer
2006-11-22 21:31         ` Nikolai Weibull

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=200608131634.k7DGYr8V002934@pwslaptop.csr.com \
    --to=p.w.stephenson@ntlworld.com \
    --cc=zsh-users@sunsite.dk \
    /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).