summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--Completion/Base/Utility/_arguments15
-rw-r--r--Doc/Zsh/compsys.yo23
3 files changed, 26 insertions, 18 deletions
diff --git a/ChangeLog b/ChangeLog
index f33f63631..dc161b387 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2001-04-26 Sven Wischnowsky <wischnow@zsh.org>
+
+ * 14117: Completion/Base/Utility/_arguments, Doc/Zsh/compsys.yo:
+ tweak to make single-letter options only be completed after an
+ option with an argument if the -W option is given
+
2001-04-26 Bart Schaefer <schaefer@zsh.org>
* 14108: Src/Modules/termcap.c: Don't define USES_TERM* if the
diff --git a/Completion/Base/Utility/_arguments b/Completion/Base/Utility/_arguments
index c68700763..3bd95687d 100644
--- a/Completion/Base/Utility/_arguments
+++ b/Completion/Base/Utility/_arguments
@@ -182,7 +182,7 @@ while [[ "$1" = -(O*|[CRWsw]) ]]; do
-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 @@ if (( $# )) && comparguments -i "$autod" "$singopt[@]" "$@"; then
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 @@ if (( $# )) && comparguments -i "$autod" "$singopt[@]" "$@"; then
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 @@ if (( $# )) && comparguments -i "$autod" "$singopt[@]" "$@"; then
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 @@ if (( $# )) && comparguments -i "$autod" "$singopt[@]" "$@"; then
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 @@ if (( $# )) && comparguments -i "$autod" "$singopt[@]" "$@"; then
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 @@ if (( $# )) && comparguments -i "$autod" "$singopt[@]" "$@"; then
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 \
diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo
index e89ac7cd2..040429d5d 100644
--- a/Doc/Zsh/compsys.yo
+++ b/Doc/Zsh/compsys.yo
@@ -2938,17 +2938,18 @@ where `tt(a)' takes an argument in the next word, tt(_arguments) would
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: