about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2012-09-03 11:12:15 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2012-09-03 11:12:15 +0000
commitd3891edfca77ce587585990135242247a48595fc (patch)
tree061a77d2a9a70b5d8a34c7894ead1e5a1d393931
parent260b433632310e847b5c540f2812cc0856576273 (diff)
downloadzsh-d3891edfca77ce587585990135242247a48595fc.tar.gz
zsh-d3891edfca77ce587585990135242247a48595fc.tar.xz
zsh-d3891edfca77ce587585990135242247a48595fc.zip
users/12713: returning REPLY to _user_expand sets description for expansion
-rw-r--r--ChangeLog8
-rw-r--r--Completion/Base/Completer/_user_expand13
-rw-r--r--Doc/Zsh/compsys.yo4
3 files changed, 17 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index c7dbbecf8..a2f9e8ac2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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 $
 *****************************************************
diff --git a/Completion/Base/Completer/_user_expand b/Completion/Base/Completer/_user_expand
index 049cc31ef..cf3d172f0 100644
--- a/Completion/Base/Completer/_user_expand
+++ b/Completion/Base/Completer/_user_expand
@@ -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
diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo
index 2787f66a7..2991c1f4a 100644
--- a/Doc/Zsh/compsys.yo
+++ b/Doc/Zsh/compsys.yo
@@ -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()
 )