about summary refs log tree commit diff
path: root/Completion/Zsh/Type
diff options
context:
space:
mode:
authorOliver Kiddle <opk@zsh.org>2016-06-22 01:30:22 +0200
committerOliver Kiddle <opk@zsh.org>2016-06-22 01:30:22 +0200
commit139a4dbe07728a22dcb120d1ca9ff3cdae98471a (patch)
tree3967a7b2dffeda20d91a153b02e561785d542d47 /Completion/Zsh/Type
parentaed754980b29a20e7ec01faaa4dbdd0ccfde0ad4 (diff)
downloadzsh-139a4dbe07728a22dcb120d1ca9ff3cdae98471a.tar.gz
zsh-139a4dbe07728a22dcb120d1ca9ff3cdae98471a.tar.xz
zsh-139a4dbe07728a22dcb120d1ca9ff3cdae98471a.zip
38735: support verbose style to allow clearer but less compact descriptions for time specifiers
Diffstat (limited to 'Completion/Zsh/Type')
-rw-r--r--Completion/Zsh/Type/_globquals24
1 files changed, 20 insertions, 4 deletions
diff --git a/Completion/Zsh/Type/_globquals b/Completion/Zsh/Type/_globquals
index ed9c008a1..6eef16877 100644
--- a/Completion/Zsh/Type/_globquals
+++ b/Completion/Zsh/Type/_globquals
@@ -1,7 +1,7 @@
 #autoload
 
-local state=qual expl char delim timespec
-local -a alts tdisp sdisp
+local state=qual expl char delim timespec default
+local -a alts tdisp sdisp tmatch smatch
 local -A specmap
 
 while [[ -n $PREFIX ]]; do
@@ -118,11 +118,27 @@ while [[ -n $PREFIX ]]; do
       timespec=$PREFIX[1]
       if ! compset -P '[Mwhmsd]' && [[ -z $PREFIX ]]; then
 	tdisp=( seconds minutes hours days weeks Months )
-        alts+=( "time-specifiers:time specifier:compadd -E 0 -d tdisp -S '' - s m h d w M" )
+	tmatch=( s m h d w M )
+	if zstyle -t ":completion:${curcontext}:time-specifiers" verbose; then
+	  zstyle -s ":completion:${curcontext}:time-specifiers" list-separator sep || sep=--
+          print -v tdisp -f "%s ${sep//(#m)[%\\]/$MATCH$MATCH} %s\0" ${tmatch:^^tdisp}
+	  tdisp=( ${(0)tdisp} )
+	fi
+	alts+=( "time-specifiers:time specifier:compadd -E 0 -d tdisp -S '' -a tmatch" )
       fi
       if ! compset -P '[-+]' && [[ -z $PREFIX ]]; then
 	sdisp=( before exactly since )
-        alts+=("senses:sense:compadd -E 0 -d sdisp -S '' - + '' -")
+	smatch=( - '' + )
+	if zstyle -t ":completion:${curcontext}:senses" verbose; then
+	  zstyle -s ":completion:${curcontext}:senses" list-separator sep || sep=--
+	  default=" [default exactly]"
+	  sdisp=( "- $sep before" "+ $sep since" )
+	  smatch=( - + )
+	else
+	  sdisp=( before exactly since )
+	  smatch=( - '' + )
+	fi
+        alts+=( "senses:sense${default}:compadd -E 0 -d sdisp -S '' -a smatch" )
       fi
       specmap=( M months w weeks h hours m minutes s seconds '(|+|-|d)' days)
       alts+=('digits:digit ('${${specmap[(K)${timespec:-d}]}:-invalid time specifier}'):_dates -f ${${timespec/[-+]/d}:-d} -S ""' )