zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: Re: _arguments questions
Date: Tue, 4 Apr 2000 14:54:22 +0200 (MET DST)	[thread overview]
Message-ID: <200004041254.OAA09834@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: Alexandre Duret-Lutz's message of 04 Apr 2000 12:24:31 +0200


Alexandre Duret-Lutz wrote:

> ...
> 
> I have some troubles with nested `_arguments'...
> 
>   _foo () { 
>     _arguments -c -d -e
>   }
> 
>   _test () {
>     _arguments -a -b '-c:*::blah: _foo'
>   }
> 
> The wanted behaviour is that any arguments given after the first `-c' shall
> complete to `-c', `-d', or `-e'.  Unfortunately:
> 
>   phobos% compdef _test test
>   phobos% test -c -<TAB>
>   -a   -b
> 
> Strange. Tracing trough the code, I found that the call to `_arguments' in
> `_foo' returned 1 because `compargument -i' ensures that CURRENT > 1.

It has to do that because it has to parse a whole command line -- and
skip the command.

> Indeed, if I add a dummy option after the first `-c' it completes right :
> 
>   phobos% test -c -dummy -<TAB>
>   -c   -d   -e
> 
> Then, I can try to add this dummy word automatically :
> 
>   _bar () {
>     words=(dummy $words)
>     (( ++CURRENT ))
>     _foo
>   }
> 
>   _test () {
>     _arguments -a -b '-c:*::blah: _bar'
>   }
> 
> But the behaviour is now
> 
>   phobos% test -c -<TAB>
>   -a   -b   -c   -d   -e
> 
> with unwanted `-a' and `-b'. 

This is a bug. Result of 9621. Fixed by the patch below.

> ...
> 
> So questions are
>  1) is there a simplier way to nest `_arguments' ?

I don't see any. Sorry. Adding more syntactic sugar to the
_argument specs to support this doesn't seem worth it unless we put 
it into the <action>. Then it's quite simple (making _arguments
insert the dummy, probably using the option name for it).

Should we?


Bye
 Sven

Index: Src/Zle/computil.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/computil.c,v
retrieving revision 1.3
diff -u -r1.3 computil.c
--- Src/Zle/computil.c	2000/04/03 15:27:15	1.3
+++ Src/Zle/computil.c	2000/04/04 12:47:54
@@ -1427,7 +1427,8 @@
 	if ((ca_laststate.opt || (ca_laststate.doff && ca_laststate.def) ||
 	     (ca_laststate.def &&
 	      (ca_laststate.def->type == CAA_OPT ||
-	       ca_laststate.def->type >= CAA_RARGS))) &&
+	       (ca_laststate.def->type >= CAA_RARGS &&
+		ca_laststate.def->num < 0)))) &&
 	    (!ca_laststate.def || ca_laststate.def->type < CAA_RARGS ||
 	     (ca_laststate.def->type == CAA_RARGS ?
 	      (ca_laststate.curpos == ca_laststate.argbeg + 1) :

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


             reply	other threads:[~2000-04-04 12:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-04-04 12:54 Sven Wischnowsky [this message]
2000-04-04 15:59 ` Alexandre Duret-Lutz
2000-04-05  8:11 Sven Wischnowsky
2000-04-05  9:28 ` Alexandre Duret-Lutz
2000-04-05  9:43 Sven Wischnowsky
2000-04-05 12:03 Sven Wischnowsky
2000-04-05 13:01 ` Alexandre Duret-Lutz

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=200004041254.OAA09834@beta.informatik.hu-berlin.de \
    --to=wischnow@informatik.hu-berlin.de \
    --cc=zsh-workers@sunsite.auc.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).