From: Peter Stephenson <pws@ibmth.df.unipi.it>
To: zsh-workers@sunsite.auc.dk (Zsh hackers list)
Subject: _subscript
Date: Mon, 21 Jun 1999 15:56:45 +0200 [thread overview]
Message-ID: <9906211356.AA38873@ibmth.df.unipi.it> (raw)
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 <pws@ibmth.df.unipi.it> Tel: +39 050 844536
WWW: http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy
reply other threads:[~1999-06-21 14:26 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9906211356.AA38873@ibmth.df.unipi.it \
--to=pws@ibmth.df.unipi.it \
--cc=zsh-workers@sunsite.auc.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).