zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <opk@u.genie.co.uk>
To: zsh-workers@sunsite.dk
Subject: Re: problem with _arguments exclusion lists
Date: Thu, 19 Apr 2001 15:01:48 +0100	[thread overview]
Message-ID: <3ADEEFCC.E3D1C6ED@u.genie.co.uk> (raw)
In-Reply-To: <200104171410.QAA08041@beta.informatik.hu-berlin.de>

Sven Wischnowsky wrote:
> 
> ;-) I understood you, really.  But I'm pretty sure there are programs
> that allow other (single letter) options after that `-c', meaning that
> either `-c's argument is the empty string or that it comes in the next
> word.  Or something.  So I still think we need a way to tell _arguments
> that either:
> 
> 1) after all `-x-:...' or `-x+:...' options other options may be
>    completed, or

I suppose this option would involve another option to _arguments like
-W and it would only be useful with -s.

> 2) that after some of those options other options may be completed, or

And, I suppose this would handle commands which are inconsistent in the
way they behave for different options. For the _arguments syntax, I
can't think of much better than some additional random character before
the colon.

I suppose that of these (2) covers more possible situations so is the
most complete but we could have both where the option (as per (1))
specifies a default and the syntax for (2) overrides it. Keeping this in
mind, if (1) is implemented, (2) could be added later if we find
inconsistent commands for which it is needed.

> All that is independent of what we choose to use as the default.  I.e.,
> if we leave the current behaviour the default or if we make completing
> options there the default (unless otherwise specified).

I would probably vote for the current behaviour being the default - that
is not completing other options in this case because it is probably more
common for commands to parse arguments that way and it keeps the number
of matches down.

> Or maybe I'm thinking way to complicated again and we should just make
> it try completing options in such places, too.  If the user has already

Possibly, but I would err on the side of making it not try completing
options in such places. When I type commands, I tend to specify them in
a clear sensible way rather than the most minimal way that command
happens to allow.

> started typing the argument of the option, other option names won't
> match anyway.

True. And if other option names do match, the user might be trying to
complete the option name so it is important that it is added as a
match.

> Leaves only the slight ugliness that `-c<TAB>' would
> offer other single-letter options as possible completions (if _arguments
> was given the -s options), even if the command doesn't allow that after
> options that get an argument.

That is really quite ugly and backs up my feeling that this should not be
the default.

> 3) (what you described) that the argument of option `-x+:...' has to
>    match a certain pattern and if it doesn't match, other options are to
>    be completed there.

I think it is a good idea to maybe complete options only if we fail to
complete the option argument because it avoids the ugliness mentioned
above. Would it be possible to use a tag-order style to put the options
last here?

I wouldn't want to put the pattern in _arguments though. What follows is
a separate issue really so is a bit of a divergence.

As a test, I created an _number like this:
[[ $PREFIX$SUFFIX = [0-9]# ]] || return 1
_message 'number' && return 0
And then used this _arguments:
_arguments -s '-c+:number:_number' '-conf'

Now, if I complete after -co, I get the message:
	No matches for: `number' or `corrections'
What _arguments should do in this case is see the return code from
_number and from it conclude that we are not completing a parameter to
-c because it failed. For (3), it could then complete other single
letter options (it should be adding -conf as a match regardless). This may
be more complicated but is how I think we should be specifying patterns
if we use option (3).

Incidentally, with this when completing after just -c, the message
`number' is displayed to indicate that what is expected is a number. It
does not look up the format style with the descriptions tag and display
it in bold (with my style settings). I think it should because `number'
is a group of matches the same as other things we complete (option,
user etc), it is just that we haven't generated as matches all possible
numbers.

We could have a general function which is called like _message to
say we are completing such and such sort of thing but are not adding the
actual matches because it doesn't make sense to. It could take an option
for specifying a pattern to compare against $PREFIX/$SUFFIX to allow it
to fail when appropriate.

Oliver


  reply	other threads:[~2001-04-19 14:02 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-04-12 14:32 Oliver Kiddle
2001-04-17  9:50 ` Sven Wischnowsky
2001-04-17 10:44   ` Oliver Kiddle
2001-04-17 11:28     ` Sven Wischnowsky
2001-04-17 13:55       ` Oliver Kiddle
2001-04-17 14:10         ` Sven Wischnowsky
2001-04-19 14:01           ` Oliver Kiddle [this message]
2001-04-20  8:31             ` Sven Wischnowsky
2001-04-23  8:59               ` Oliver Kiddle
2001-04-24 10:00                 ` Sven Wischnowsky
2001-04-26 11:00                   ` Oliver Kiddle
2001-04-26 12:10                     ` Sven Wischnowsky
2001-04-25  7:10                 ` Sven Wischnowsky
2001-04-26 13:55 Oliver Kiddle
2001-04-26 14:35 ` Sven Wischnowsky
2001-05-04 16:20   ` Oliver Kiddle
2001-05-07 11:10     ` Sven Wischnowsky
2001-05-08 11:45       ` Oliver Kiddle

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=3ADEEFCC.E3D1C6ED@u.genie.co.uk \
    --to=opk@u.genie.co.uk \
    --cc=zsh-workers@sunsite.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).