mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-14 14:01:18 +02:00
28307: support new styles esp. vcs_info ones and allow quoted contexts again
This commit is contained in:
parent
5ca08eccd0
commit
30d6deb355
2 changed files with 124 additions and 10 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2010-10-01 Oliver Kiddle <opk@zsh.org>
|
||||||
|
|
||||||
|
* 28307: Completion/Zsh/Command/_zstyle: support new styles
|
||||||
|
especially vcs_info ones and allow quoted contexts again
|
||||||
|
|
||||||
2010-09-25 Peter Stephenson <p.w.stephenson@ntlworld.com>
|
2010-09-25 Peter Stephenson <p.w.stephenson@ntlworld.com>
|
||||||
|
|
||||||
* 28295 plus tweak for failure case: use lexer to split words
|
* 28295 plus tweak for failure case: use lexer to split words
|
||||||
|
@ -13677,5 +13682,5 @@
|
||||||
|
|
||||||
*****************************************************
|
*****************************************************
|
||||||
* This is used by the shell to define $ZSH_PATCHLEVEL
|
* This is used by the shell to define $ZSH_PATCHLEVEL
|
||||||
* $Revision: 1.5087 $
|
* $Revision: 1.5088 $
|
||||||
*****************************************************
|
*****************************************************
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#compdef zstyle
|
#compdef zstyle
|
||||||
|
|
||||||
local state context ostate line expl ctop suf
|
local state context ostate line expl ctop suf
|
||||||
local nm=$compstate[nmatches] taglist patterns pstyles
|
local nm=$compstate[nmatches] taglist patterns pstyles contexts
|
||||||
typeset -A opt_args styles
|
typeset -A opt_args styles
|
||||||
|
|
||||||
(( $+functions[_completers] )) ||
|
(( $+functions[_completers] )) ||
|
||||||
|
@ -25,6 +25,7 @@ _completers() {
|
||||||
# c completion
|
# c completion
|
||||||
# d chpwd
|
# d chpwd
|
||||||
# e line editor
|
# e line editor
|
||||||
|
# v vcs_info
|
||||||
# z zftp
|
# z zftp
|
||||||
# or any combination of the above,
|
# or any combination of the above,
|
||||||
# followed by a colon, followed by a state to enter, empty if none.
|
# followed by a colon, followed by a state to enter, empty if none.
|
||||||
|
@ -41,14 +42,21 @@ styles=(
|
||||||
cache-policy c:_functions
|
cache-policy c:_functions
|
||||||
call-command c:bool
|
call-command c:bool
|
||||||
command c:command
|
command c:command
|
||||||
|
command-path c:_dir_list
|
||||||
commands c:
|
commands c:
|
||||||
complete c:bool
|
complete c:bool
|
||||||
|
complete-options c:bool
|
||||||
completer c:completer
|
completer c:completer
|
||||||
condition c:bool
|
condition c:bool
|
||||||
cursor c:cursor
|
cursor c:cursor
|
||||||
|
delimiters c:
|
||||||
disabled c:bool
|
disabled c:bool
|
||||||
domains c:
|
domains c:
|
||||||
|
environ c:environ
|
||||||
expand c:
|
expand c:
|
||||||
|
extra-verbose c:bool
|
||||||
|
fake c:
|
||||||
|
fake-always c:
|
||||||
fake-files c:fake-files
|
fake-files c:fake-files
|
||||||
fake-parameters c:fake-params
|
fake-parameters c:fake-params
|
||||||
file-list c:bool
|
file-list c:bool
|
||||||
|
@ -99,6 +107,7 @@ styles=(
|
||||||
packageset c:packageset
|
packageset c:packageset
|
||||||
path c:_directories
|
path c:_directories
|
||||||
pager c:_command_names
|
pager c:_command_names
|
||||||
|
path-completion c:bool
|
||||||
pine-directory c:_directories
|
pine-directory c:_directories
|
||||||
ports c:_ports
|
ports c:_ports
|
||||||
prefix-hidden c:bool
|
prefix-hidden c:bool
|
||||||
|
@ -107,17 +116,18 @@ styles=(
|
||||||
range c:
|
range c:
|
||||||
recent-dirs-insert c:recent-dirs-insert
|
recent-dirs-insert c:recent-dirs-insert
|
||||||
regular c:bool
|
regular c:bool
|
||||||
|
rehash c:bool
|
||||||
remote-access c:bool
|
remote-access c:bool
|
||||||
remove-all-dups c:bool
|
remove-all-dups c:bool
|
||||||
select-prompt c:
|
select-prompt c:
|
||||||
select-scroll c:
|
select-scroll c:
|
||||||
separate-sections c:bool
|
separate-sections c:bool
|
||||||
|
show-completer c:bool
|
||||||
single-ignored c:single-ignored
|
single-ignored c:single-ignored
|
||||||
sort c:bool
|
sort c:bool
|
||||||
special-dirs c:sdirs
|
special-dirs c:sdirs
|
||||||
squeeze-slashes c:bool
|
squeeze-slashes c:bool
|
||||||
stop c:stop
|
stop c:stop
|
||||||
stop-keys c:
|
|
||||||
strip-comments c:bool
|
strip-comments c:bool
|
||||||
subst-globs-only c:bool
|
subst-globs-only c:bool
|
||||||
substitute c:bool
|
substitute c:bool
|
||||||
|
@ -127,6 +137,8 @@ styles=(
|
||||||
urls c:_urls
|
urls c:_urls
|
||||||
use-cache c:bool
|
use-cache c:bool
|
||||||
use-compctl c:urgh
|
use-compctl c:urgh
|
||||||
|
use-ip c:bool
|
||||||
|
use-perl c:bool
|
||||||
users c:_users
|
users c:_users
|
||||||
users-hosts c:user-host
|
users-hosts c:user-host
|
||||||
users-hosts-ports c:user-host-port
|
users-hosts-ports c:user-host-port
|
||||||
|
@ -160,6 +172,24 @@ styles=(
|
||||||
word-style e:word-style
|
word-style e:word-style
|
||||||
word-context e:
|
word-context e:
|
||||||
|
|
||||||
|
formats v:vcs-format
|
||||||
|
actionformats v:vcs-format
|
||||||
|
branchformat v:branch-format
|
||||||
|
nvcsformats v:
|
||||||
|
stgitformat v:stg-format
|
||||||
|
max-exports v:
|
||||||
|
enable v:vcs
|
||||||
|
disable v:vcs
|
||||||
|
disable-patterns v:
|
||||||
|
check-for-changes v:bool
|
||||||
|
stagedstr v:
|
||||||
|
unstagedstr v:
|
||||||
|
command v:_command_names
|
||||||
|
use-server v:bool
|
||||||
|
use-simple v:bool
|
||||||
|
get-revision v:bool
|
||||||
|
use-prompt-escapes v:bool
|
||||||
|
|
||||||
chpwd z:bool
|
chpwd z:bool
|
||||||
progress z:progress
|
progress z:progress
|
||||||
remote-glob z:bool
|
remote-glob z:bool
|
||||||
|
@ -193,14 +223,19 @@ while (( $#state )); do
|
||||||
case "$state[1]" in
|
case "$state[1]" in
|
||||||
(contexts)
|
(contexts)
|
||||||
if [[ ! -prefix :*: ]]; then
|
if [[ ! -prefix :*: ]]; then
|
||||||
_wanted contexts expl context compadd -P : -qS : completion zftp
|
_wanted contexts expl context compadd -P : -qS : completion vcs_info zftp
|
||||||
elif compset -P :completion:; then
|
elif compset -P :completion:; then
|
||||||
for ostate in functions _completers cmdorcont argument tag; do
|
contexts=( functions _completers cmdorcont argument tag )
|
||||||
|
elif compset -P :vcs_info:; then
|
||||||
|
contexts=( vcs-string user-context repo-root-name )
|
||||||
|
fi
|
||||||
|
if (( $#contexts )); then
|
||||||
|
for ostate in $contexts; do
|
||||||
compset -P '[^:]#:' || break
|
compset -P '[^:]#:' || break
|
||||||
done
|
done
|
||||||
suf=()
|
suf=()
|
||||||
compset -S ':*' || suf=( -qS: )
|
compset -S ':*' || suf=( -qS: )
|
||||||
[[ $ostate = tag ]] && suf=()
|
[[ $ostate = $contexts[-1] ]] && suf=()
|
||||||
if compset -P '(|\\)\((*\||)'; then # handle (x|y) patterns
|
if compset -P '(|\\)\((*\||)'; then # handle (x|y) patterns
|
||||||
suf=()
|
suf=()
|
||||||
compset -S '(|\\)[)|]*' ||
|
compset -S '(|\\)[)|]*' ||
|
||||||
|
@ -222,7 +257,7 @@ while (( $#state )); do
|
||||||
|
|
||||||
(styles)
|
(styles)
|
||||||
# Get the top-level context we're completing for, if any.
|
# Get the top-level context we're completing for, if any.
|
||||||
case $line[1] in
|
case ${(Q)line[1]} in
|
||||||
(:completion:*)
|
(:completion:*)
|
||||||
ctop=c
|
ctop=c
|
||||||
;;
|
;;
|
||||||
|
@ -235,6 +270,10 @@ while (( $#state )); do
|
||||||
ctop=z
|
ctop=z
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
(:vcs_info:*)
|
||||||
|
ctop=v
|
||||||
|
;;
|
||||||
|
|
||||||
(:zle:*)
|
(:zle:*)
|
||||||
ctop=e
|
ctop=e
|
||||||
;;
|
;;
|
||||||
|
@ -248,7 +287,7 @@ while (( $#state )); do
|
||||||
;;
|
;;
|
||||||
|
|
||||||
(style-arg)
|
(style-arg)
|
||||||
state+=( "${styles[$line[2]]#*:}" )
|
state+=( "${styles[${(Q)line[2]}]#*:}" )
|
||||||
;;
|
;;
|
||||||
|
|
||||||
(argument)
|
(argument)
|
||||||
|
@ -278,6 +317,18 @@ while (( $#state )); do
|
||||||
_wanted values expl completer _completers -p
|
_wanted values expl completer _completers -p
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
(environ)
|
||||||
|
if [[ "$PREFIX" = *\=* ]]; then
|
||||||
|
compstate[parameter]="${PREFIX%%\=*}"
|
||||||
|
compset -P 1 '*='
|
||||||
|
_value
|
||||||
|
else
|
||||||
|
suf=()
|
||||||
|
compset -S '=*' || suf=(-S '=')
|
||||||
|
_parameters -q $suf
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
(fsort)
|
(fsort)
|
||||||
_wanted values expl 'how to sort files' \
|
_wanted values expl 'how to sort files' \
|
||||||
compadd name size links time date modification access inode change reverse
|
compadd name size links time date modification access inode change reverse
|
||||||
|
@ -455,6 +506,64 @@ while (( $#state )); do
|
||||||
_wanted word-styles expl 'word style' compadd normal shell space
|
_wanted word-styles expl 'word style' compadd normal shell space
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
(vcs-string)
|
||||||
|
_wanted vcs expl vcs compadd $suf - \
|
||||||
|
${${(f)"$(_call_program vcs vcs_info_printsys 2>/dev/null)"}:#\#*}
|
||||||
|
;;
|
||||||
|
|
||||||
|
(vcs)
|
||||||
|
_wanted vcs expl vcs compadd \
|
||||||
|
${${(f)"$(_call_program vcs vcs_info_printsys 2>/dev/null)"}:#(\#|*-)*}
|
||||||
|
;;
|
||||||
|
|
||||||
|
(user-context)
|
||||||
|
_wanted user-contexts expl 'user context' compadd $suf default command
|
||||||
|
;;
|
||||||
|
|
||||||
|
(repo-root-name)
|
||||||
|
_message -e names 'repository root name'
|
||||||
|
;;
|
||||||
|
|
||||||
|
(vcs-format)
|
||||||
|
if [[ $PREFIX = *% ]]; then
|
||||||
|
compset -P '*%'
|
||||||
|
_values -s '' 'format replacement' \
|
||||||
|
's[the vcs in use]' \
|
||||||
|
'b[the current branch]' \
|
||||||
|
'a[an identifier describing the action]' \
|
||||||
|
'i[current revision no/id]' \
|
||||||
|
'c[details of staged changes]' \
|
||||||
|
'u[details of unstaged changes]' \
|
||||||
|
'r[repository name]' \
|
||||||
|
'S[subdirectory within repository]' \
|
||||||
|
'm[misc replacement - backend specific]'
|
||||||
|
else
|
||||||
|
_message -e formats 'vcs format'
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
|
(branch-format)
|
||||||
|
if [[ $PREFIX = *% ]]; then
|
||||||
|
compset -P '*%'
|
||||||
|
_values -s '' 'format replacement' \
|
||||||
|
'b[the current branch]' \
|
||||||
|
'r[current revision number]' \
|
||||||
|
else
|
||||||
|
_message -e formats 'vcs format'
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
|
(stg-format)
|
||||||
|
if [[ $PREFIX = *% ]]; then
|
||||||
|
compset -P '*%'
|
||||||
|
_values -s '' 'format replacement' \
|
||||||
|
'p[patch currently on top of the stack]' \
|
||||||
|
'c[the number of unapplied patches]'
|
||||||
|
else
|
||||||
|
_message -e formats 'vcs format'
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
(_*)
|
(_*)
|
||||||
${=state[1]} $suf
|
${=state[1]} $suf
|
||||||
;;
|
;;
|
||||||
|
|
Loading…
Reference in a new issue