From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20560 invoked from network); 10 Jun 1999 10:58:00 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 10 Jun 1999 10:58:00 -0000 Received: (qmail 4212 invoked by alias); 10 Jun 1999 10:57:03 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6567 Received: (qmail 4205 invoked from network); 10 Jun 1999 10:57:01 -0000 Message-Id: <9906101022.AA40208@ibmth.df.unipi.it> To: zsh-workers@sunsite.auc.dk (Zsh hackers list) Subject: PATCH: pws-21: _vars Date: Thu, 10 Jun 1999 12:22:54 +0200 From: Peter Stephenson This extends the _vars completion, used after things like read and vared, to allow completion of the keys of associative arrays. However, the [ has to be added by hand because it can't tell whether you want the parameter or an element. Maybe there's a case for autoparamkeys behaviour --- but that would need sensitivity to the command context, which isn't really on. --- Completion/Base/_vars.old Tue Apr 13 09:37:37 1999 +++ Completion/Base/_vars Thu Jun 10 12:17:04 1999 @@ -1,3 +1,20 @@ #compdef getopts read unset vared -compgen -v +# This will handle completion of keys of associative arrays, e.g. at +# `vared compconfig['. However, in this version the [ must be +# added by hand. + +if [[ $PREFIX = *\[ ]]; then + local var=${PREFIX%%\[*} + local elt="${PREFIX#*\]}${SUFFIX%\]}" + local addclose + compset -p $(( ${#var} + 1 )) + if ! compset -S \]; then + addclose=(-S ']') + fi + if [[ ${(tP)var} = assoc* ]]; then + compadd $addclose ${(kP)var} + fi +else + compgen -v +fi -- Peter Stephenson Tel: +39 050 844536 WWW: http://www.ifh.de/~pws/ Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy