From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19678 invoked from network); 14 Sep 1999 08:17:59 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 14 Sep 1999 08:17:59 -0000 Received: (qmail 23820 invoked by alias); 14 Sep 1999 08:17:50 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7819 Received: (qmail 23813 invoked from network); 14 Sep 1999 08:17:48 -0000 Date: Tue, 14 Sep 1999 10:17:47 +0200 (MET DST) Message-Id: <199909140817.KAA26718@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@sunsite.auc.dk In-reply-to: Tanaka Akira's message of 14 Sep 1999 05:32:47 +0900 Subject: Re: The options variable of _arguments. Tanaka Akira wrote: > Z(2):akr@is27e1u11% Src/zsh -f > is27e1u11% bindkey -e; fpath=($PWD/Completion/*(/)); autoload -U compinit; compinit -D; compdef _tst tst > is27e1u11% _tst () { _arguments -s '-a' '-b' ':descr:{ compadd - $+options[-a] }' } > is27e1u11% tst -ab > > -> > > is27e1u11% tst -ab 0 > > Hm. It should be: > > is27e1u11% tst -ab 1 Right. For single-character options the `options' assoc wasn't correctly set. This also documents that `expl' may be use inside actions. Bye Sven diff -u oldcompletion/Base/_arguments Completion/Base/_arguments --- oldcompletion/Base/_arguments Tue Sep 14 09:09:00 1999 +++ Completion/Base/_arguments Tue Sep 14 10:16:27 1999 @@ -8,7 +8,7 @@ local args rest ws cur nth def nm expl descr action opt arg tmp xor local single uns ret=1 aret soptseq soptseq1 sopts prefix _line odescr local beg optbeg argbeg nargbeg inopt inrest fromrest cmd="$words[1]" -local matched curopt noargs +local matched curopt noargs i # Associative arrays used to collect information about the options. @@ -433,7 +433,9 @@ if (( $+opts[$tmp] )); then def="$opts[$tmp]" curopt="$tmp" - _options[$curopt]='' + for i in ${(s::)ws[1][2,-1]}; do + _options[${ws[1][1]}$i]='' + done optbeg="$beg" argbeg="$beg" inopt=yes @@ -646,6 +648,9 @@ def="$dopts[$tmp[1]]" opt='' uns="${prefix[2,-1]%%${tmp[1][2]}*}${tmp[1][2]}" + for i in ${(s::)prefix[2,-1]%%${tmp[1][2]}*} ${tmp[1][2]}; do + _options[${prefix[1]}$i]='' + done break elif compset -P "$tmp[1]"; then @@ -667,6 +672,9 @@ def="$odopts[$tmp[1]]" opt='' uns="${prefix[2,-1]%%${tmp[1][2]}*}${tmp[1][2]}" + for i in ${(s::)prefix[2,-1]%%${tmp[1][2]}*} ${tmp[1][2]}; do + _options[${prefix[1]}$i]='' + done break elif compset -P "$tmp[1]"; then def="$odopts[$tmp[1]]" diff -u od/Zsh/compsys.yo Doc/Zsh/compsys.yo --- od/Zsh/compsys.yo Tue Sep 14 09:08:51 1999 +++ Doc/Zsh/compsys.yo Tue Sep 14 10:12:51 1999 @@ -819,7 +819,10 @@ otherwise it will be invoked with some extra string placed after the first word which can be given as arguments to the tt(compadd) and tt(compgen) builtins and which make sure that the var(message) given -in the description will be shown above the matches. +in the description will be shown above the matches. These arguments +are taken from the array parameter tt(expl) which will be set up +before executing the var(action) and hence may be used in it (normally +in an expansion like `tt($expl[@])'). In places where no sensible matches can be generated, the action should consist of only a space. This will make the var(message) be -- Sven Wischnowsky wischnow@informatik.hu-berlin.de