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

Re: zsh-equivalent for tcsh option "set complete=enhance"?



Zoltan Hidvegi wrote:
> >From wischnow@xxxxxxxxxxxxxxxxxxxxxxx  Thu Oct 31 13:06:39 1996
> Because of that I won't be able to port the patch below to a newer
> version, so I'm sending it for 2.6beta19 (sorry).
> 
> It contains some thing I was playing with for some years now, in
> short:
> 
> - Completion character equivalence classes: some characters can stand
>   for others when completing (e.g. `-' can stand for `-' and `_'),
>   this is under complete user control.
> - An option to make completion case-insensitive.

I thought about this and (although I don't myself writing it without
several years more experience in the relevant code) I don't see why it
shouldn't be a little more general and in some sense zsh-like.

What I had in mind was that instead of using global arrays there is an
extra option to compctl (say -M for modify match) that says what can
be done to the command argument to make it match the candidate.  For
example,

-M 'c,E[[-_],],e[no,],E[\?,[A-Za-z]]'

says:

- this completion is to be performed with case-fold search (you'll see
this is the same as E[[A-Za-z],[A-Za-z]], but this is probably common
enough for a shorthand)

- any _ or - in the argument matches the empty string in the candidate
(and hence should be discarded) --- E specifies pattern matching

- likewise, the string 'no' is to be replaced with an empty one; (e
for a string; the e/E distinction is like extended completion) [this
replaces all no's, not just at the beginning, haven't thought what to
do about that]

- a real ? (because quoted) in the argument is equivalent to a single
alphabetic character in the candidate.

So, with the above

setopt no_SH_WO?D_SP<TAB>   ->    no_SH_WO?D_SPlit
                                          ^ not actually any use,
                                            just an example

Maybe a general pattern behaviour like this is too difficult and it
needs instead to involve character classes and strings instead.  I've
really no idea whether this double pattern matching is feasible in an
efficient fashion.  In fact, this is obviously going to be a lot
slower than Sven's proposal, although one only gets the overhead when
one needs it.

-- 
Peter Stephenson <pws@xxxxxx>       Tel: +49 33762 77366
WWW:  http://www.ifh.de/~pws/       Fax: +49 33762 77413
Deutsches Elektronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen
DESY-IfH, 15735 Zeuthen, Germany.



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