1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-03 10:21:46 +02:00

users/12713: returning REPLY to _user_expand sets description for expansion

This commit is contained in:
Peter Stephenson 2012-09-03 11:12:15 +00:00
parent 260b433632
commit d3891edfca
3 changed files with 17 additions and 8 deletions

View file

@ -1,3 +1,9 @@
2012-09-03 Peter Stephenson <pws@csr.com>
* users/17213: Completion/Base/Completer/_user_expand,
Doc/Zsh/compsys.yo: allow REPLY to pass a description for an
expansion.
2012-08-27 Peter Stephenson <p.w.stephenson@ntlworld. com>
* Oliver (olipro): 30643: Completion/Linux/Command/_ipset:
@ -124,5 +130,5 @@
*****************************************************
* This is used by the shell to define $ZSH_PATCHLEVEL
* $Revision: 1.5712 $
* $Revision: 1.5713 $
*****************************************************

View file

@ -12,7 +12,7 @@ setopt localoptions nonomatch
[[ _matcher_num -gt 1 ]] && return 1
local exp word sort expr expl subd suf=" " asp tmp spec
local exp word sort expr expl subd suf=" " asp tmp spec REPLY
local -a specs reply
if [[ "$funcstack[2]" = _prefix ]]; then
@ -30,6 +30,7 @@ exp=("$word")
zstyle -a ":completion:${curcontext}" user-expand specs || return 1
for spec in $specs; do
REPLY=
case $spec in
('$'[[:IDENT:]]##)
# Spec is an associative array with explicit keys.
@ -85,9 +86,9 @@ fi
if [[ -z "$compstate[insert]" ]] ;then
if [[ "$sort" = menu ]]; then
_description expansions expl expansions "o:$word"
_description expansions expl "expansions${REPLY:+: $REPLY}" "o:$word"
else
_description -V expansions expl expansions "o:$word"
_description -V expansions expl "expansions${REPLY:+: $REPLY}" "o:$word"
fi
compadd "$expl[@]" -UQ -qS "$suf" -a exp
@ -98,9 +99,9 @@ else
local i j normal space dir
if [[ "$sort" = menu ]]; then
_description expansions expl expansions "o:$word"
_description expansions expl "expansions${REPLY:+: $REPLY}" "o:$word"
else
_description -V expansions expl expansions "o:$word"
_description -V expansions expl "expansions${REPLY:+: $REPLY}" "o:$word"
fi
normal=()
space=()
@ -120,7 +121,7 @@ else
(( $#space )) && compadd "$expl[@]" -UQ -qS " " -a space
(( $#normal )) && compadd "$expl[@]" -UQ -qS "" -a normal
fi
if _requested all-expansions expl 'all expansions'; then
if _requested all-expansions expl "all expansions${REPLY:+: $REPLY}"; then
local disp dstr
if [[ "${#${exp}}" -ge COLUMNS ]]; then

View file

@ -3180,7 +3180,9 @@ var(_func) is the name of a shell function whose name must begin with
tt(_) but is not otherwise special to the completion system. The function
is called with the trial word as an argument. If the word is to be
expanded, the function should set the array tt(reply) to a list of
expansions. The return status of the function is irrelevant.
expansions. Optionally, it can set tt(REPLY) to a word that will
be used as a description for the set of expansions.
The return status of the function is irrelevant.
)
endsitem()
)