* PATCH: use new splitting mechanism for _sequence
@ 2014-10-11 22:22 Oliver Kiddle
0 siblings, 0 replies; only message in thread
From: Oliver Kiddle @ 2014-10-11 22:22 UTC (permalink / raw)
To: Zsh workers
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:)-] ))
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2014-10-11 22:30 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-11 22:22 PATCH: use new splitting mechanism for _sequence Oliver Kiddle
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).