Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: New completions
- X-seq: zsh-workers 6710
- From: Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx
- Subject: Re: PATCH: New completions
- Date: Fri, 18 Jun 1999 12:01:39 +0200 (MET DST)
- In-reply-to: "Kiddle, Oliver"'s message of Fri, 18 Jun 1999 10:30:48 +0100
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
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@xxxxxxxxxxxxxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author