zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: Re: optional argument?
@ 2000-04-28 11:14 Sven Wischnowsky
  0 siblings, 0 replies; only message in thread
From: Sven Wischnowsky @ 2000-04-28 11:14 UTC (permalink / raw)
  To: zsh-workers


Tanaka Akira wrote:

> In article <200004250945.LAA03283@beta.informatik.hu-berlin.de>,
>   Sven Wischnowsky <wischnow@informatik.hu-berlin.de> 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@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2000-04-28 11:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-04-28 11:14 PATCH: Re: optional argument? Sven Wischnowsky

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).