zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: _arguments (was: Re: odd diff completion)
Date: Thu, 15 Jun 2000 10:06:47 +0200 (MET DST)	[thread overview]
Message-ID: <200006150806.KAA06014@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: Clint Adams's message of Wed, 14 Jun 2000 09:53:20 -0400


Clint Adams wrote:

> Under 3.1.9:
> 
> diff pars<TAB>
> completes to diff parse.c
> 
> Under yesterday's CVS:
> 
> diff pars<TAB>
> completes to diff parsB

Ahem. Sorry, under certain conditons ca_get_sopt() returned an option
even for non-option strings.


In another message:

> > The `-A -*' doesn't mean that it complete ignores all unknown strings
> > starting with a hyphen, it just means that it doesn't stop completing
> > options if it finds undescribed `-foo's.
> 
> > So, you still have to give it the `--{install,...}' to make it ignore
> > it. Or you use the `= ' trick together with the `::' trick, as in:
> > 
> >            '(-i)--install:*::Debian packages:= ->install' \
> 
> I'm confused.  If I omit the '--{install,...}', doesn't that make
> --install an undescribed -foo, and thus it shouldn't stop completing
> options?

I've now had a look and am of the opinion, that the behaviour is the
right thing. The install case uses multiple sets. For multiple sets,
_arguments has to detect undescribed options and it has to stop trying 
to complete a set if there is a string not covered by the descriptions 
for that set on the line (otherwise it couldn't make the sets be
mutually exclusive).

We could make the -A pattern be used there, the patch below contains
the code for that, #if'ed out with a marker comment above it. However,
that would defeat the purpose of multiple sets, i.e. the sets are then 
not mutually exclusive if we use a simple pattern like -*. One would
then need a pattern that exactly matches all possible options -- not
very user-friendly.

So the solution for the current state of _arguments, which I don't
want to change is to include the --install etc. in the second call to
_arguments, that makes everything work as you want. BUT, I'd be
willing to give some more help for this. The only things I could think 
of are:

- an option, say -I, which gives an array of options which are to be
  ignored but not completed
- or, probably more more user-friendly, yet another optspec syntax
  describing options which are to be ignored but not completed; for
  example, if we find a syntax that starts with a special string for
  that, one could use <not>${^_dpkg_actions} in the second call to
  _arguments to make it skip all options described in $_dpkg_options

I think I prefer the latter (or both). Anyone got an idea for an
acceptable syntax? Or other suggestions?

Bye
 Sven

Index: Src/Zle/computil.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/computil.c,v
retrieving revision 1.29
diff -u -r1.29 computil.c
--- Src/Zle/computil.c	2000/06/13 12:14:32	1.29
+++ Src/Zle/computil.c	2000/06/15 07:20:53
@@ -1083,7 +1083,7 @@
     LinkList l = NULL;
 
     *lp = NULL;
-    for (p = NULL; *line; line++)
+    for (p = NULL; *line; line++) {
 	if ((p = d->single[STOUC(*line)]) && p->active &&
 	    p->args && p->name[0] == pre) {
 	    if (p->type == CAO_NEXT) {
@@ -1100,8 +1100,10 @@
 		}
 		break;
 	    }
-	} else if (!p || (!p->active && p->name[0] != pre))
+	} else if (p && !p->active)
 	    return NULL;
+	p = NULL;
+    }
     if (p && end)
 	*end = line;
     return p;
@@ -1444,7 +1446,14 @@
 		state.opt = 0;
 	    else
 		state.curopt = NULL;
-	} else if (multi && (*line == '-' || *line == '+') && cur != compcurrent)
+	} else if (multi && (*line == '-' || *line == '+') && cur != compcurrent
+#if 0
+		   /**** Ouch. Using this will disable the mutual exclusion
+			 of different sets. Not using it will make the -A
+			 pattern be effectively ignored with multiple sets. */
+		   && (!napat || !pattry(napat, line))
+#endif
+		   )
 	    return 1;
 	else if (state.arg && (!napat || !pattry(napat, line))) {
 	    /* Otherwise it's a normal argument. */

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


             reply	other threads:[~2000-06-15  8:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-06-15  8:06 Sven Wischnowsky [this message]
2000-06-16 15:19 ` PATCH: _arguments and _dpkg Clint Adams

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=200006150806.KAA06014@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).