Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: completion
- X-seq: zsh-workers 7478
- From: Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx
- Subject: Re: PATCH: completion
- Date: Wed, 25 Aug 1999 10:24:49 +0200 (MET DST)
- In-reply-to: Tanaka Akira's message of 25 Aug 1999 00:56:54 +0900
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
Tanaka Akira wrote:
> In article <199908231346.PAA03326@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
> Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx> writes:
>
> > '-opt:*::descr:action' # all args to the option
>
> Does this require the actual option?
It did. I wanted to allow this for the `rest arguments', too, and then
forgot to write it (again). Sorry.
The syntax is, of course: `*::descr:action'.
The patch also contains a hunk for `_vars_eq', making it use default
completion after the equal sign.
Bye
Sven
diff -u od/Zsh/compsys.yo Doc/Zsh/compsys.yo
--- od/Zsh/compsys.yo Mon Aug 23 15:47:49 1999
+++ Doc/Zsh/compsys.yo Wed Aug 25 10:19:54 1999
@@ -902,6 +902,11 @@
This describes how arguments are to be completed for which no
description with one of the first two forms was given. This also means
that any number of arguments can be completed.
+
+If there are two colons before the message (as in
+`tt(*::)var(message)tt(:)var(action)') the tt(words) special array and
+the tt(CURRENT) special parameter will be restricted to only the
+normal arguments when the var(Action) is executed or evaluated.
)
item(var(opt-spec)[var(description) ...])(
This describes an option and (if at least one var(description) is
diff -u -r oc/Base/_arguments Completion/Base/_arguments
--- oc/Base/_arguments Tue Aug 24 11:13:33 1999
+++ Completion/Base/_arguments Wed Aug 25 10:21:05 1999
@@ -7,7 +7,7 @@
local long args rest ws cur nth def nm expl descr action opt arg tmp
local single uns ret=1 soptseq soptseq1 sopts prefix line
-local beg optbeg argbeg
+local beg optbeg argbeg nargbeg inopt
# Associative arrays used to collect information about the options.
@@ -82,6 +82,16 @@
opts[$tmp]=''
fi
unset "oneshot[$tmp]"
+ elif [[ "$1" = \*::* ]]; then
+
+ # This is `*:...', describing `all other arguments', with argument
+ # range restriction.
+
+ if [[ "$1" = \*:::* ]]; then
+ rest="*${1[3,-1]}"
+ else
+ rest="$1"
+ fi
elif [[ "$1" = \*:* ]]; then
# This is `*:...', describing `all other arguments'.
@@ -125,8 +135,9 @@
nth=1
line=( "$words[1]" )
beg=2
-argbeg=2
-optbeg=2
+argbeg=1
+optbeg=1
+nargbeg=1
# ...until the current word is reached.
@@ -190,6 +201,7 @@
def="$opts[$ws[1]]"
optbeg="$beg"
argbeg="$beg"
+ inopt=yes
[[ -n "$oneshot[$ws[1]]" ]] && unset "opts[$ws[1]]"
else
uns=''
@@ -199,6 +211,7 @@
def="$opts[$tmp]"
optbeg="$beg"
argbeg="$beg"
+ inopt=yes
uns="${ws[1][2,-1]}"
opt=''
fi
@@ -242,6 +255,7 @@
[[ -n "$oneshot[$tmp[1]]" ]] && unset "dopts[$tmp[1]]"
if [[ "$def" = [^*]*[^\\]:*[^\\]:* ]]; then
def="${def#?*[^\\]:*[^\\]:}"
+ inopt=yes
else
def=''
fi
@@ -279,6 +293,7 @@
def="${def#?*[^\\]:*[^\\]:}"
optbeg="$beg"
argbeg="$beg"
+ inopt=yes
else
def=''
fi
@@ -303,6 +318,8 @@
if [[ -n "$opt" && -n "$arg" ]]; then
def=''
line=( "$line[@]" "$ws[1]" )
+ [[ -n "$inopt" ]] && nargbeg=$(( beg - 1 ))
+ inopt=''
(( nth++ ))
fi
fi
@@ -313,6 +330,8 @@
(( beg++ ))
done
+[[ -n "$inopt" ]] && nargbeg="$beg"
+
# Now generate the matches.
if [[ $#long -ne 0 && "$PREFIX" = --* ]]; then
@@ -339,12 +358,10 @@
# If we have none at all, use the one for this argument position.
def="$args[nth]"
- [[ -z "$def" ]] && def="$rest"
-
- if [[ "$def" = \** ]]; then
- def="${def#*[^\\]:}"
- [[ "$def" = :* ]] && def="$def[2,-1]"
- [[ "$def" = :* ]] && def="$def[2,-1]"
+ if [[ -z "$def" ]]; then
+ def="$rest"
+ optbeg="$nargbeg"
+ argbeg="$nargbeg"
fi
fi
@@ -456,6 +473,8 @@
def="$def[2,-1]"
beg=$optbeg
fi
+
+ [[ beg -ge $#words ]] && beg=$(( $#words - 1 ))
shift beg words
(( CURRENT -= beg ))
diff -u -r oc/Builtins/_vars_eq Completion/Builtins/_vars_eq
--- oc/Builtins/_vars_eq Tue Aug 24 11:13:35 1999
+++ Completion/Builtins/_vars_eq Wed Aug 25 09:08:07 1999
@@ -1,3 +1,7 @@
#compdef declare export integer local readonly typeset
-_parameters -q -S '='
+if compset -P '*='; then
+ _default
+else
+ _parameters -q -S '='
+fi
--
Sven Wischnowsky wischnow@xxxxxxxxxxxxxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author