From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3275 invoked from network); 21 Jun 1999 14:26:53 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 21 Jun 1999 14:26:53 -0000 Received: (qmail 28129 invoked by alias); 21 Jun 1999 14:25:24 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6766 Received: (qmail 28121 invoked from network); 21 Jun 1999 14:25:23 -0000 Message-Id: <9906211356.AA38873@ibmth.df.unipi.it> To: zsh-workers@sunsite.auc.dk (Zsh hackers list) Subject: _subscript Date: Mon, 21 Jun 1999 15:56:45 +0200 From: Peter Stephenson This is the current version (or, as I keep typing, versino, which doesn't mean anything in Italian either) of _subscript after applying Oliver's changes by hands, plus I've also added a `-V default' to the compadd's which keeps them from reordering the numbers. Otherwise menucompletion takes you through 1, 10, 11, 12, 2, etc. Hmm... I wonder if it would be possible to arrange for `print' formatting of parameter output in a general way by having a flag which allowed you to pass a whole set of arguments to print, like ${(x.-D.)foo}, where x is some flag that hasn't been used. Then the final result of expansion at that level would be effectively filtered through print -D (print would probably need some significant rewriting), and it would be easy to handle arrays so you could get output in columns by ${(x.-c.)foo}. Or maybe there's a better way. #compdef -subscript- 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 local list i j ind=( {1..${#${(P)${compstate[parameter]}}}} ) list=() for i in "$ind[@]"; do [[ "$i" = ${PREFIX}*${SUFFIX} ]] && list=( "$list[@]" "${(r:4:: ::):)i} $(print -D ${(P)${compstate[parameter]}[$i]})" ) done if [[ "$RBUFFER" = \]* ]]; then compadd -S '' -V default -y list - "$ind[@]" else compadd -S ']' -V default -y list - "$ind[@]" fi else _compalso -math- fi -- Peter Stephenson Tel: +39 050 844536 WWW: http://www.ifh.de/~pws/ Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy