Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: use new splitting mechanism for _sequence
- X-seq: zsh-workers 33438
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: Zsh workers <zsh-workers@xxxxxxx>
- Subject: PATCH: use new splitting mechanism for _sequence
- Date: Sun, 12 Oct 2014 00:22:50 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s1024; t=1413066171; bh=yGJDKwRTSzC5NB/oXjGmVNUsK4w+ixgDXfZCZsZTGaI=; h=X-Yahoo-Newman-Id:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:From:To:Subject:MIME-Version:Content-Type:Content-ID:Date:Message-ID; b=10LSLON4rZ9JG7bge1fP1ux9xfNY52l+R3RcDhYmdthvoNamdLJ70/WP2OBE2TN8OjGZCJr9VkEa6N6B+Pe7VxHUf+QgMQGvJDHKuhVub938Z8rYi/sBEyOAVTTyYgDeb2QykCTej/cB17tJuLJt9hwQZ1ImC3LEFSuquWm5SiI=
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
This changes _sequence to use the new way of splitting strings with
a dynamic separator from 33423.
The patch also adds some quoting to cope with separators that need to be
quoted.
Oliver
diff --git a/Completion/Base/Utility/_sequence b/Completion/Base/Utility/_sequence
index 391e5f7..9167b8f 100644
--- a/Completion/Base/Utility/_sequence
+++ b/Completion/Base/Utility/_sequence
@@ -7,11 +7,11 @@
# -s sep : specify separator [defaults to comma]
# -d : duplicate values allowed
-local curcontext="$curcontext" nm="$compstate[nmatches]" pre nosep minus
+local curcontext="$curcontext" nm="$compstate[nmatches]" pre qsep nosep minus
local -a sep num pref suf end uniq dedup
zparseopts -D -a opts s:=sep n:=num p:=pref i:=pref P:=pref I:=suf S:=suf q=suf r:=suf R:=suf C:=cont d=uniq M: J: X: x:
-(( $#cont )) && curcontext="$curcontext%:*}:$cont[2]"
+(( $#cont )) && curcontext="${curcontext%:*}:$cont[2]"
(( $#sep )) || sep[2]=,
if (( $+suf[(r)-S] )); then
@@ -19,20 +19,20 @@ if (( $+suf[(r)-S] )); then
(( $#end )) && compset -S ${end}\* && suf=() && nosep=1
fi
+qsep="${sep[2]}"
+compquote -p qsep
if (( ! $#uniq )); then
(( $+pref[(r)-P] )) && pre="${(q)pref[pref[(i)-P]+1]}"
- typeset -T unique="${PREFIX#$pre}" uniq $sep[2]
- dedup=( ${(q)uniq[1,-2]} )
- unique="${SUFFIX}"
- dedup+=( ${(q)uniq[2,-1]} )
+ dedup=( "${(@)${(@ps.$qsep.)PREFIX#$pre}[1,-2]}" "${(@)${(@ps.$qsep.)SUFFIX}[2,-1]}" )
+ [[ -n $compstate[quoting] ]] || dedup=( ${(Q)dedup} )
fi
-if (( ! $#num )) || (( num[2] > 1 )) && ! compset -P $(( num[2] - 1 )) \*$sep[2]; then
- (( nosep )) || suf=( -S $sep[2] -r "$end[1]${sep[2][1]} \t\n\-" )
- compset -S ${sep[2]}\* && suf=()
- compset -P \*$sep[2] && pref=()
-else
+if (( $#num )) && compset -P $(( num[2] - 1 )) \*${(q)qsep}; then
pref=()
+else
+ (( ! nosep && (!$#num || num[2] > 1) )) && suf=( -S ${qsep} -r "$end[1]${(q)qsep[1]} \t\n\-" )
+ compset -S ${(q)qsep}\* && suf=()
+ compset -P \*${(q)qsep} && pref=()
fi
(( minus = argv[(ib:2:)-] ))
Messages sorted by:
Reverse Date,
Date,
Thread,
Author