Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: Re: optional argument?
- X-seq: zsh-workers 11003
- From: Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx
- Subject: PATCH: Re: optional argument?
- Date: Fri, 28 Apr 2000 13:14:41 +0200 (MET DST)
- In-reply-to: Tanaka Akira's message of 28 Apr 2000 18:44:23 +0900
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
Tanaka Akira wrote:
> In article <200004250945.LAA03283@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
> Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx> writes:
>
> > At the weekend I hacked on _arguments (and comparguments) to allow
> > _arguments to complete more than one action when appropriate. And the
> > case above is of course one of cases where it is done.
>
> It's good change, in general. But I found a problem.
>
> Z(4):akr@serein% Src/zsh -f
> serein% bindkey -e; fpath=($PWD/Completion/*(/)); autoload -U compinit; compinit -D; compdef _tst tst
> serein% _tst () { _arguments '-o:o:(o)' ':a:(a)' }
> serein% tst -o <TAB>
> a o
>
> It shouldn't complete `a' because `o' is not optional.
Of course. Getting that right really isn't all that easy...
Bye
Sven
Index: Src/Zle/computil.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/computil.c,v
retrieving revision 1.9
diff -u -r1.9 computil.c
--- Src/Zle/computil.c 2000/04/25 11:49:11 1.9
+++ Src/Zle/computil.c 2000/04/28 11:13:52
@@ -1399,7 +1399,8 @@
for (; arg && (arg->num < 0 ||
(arg->min <= ca_laststate.nth + addopt &&
arg->num >= ca_laststate.nth));) {
- if (!opt && (lopt = arg->type != CAA_OPT) && oopt > 0)
+ lopt = (arg->type == CAA_OPT);
+ if (!opt && !lopt && oopt > 0)
oopt = 0;
addlinknode(descr, arg->descr);
@@ -1446,7 +1447,7 @@
}
}
}
- if (!single && opt && !lopt) {
+ if (!single && opt && lopt) {
opt = NULL;
arg = ca_get_arg(ca_laststate.d, ca_laststate.nth);
--
Sven Wischnowsky wischnow@xxxxxxxxxxxxxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author