* _subscript
@ 1999-06-21 13:56 Peter Stephenson
0 siblings, 0 replies; only message in thread
From: Peter Stephenson @ 1999-06-21 13:56 UTC (permalink / raw)
To: Zsh hackers list
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1999-06-21 14:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-06-21 13:56 _subscript Peter Stephenson
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).