Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: compctl -Tx 'w[0,...] ...' ...
- X-seq: zsh-workers 3534
- From: Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxxx
- Subject: Re: compctl -Tx 'w[0,...] ...' ...
- Date: Mon, 29 Sep 1997 08:29:17 +0200
- In-reply-to: "Bart Schaefer"'s message of Fri, 26 Sep 1997 12:45:53 -0700
"Bart Schaefer" wrote:
>
> What's the difference between
>
> compctl ... -- foo
>
> and
>
> compctl -Tx 'w[0,foo]' ...
>
> ?? Aside from the obvious fact that you can use multiple `compctl ...`
> commands but only one `compctl -Tx ...`.
>
> Take a look at this:
>
> ...
>
> The above turns every compctl that doesn't use -x (because -x completions
> can't be nested) into a single huge compctl -T. (It could probably be
> cleaned up a lot, especially the `stuff' loop for unfolding compctls that
> happen to have embedded newlines e.g. in -k '(...)' lists.)
>
> With some finagling, it ought to be possible to rewrite all the compctls
> that use -x in a similar manner, eventually reducing the entire collection
> of compctls (except for -C and -D) to one `compctl -T`.
>
> Now you may be wondering, what's the point of all this? Well, at first it
> was just a desire to have something like compctl -T but that kicked in only
> after everything else failed. (You can almost get this with -D, but only
> for commands that don't already have some other completion.)
Hm, using flags before a `-x' or `+' with no flags following it
(continue with default completion) aren't enough? Could I get an
example, please?
> Beyond that,
> though, it suggests that there may be a lot of redundant functionality in
> the completion code, which could without much effort be folded together.
>
Not that much, only the following lines could be removed:
else if (linredir ||
!(cmd &&
(((ccp = (Compctlp) compctltab->getnode(compctltab, cmd)) &&
(compc = ret = ccp->cc)) ||
((s = dupstring(cmd)) && remlpaths(&s) &&
(ccp = (Compctlp) compctltab->getnode(compctltab, s)) &&
(compc = ret = ccp->cc)))))
And doing it that way should be faster than the all in one `-T' version.
But I admit that I didn't think of using `-T' with `w[0,...]'...
> Also, if you convert all your compctls to one big -T like that, then you
> can replace 'w[0,string]' with 'W[0,pattern]' and get an effect that a few
> persistent zsh-users have been requesting for some years: pattern matching
> on the command name when defining a completion.
>
Huh? That wouldn't be that difficult to implement (I think) and I
don't remember a request for it...
Bye
Sven
--
Sven Wischnowsky wischnow@xxxxxxxxxxxxxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author