From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7372 invoked from network); 18 Jun 1999 10:02:12 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 18 Jun 1999 10:02:11 -0000 Received: (qmail 15391 invoked by alias); 18 Jun 1999 10:01:42 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6710 Received: (qmail 15384 invoked from network); 18 Jun 1999 10:01:41 -0000 Date: Fri, 18 Jun 1999 12:01:39 +0200 (MET DST) Message-Id: <199906181001.MAA13055@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@sunsite.auc.dk In-reply-to: "Kiddle, Oliver"'s message of Fri, 18 Jun 1999 10:30:48 +0100 Subject: Re: PATCH: New completions Kiddle, Oliver wrote: > The other patch (for _subscript) is a bit messy and can almost certainly be > improved. Basically it completes the index in an array by using -y to > supply a list of each array element. I find it very useful for pulling > single directories out of $manpath, $fpath etc. This didn't apply after 6689, so here is a modified patch for that -- with some other changes (I hope you find them acceptable). The list looks more like a select list and I avoided using `compgen -s'. Hm, `compgen -s', maybe we should document it that this is almost always unnecessary (after 6692). Or maybe we should even disallow the `-s' option for `compgen'. BUT: thank you for sharing your completion functions with us. I'd like to see more of this. Bye Sven --- oc/Base/_subscript Thu Jun 17 12:04:14 1999 +++ Completion/Base/_subscript Fri Jun 18 11:55:00 1999 @@ -1,10 +1,25 @@ #compdef -subscript- +local list ind + if [[ ${(Pt)${compstate[parameter]}} = assoc* ]]; then if [[ "$RBUFFER" = \]* ]]; then compadd -S '' - "${(@kP)${compstate[parameter]}}" else compadd -S ']' - "${(@kP)${compstate[parameter]}}" + fi +elif [[ ${(Pt)${compstate[parameter]}} = array* ]]; then + ind=( {1..${#${(P)${compstate[parameter]}}}} ) + list=() + for i in "$ind[@]"; do + [[ "$i" = ${PREFIX}*${SUFFIX} ]] && + list=( "$list[@]" "${(r:4:: ::):)i} ${(P)${compstate[parameter]}[$i]}" ) + done + + if [[ "$RBUFFER" = \]* ]]; then + compadd -S '' -y list - "$ind[@]" + else + compadd -S ']' -y list - "$ind[@]" fi else _compalso -math- -- Sven Wischnowsky wischnow@informatik.hu-berlin.de