mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-17 15:01:40 +02:00
users/15621: compdef -p/-P <pat>=<service>
users/15622: use service with _pick_variant
This commit is contained in:
parent
32ce1cdd79
commit
8d00aca697
4 changed files with 31 additions and 4 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,5 +1,15 @@
|
||||||
2010-12-06 Peter Stephenson <pws@csr.com>
|
2010-12-06 Peter Stephenson <pws@csr.com>
|
||||||
|
|
||||||
|
* users/15622: Completion/Base/Utility/_pick_variant: use
|
||||||
|
$service rather than $words[1] to pick the service. Although
|
||||||
|
there may be cases where this doesn't work, this provides
|
||||||
|
transparent behaviour for simple uses along the lines of
|
||||||
|
"compdef <_func> <cmd>=<service>"
|
||||||
|
|
||||||
|
* users/15621: Completion/compinit,
|
||||||
|
Completion/Base/Core/dispatch: fix setting service for compef
|
||||||
|
-p/-P.
|
||||||
|
|
||||||
* Mikael: 28487: Doc/Zsh/builtins.yo, Doc/Zsh/expn.yo,
|
* Mikael: 28487: Doc/Zsh/builtins.yo, Doc/Zsh/expn.yo,
|
||||||
Doc/Zsh/options.yo, Doc/Zsh/prompt.yo: fix docs to refer to
|
Doc/Zsh/options.yo, Doc/Zsh/prompt.yo: fix docs to refer to
|
||||||
current directory rather than $PWD.
|
current directory rather than $PWD.
|
||||||
|
@ -13910,5 +13920,5 @@
|
||||||
|
|
||||||
*****************************************************
|
*****************************************************
|
||||||
* This is used by the shell to define $ZSH_PATCHLEVEL
|
* This is used by the shell to define $ZSH_PATCHLEVEL
|
||||||
* $Revision: 1.5143 $
|
* $Revision: 1.5144 $
|
||||||
*****************************************************
|
*****************************************************
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
local comp pat val name i ret=1 _compskip="$_compskip"
|
local comp pat val name i ret=1 _compskip="$_compskip"
|
||||||
local curcontext="$curcontext" service str noskip
|
local curcontext="$curcontext" service str noskip
|
||||||
|
local -a match mbegin mend
|
||||||
|
|
||||||
# If we get the option `-s', we don't reset `_compskip'.
|
# If we get the option `-s', we don't reset `_compskip'.
|
||||||
|
|
||||||
|
@ -24,6 +25,10 @@ if [[ "$_compskip" != (all|*patterns*) ]]; then
|
||||||
[[ -n "$str" ]] || continue
|
[[ -n "$str" ]] || continue
|
||||||
service="${_services[$str]:-$str}"
|
service="${_services[$str]:-$str}"
|
||||||
for i in "${(@)_patcomps[(K)$str]}"; do
|
for i in "${(@)_patcomps[(K)$str]}"; do
|
||||||
|
if [[ $i = (#b)"="([^=]#)"="(*) ]]; then
|
||||||
|
service=$match[1]
|
||||||
|
i=$match[2]
|
||||||
|
fi
|
||||||
eval "$i" && ret=0
|
eval "$i" && ret=0
|
||||||
if [[ "$_compskip" = *patterns* ]]; then
|
if [[ "$_compskip" = *patterns* ]]; then
|
||||||
break
|
break
|
||||||
|
|
|
@ -7,7 +7,7 @@ local -A opts
|
||||||
(( $+_cmd_variant )) || typeset -gA _cmd_variant
|
(( $+_cmd_variant )) || typeset -gA _cmd_variant
|
||||||
|
|
||||||
zparseopts -D -A opts c: r:
|
zparseopts -D -A opts c: r:
|
||||||
: ${opts[-c]:=$words[1]}
|
: ${opts[-c]:=${service:-$words[1]}}
|
||||||
|
|
||||||
while [[ $1 = *=* ]]; do
|
while [[ $1 = *=* ]]; do
|
||||||
var+=( "${1%%\=*}" "${1#*=}" )
|
var+=( "${1%%\=*}" "${1#*=}" )
|
||||||
|
|
|
@ -230,6 +230,10 @@ comppostfuncs=()
|
||||||
|
|
||||||
compdef() {
|
compdef() {
|
||||||
local opt autol type func delete new i ret=0 cmd svc
|
local opt autol type func delete new i ret=0 cmd svc
|
||||||
|
local -a match mbegin mend
|
||||||
|
|
||||||
|
emulate -L zsh
|
||||||
|
setopt extendedglob
|
||||||
|
|
||||||
# Get the options.
|
# Get the options.
|
||||||
|
|
||||||
|
@ -364,10 +368,18 @@ compdef() {
|
||||||
else
|
else
|
||||||
case "$type" in
|
case "$type" in
|
||||||
pattern)
|
pattern)
|
||||||
_patcomps[$1]="$func"
|
if [[ $1 = (#b)(*)=(*) ]]; then
|
||||||
|
_patcomps[$match[1]]="=$match[2]=$func"
|
||||||
|
else
|
||||||
|
_patcomps[$1]="$func"
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
postpattern)
|
postpattern)
|
||||||
_postpatcomps[$1]="$func"
|
if [[ $1 = (#b)(*)=(*) ]]; then
|
||||||
|
_postpatcomps[$match[1]]="=$match[2]=$func"
|
||||||
|
else
|
||||||
|
_postpatcomps[$1]="$func"
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
if [[ "$1" = *\=* ]]; then
|
if [[ "$1" = *\=* ]]; then
|
||||||
|
|
Loading…
Reference in a new issue