From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.dk
Subject: Re: problem with _arguments exclusion lists
Date: Thu, 26 Apr 2001 16:35:23 +0200 (MET DST) [thread overview]
Message-ID: <200104261435.QAA05286@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: <3AE828D4.A2EC6AEE@u.genie.co.uk>
Oliver Kiddle wrote:
> ...
>
> But if the word is empty, and the pattern matches, it does offer both
> message and options. I think this check should come before the
> _message and an empty $PREFIX$SUFFIX should prevent the failed return.
> Like this:
> [[ -n $PREFIX$SUFFIX && "$PREFIX$SUFFIX" != $~1 ]] && return 1
If we do that, no options will be completed after, e.g. `pine -c' (with
your patch), because then the action returned zero.
> The completion for vncserver (patch below) could use this so that it
> offers display numbers before the initial `:' is typed.
I admit that I never thought about using this in a normal-argument spec
(non-option-argument). Isn't that already covered enough by the normal
behaviour of _arguments? I.e., using some other action for that
argument that displays the message and handles the colon (I don't know
how this argument has to look like...).
> When, in the first message you say `the new behaviour of completing
> options if the action returns non-zero', I would have said that the
> behaviour was to be not claiming to complete the message when actions
> return non-zero so that completing other things, like options isn't
> blocked.
That part of the `behaviour' depends on whatever the action does,
obviously. And I think that the current behaviour of _guard is at least
a good default. As I said, we can give it an option to say what should
be done (returned) if the word is the empty string.
> > No, -w (now -W since I swapped them), makes it complete options
> > regardless of the return value of the action. What you're seeing
> > here
> > is the new default behaviour of trying to complete options if the
> > action returns non-zero.
>
> Oh. I thought it was going to not complete single letter options
> unless it had -W and -s and always complete long options. So how do I
> get _pine to work properly (use of _guard for _pine also in the
> patch):
>
> valid
> pine -cr4 produces an error message
>
> so pine -r<tab> offers other single letter options including -c pine
> -c<tab> should offer -conf, -character-set etc but not other single
> letter options like -r. It should also offer numbers.
[See? That last one... that's what you get with the current behaviour
of _guard and _arguments.]
> I thought the
> _arguments -W option was going to allow it to offer single letter
> options like -r for any command which allows options between an option
> and its argument where they are all in the same word. So -W wouldn't be
> used for pine and the -r option wouldn't be offered between -c and its
> number argument.
Ah, right. That makes sense. Patch below.
Bye
Sven
Index: Completion/Base/Utility/_arguments
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Utility/_arguments,v
retrieving revision 1.4
diff -u -r1.4 _arguments
--- Completion/Base/Utility/_arguments 2001/04/26 12:13:37 1.4
+++ Completion/Base/Utility/_arguments 2001/04/26 14:34:38
@@ -182,7 +182,7 @@
-R) rawret=yes; shift;;
-w) optarg=yes; shift;;
-s) singopt=(-s); shift;;
- -W) alwopt=yes; shift;;
+ -W) alwopt=arg; shift;;
esac
done
@@ -282,7 +282,7 @@
eval ws\=\( "${action[3,-3]}" \)
_describe -t "$subc" "$descr" ws -M "$matcher" "$subopts[@]" ||
- alwopt=yes
+ alwopt=${alwopt:-yes}
tried=yes
elif [[ "$action" = \(*\) ]]; then
@@ -292,7 +292,7 @@
eval ws\=\( "${action[2,-2]}" \)
_all_labels "$subc" expl "$descr" compadd "$subopts[@]" -a - ws ||
- alwopt=yes
+ alwopt=${alwopt:-yes}
tried=yes
elif [[ "$action" = \{*\} ]]; then
@@ -301,7 +301,7 @@
while _next_label "$subc" expl "$descr"; do
eval "$action[2,-2]" && ret=0
done
- (( ret )) && alwopt=yes
+ (( ret )) && alwopt=${alwopt:-yes}
tried=yes
elif [[ "$action" = \ * ]]; then
@@ -311,7 +311,7 @@
while _next_label "$subc" expl "$descr"; do
"$action[@]" && ret=0
done
- (( ret )) && alwopt=yes
+ (( ret )) && alwopt=${alwopt:-yes}
tried=yes
else
@@ -321,7 +321,7 @@
while _next_label "$subc" expl "$descr"; do
"$action[1]" "$subopts[@]" "$expl[@]" "${(@)action[2,-1]}" && ret=0
done
- (( ret )) && alwopt=yes
+ (( ret )) && alwopt=${alwopt:-yes}
tried=yes
fi
fi
@@ -340,7 +340,8 @@
PREFIX="$origpre"
IPREFIX="$origipre"
- if comparguments -s single; then
+ if [[ -z "$alwopt" || -z "$tried" || "$alwopt" = arg ]] &&
+ comparguments -s single; then
if [[ "$single" = direct ]]; then
_all_labels options expl option \
Index: Doc/Zsh/compsys.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compsys.yo,v
retrieving revision 1.119
diff -u -r1.119 compsys.yo
--- Doc/Zsh/compsys.yo 2001/04/26 13:03:24 1.119
+++ Doc/Zsh/compsys.yo 2001/04/26 14:34:41
@@ -2938,17 +2938,18 @@
normally not complete the other option directly after `tt(-a)', but it would
allow that if given the tt(-w) option.
-Similarly, the option tt(-W) may be given to force completion of options
-even after options that get an argument in the same word. For example,
-if a command takes the options `tt(a)' and `tt(b)', where `tt(a)' needs
-an argument in the same word, directly after the option character,
-tt(_arguments) would normally only execute the action for that argument
-and not offer other options as possible completions. If given the
-tt(-W) option, it will offer other options as possible completions after
-executing the action for the argument. Note that, depending on the
-action, this may mean that the other options can't really be completed,
-but at least they will be listed. For more control, use an utility
-function like tt(_guard) in the argument's action.
+Similarly, the option tt(-W) may be given together with tt(-s) to force
+completion of single-letter options even after options that get an
+argument in the same word. For example, if a command takes the options
+`tt(a)' and `tt(b)', where `tt(a)' needs an argument in the same word,
+directly after the option character, tt(_arguments) would normally only
+execute the action for that argument and not offer other single-letter
+options as possible completions. If given the tt(-W) option, it will
+offer other options as possible completions after executing the action
+for the argument. Note that, depending on the action, this may mean
+that the other options can't really be completed, but at least they will
+be listed. For more control, use an utility function like tt(_guard) in
+the argument's action.
The forms of var(optspec) are:
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
next prev parent reply other threads:[~2001-04-26 14:35 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-04-26 13:55 Oliver Kiddle
2001-04-26 14:35 ` Sven Wischnowsky [this message]
2001-05-04 16:20 ` Oliver Kiddle
2001-05-07 11:10 ` Sven Wischnowsky
2001-05-08 11:45 ` Oliver Kiddle
-- strict thread matches above, loose matches on Subject: below --
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
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
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=200104261435.QAA05286@beta.informatik.hu-berlin.de \
--to=wischnow@informatik.hu-berlin.de \
--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).