mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-12-09 18:51:46 +01:00
38735: support verbose style to allow clearer but less compact descriptions for time specifiers
This commit is contained in:
parent
aed754980b
commit
139a4dbe07
3 changed files with 38 additions and 10 deletions
|
|
@ -1,5 +1,9 @@
|
|||
2016-06-22 Oliver Kiddle <opk@zsh.org>
|
||||
|
||||
* 38735: Completion/Unix/Command/_find,
|
||||
Completion/Zsh/Type/_globquals: support verbose style to allow
|
||||
clearer but less compact descriptions for time specifiers
|
||||
|
||||
* 38733: Completion/X/Command/_rdesktop: completion for xfreerdp
|
||||
|
||||
2016-06-21 Peter Stephenson <p.stephenson@samsung.com>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#compdef find gfind
|
||||
|
||||
local curcontext="$curcontext" state_descr variant
|
||||
local -a state line args alts
|
||||
local curcontext="$curcontext" state_descr variant default
|
||||
local -a state line args alts disp smatch
|
||||
|
||||
_pick_variant -r variant gnu=GNU $OSTYPE -version
|
||||
|
||||
|
|
@ -101,7 +101,7 @@ case $variant in
|
|||
'-D[print diagnostics]:debug option:(help tree search stat rates opt exec)'
|
||||
'-O+[enable query optimisation]:level:(1 2 3)'
|
||||
'*-daystart'
|
||||
'-regextype:regexp syntax:(emacs posix-awk posix-basic posix-egrep posix-extended)'
|
||||
'-regextype:regexp syntax:(help findutils-default awk egrep ed emacs gnu-awk grep posix-awk posix-basic posix-egrep posix-extended posix-minimal-basic sed)'
|
||||
'*-warn'
|
||||
'*-nowarn'
|
||||
'*-xautofs'
|
||||
|
|
@ -147,13 +147,21 @@ _arguments -C $args \
|
|||
'*-user:user:_users' \
|
||||
'*-xdev' \
|
||||
'*-a' '*-o' \
|
||||
'*:directory:_files -/'
|
||||
'(-D -E -H -L -O -P -f -s -x --help --version)*:directory:_files -/'
|
||||
|
||||
if [[ $state = times ]]; then
|
||||
if ! compset -P '[+-]' || [[ -prefix '[0-9]' ]]; then
|
||||
disp=( 'before' 'exactly' 'since' )
|
||||
compstate[list]+=' packed'
|
||||
alts=( "senses:sense:compadd -V times -S '' -d disp - + '' -" )
|
||||
if zstyle -t ":completion:${curcontext}:senses" verbose; then
|
||||
zstyle -s ":completion:${curcontext}:senses" list-separator sep || sep=--
|
||||
default=" [default exactly]"
|
||||
disp=( "- $sep before" "+ $sep since" )
|
||||
smatch=( - + )
|
||||
else
|
||||
disp=( before exactly since )
|
||||
smatch=( - '' + )
|
||||
fi
|
||||
alts=( "senses:sense${default}:compadd -V times -S '' -d disp -a smatch" )
|
||||
fi
|
||||
alts+=( "times:${state_descr}:_dates -f d" )
|
||||
_alternative $alts
|
||||
|
|
|
|||
|
|
@ -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 ""' )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue