about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSven Wischnowsky <wischnow@users.sourceforge.net>2000-05-08 08:16:32 +0000
committerSven Wischnowsky <wischnow@users.sourceforge.net>2000-05-08 08:16:32 +0000
commit92637abbb870dc35e1af9150741f7b11587a3350 (patch)
tree0720a090889ec58db87992e6a4e9712a1c939739
parentc15091b7d196c8fcc15bf8f13f8c7ccf62479b85 (diff)
downloadzsh-92637abbb870dc35e1af9150741f7b11587a3350.tar.gz
zsh-92637abbb870dc35e1af9150741f7b11587a3350.tar.xz
zsh-92637abbb870dc35e1af9150741f7b11587a3350.zip
misc. completion cleanups and changes (11242)
-rw-r--r--ChangeLog10
-rw-r--r--Completion/Builtins/_pids33
-rw-r--r--Completion/Builtins/_zstyle7
-rw-r--r--Completion/Commands/_complete_help6
-rw-r--r--Completion/Core/_all_labels2
-rw-r--r--Completion/Core/_approximate9
-rw-r--r--Completion/Core/_expand32
-rw-r--r--Completion/Core/_ignored58
-rw-r--r--Completion/Core/_main_complete16
-rw-r--r--Completion/Core/_prefix30
-rw-r--r--Completion/Core/_setup7
-rw-r--r--Doc/Zsh/compsys.yo42
-rw-r--r--Src/Zle/complete.mdd10
-rw-r--r--Src/Zle/complist.c2
14 files changed, 203 insertions, 61 deletions
diff --git a/ChangeLog b/ChangeLog
index 3703df67e..06aef3737 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2000-05-08  Sven Wischnowsky  <wischnow@informatik.hu-berlin.de>
+
+	* 11242: Completion/Builtins/_pids, Completion/Builtins/_zstyle,
+ 	Completion/Commands/_complete_help, Completion/Core/_all_labels,
+ 	Completion/Core/_approximate, Completion/Core/_expand,
+ 	Completion/Core/_ignored, Completion/Core/_main_complete,
+ 	Completion/Core/_prefix, Completion/Core/_setup,
+ 	Doc/Zsh/compsys.yo, Src/Zle/complete.mdd, Src/Zle/complist.c:
+ 	misc. completion cleanups and changes
+	
 2000-05-06  Bart Schaefer  <schaefer@zsh.org>
 
 	* 11236: Completion/Base/_arguments: Handle tabs between options
diff --git a/Completion/Builtins/_pids b/Completion/Builtins/_pids
index d3cf8a68e..5956ddb29 100644
--- a/Completion/Builtins/_pids
+++ b/Completion/Builtins/_pids
@@ -3,13 +3,21 @@
 # If given the `-m <pattern>' option, this tries to complete only pids
 # of processes whose command line match the `<pattern>'.
 
-local out list expl match desc listargs args
+local out list expl match desc listargs args all nm ret=1
 
 _tags processes || return 1
 
 if [[ "$1" = -m ]]; then
-  match="${2}*"
+  all=()
+  match="[[:blank:]]#${PREFIX}[0-9]#${SUFFIX}[[:blank:]]*[/[:blank:]]${2}*"
   shift 2
+elif [[ "$PREFIX$SUFFIX" = [0-9]# ]]; then
+  all=()
+  match="[[:blank:]]#${PREFIX}[0-9]#${SUFFIX}[[:blank:]]*"
+else
+  all=(-U)
+  match="*[[:blank:]]*[/[:blank:]]$PREFIX*$SUFFIX*"
+  nm="$compstate[nmatches]"
 fi
 
 zstyle -s ":completion:${curcontext}:processes" command args
@@ -20,9 +28,9 @@ if zstyle -T ":completion:${curcontext}:processes" verbose; then
   zstyle -s ":completion:${curcontext}:processes-list" command listargs
   (( $#listargs )) || listargs=( "$args[@]" )
   if [[ "$listargs" = "$args" ]]; then
-    list=("${(@Mr:COLUMNS-1:)${(f@)out}[2,-1]:#[ 	]#${PREFIX}[0-9]#${SUFFIX}[ 	]*${~match}}")
+    list=("${(@Mr:COLUMNS-1:)${(f@)out}[2,-1]:#${~match}}")
   else
-    list=("${(@Mr:COLUMNS-1:)${(f@)$(_call processes-list ps 2>/dev/null)}[2,-1]:#[ 	]#${PREFIX}[0-9]#${SUFFIX}[ 	]*${~match}}")
+    list=("${(@Mr:COLUMNS-1:)${(f@)$(_call processes-list ps 2>/dev/null)}[2,-1]:#${~match}}")
   fi
   desc=(-ld list)
 else
@@ -30,5 +38,18 @@ else
 fi
 
 _wanted processes expl 'process ID' \
-    compadd "$@" "$desc[@]" - \
-        ${${${(M)${(f)"${out}"}[2,-1]:#[ 	]#${PREFIX}[0-9]#${SUFFIX}[ 	]#*${~match}}## #}%% *}
+    compadd "$@" "$desc[@]" "$all[@]" - \
+        ${${${(M)${(f)"${out}"}[2,-1]:#${~match}}## #}%% *} && ret=0
+
+if [[ -n "$all" ]]; then
+  zstyle -s ":completion:${curcontext}:processes" insert-ids out || out=menu
+
+  case "$out" in
+  menu)   compstate[insert]=menu ;;
+  single) [[ $compstate[nmatches] -ne nm+1 ]] && compstate[insert]= ;;
+  *)      [[ ${#:-$PREFIX$SUFFIX} -gt ${#compstate[unambiguous]} ]] &&
+              compstate[insert]=menu ;;
+  esac
+fi
+
+return ret
diff --git a/Completion/Builtins/_zstyle b/Completion/Builtins/_zstyle
index b2bd1d5a8..995c8c6f2 100644
--- a/Completion/Builtins/_zstyle
+++ b/Completion/Builtins/_zstyle
@@ -31,12 +31,14 @@ styles=(
   group-name		 c:
   group-order		 c:tag
   groups		 c:_groups
+  guarded-completer      c:completer
   hidden		 c:bool
   hosts			 c:_hosts
   hosts-ports		 c:host-port
   users-hosts-ports	 c:user-host-port
   ignore-parents         c:ignorepar
   ignored-patterns	 c:
+  insert-ids             c:insert-ids
   insert-unambiguous	 c:bool
   last-prompt		 c:bool
   list			 c:listwhen
@@ -245,6 +247,11 @@ while [[ -n $state ]]; do
       _normal
       ;;
 
+    insert-ids)
+      _wanted values expl 'when to insert process IDs' \
+          compadd - menu single longer
+      ;;
+
     _*)
       ${=ostate}
       ;;
diff --git a/Completion/Commands/_complete_help b/Completion/Commands/_complete_help
index 6733111ff..b952480f8 100644
--- a/Completion/Commands/_complete_help
+++ b/Completion/Commands/_complete_help
@@ -9,9 +9,9 @@ _complete_help() {
 
   compadd() { return 1 }
   zstyle() {
-    local _f="${${(@)${(@)funcstack[2,(i)_(main_complete|complete|approximate|normal)]}:#_(wanted|requested|loop|try)}% *}"
+    local _f="${${(@)${(@)funcstack[2,(i)_(main_complete|complete|approximate|normal)]}:#_(wanted|requested|all_labels|next_label)}% *}"
 
-    [[ -z "$_f" ]] && _f="${${(@)funcstack[2,(i)_(main_complete|complete|approximate|normal)]}:#_(wanted|requested|loop|try)}"
+    [[ -z "$_f" ]] && _f="${${(@)funcstack[2,(i)_(main_complete|complete|approximate|normal)]}:#_(wanted|requested|all_labels|next_label)}"
 
     if [[ "$help_sfuncs[$2]" != *${_f}* ||
           "$help_styles[${2}${_f}]" != *${3}* ]]; then
@@ -77,7 +77,7 @@ styles in context ${i}"
 }
 
 _help_sort_tags() {
-  local f="${${(@)${(@)funcstack[3,(i)_(main_complete|complete|approximate|normal)]}:#_(wanted|requested|loop|try)}% *}"
+  local f="${${(@)${(@)funcstack[3,(i)_(main_complete|complete|approximate|normal)]}:#_(wanted|requested|all_labels|next_label)}% *}"
 
   if [[ "$help_funcs[$curcontext]" != *${f}* ||
         "$help_tags[${curcontext}${f}]" != *(${(j:|:)~argv})* ]]; then
diff --git a/Completion/Core/_all_labels b/Completion/Core/_all_labels
index 72d9d0317..f85478cb5 100644
--- a/Completion/Core/_all_labels
+++ b/Completion/Core/_all_labels
@@ -32,7 +32,7 @@ while comptags "-A$prev" "$1" curtag spec; do
     _description "$gopt" "${curtag%:*}" "$2" "$descr"
     curtag="${curtag%:*}"
 
-    "$4" "${(P@)2}" "${(@)argv[5,-1]}"
+    "$4" "${(P@)2}" "${(@)argv[5,-1]}" && ret=0
   else
     _description "$gopt" "$curtag" "$2" "$3"
 
diff --git a/Completion/Core/_approximate b/Completion/Core/_approximate
index 840c1729a..47fc9ce23 100644
--- a/Completion/Core/_approximate
+++ b/Completion/Core/_approximate
@@ -13,7 +13,14 @@
 local _comp_correct _correct_expl comax cfgacc redef
 local oldcontext="${curcontext}" opm="$compstate[pattern_match]"
 
-zstyle -s ":completion:${curcontext}:" max-errors cfgacc || cfgacc='2 numeric'
+if [[ "$1" = -a* ]]; then
+  cfgacc="${1[3,-1]}"
+elif [[ "$1" = -a ]]; then
+  cfgacc="$2"
+else
+  zstyle -s ":completion:${curcontext}:" max-errors cfgacc ||
+      cfgacc='2 numeric'
+fi
 
 # Get the number of errors to accept.
 
diff --git a/Completion/Core/_expand b/Completion/Core/_expand
index f75c626d3..985f21899 100644
--- a/Completion/Core/_expand
+++ b/Completion/Core/_expand
@@ -11,7 +11,12 @@ setopt localoptions nullglob
 
 [[ _matcher_num -gt 1 ]] && return 1
 
-local exp word sort expr expl subd suf=" "
+local exp word sort expr expl subd suf=" " force opt
+
+(( $# )) &&
+    while getopts gsco opt; do
+      force="$force$opt"
+    done
 
 if [[ "$funcstack[2]" = _prefix ]]; then
   word="$IPREFIX$PREFIX$SUFFIX"
@@ -21,8 +26,9 @@ fi
 
 # First, see if we should insert all *completions*.
 
-if zstyle -s ":completion:${curcontext}:" completions expr &&
-   [[ "${(e):-\$[$expr]}" -eq 1 ]]; then
+if [[ "$force" = *c* ]] ||
+   { zstyle -s ":completion:${curcontext}:" completions expr &&
+     [[ "${(e):-\$[$expr]}" -eq 1 ]] }; then
   compstate[insert]=all
   return 1
 fi
@@ -35,9 +41,10 @@ exp=("$word")
 # changes quoted spaces, tabs, and newlines into spaces and protects
 # this function from aborting on parse errors in the expansion.
 
-if { zstyle -s ":completion:${curcontext}:" substitute expr ||
-     { [[ "$curcontext" = expand-word:* ]] && expr=1 } } &&
-       [[ "${(e):-\$[$expr]}" -eq 1 ]]; then
+if [[ "$force" = *s* ]] ||
+   { { zstyle -s ":completion:${curcontext}:" substitute expr ||
+       { [[ "$curcontext" = expand-word:* ]] && expr=1 } } &&
+         [[ "${(e):-\$[$expr]}" -eq 1 ]] }; then
   exp=( ${(f)"$(print -lR - ${(e)exp//\\[ 	
 ]/ })"} ) 2>/dev/null
 else
@@ -52,9 +59,10 @@ subd=("$exp[@]")
 
 # Now try globbing.
 
-{ zstyle -s ":completion:${curcontext}:" glob expr ||
-  { [[ "$curcontext" = expand-word:* ]] && expr=1 } } &&
-    [[ "${(e):-\$[$expr]}" -eq 1 ]] &&
+[[ "$force" = *g* ]] ||
+  { { zstyle -s ":completion:${curcontext}:" glob expr ||
+      { [[ "$curcontext" = expand-word:* ]] && expr=1 } } &&
+        [[ "${(e):-\$[$expr]}" -eq 1 ]] } &&
     exp=( ${~exp} )
 
 # If we don't have any expansions or only one and that is the same
@@ -67,8 +75,10 @@ subd=("$exp[@]")
 # With subst-globs-only we bail out if there were no glob expansions,
 # regardless of any substitutions
 
-zstyle -s ":completion:${curcontext}:" subst-globs-only expr &&
-    [[ "${(e):-\$[$expr]}" -eq 1 && "$subd" = "$exp"(|\(N\)) ]] && return 1
+[[ "$force" = *o* ]] ||
+  { zstyle -s ":completion:${curcontext}:" subst-globs-only expr &&
+      [[ "${(e):-\$[$expr]}" -eq 1 ]] } && 
+        [[ "$subd" = "$exp"(|\(N\)) ]] && return 1
 
 # Now add as matches whatever the user requested.
 
diff --git a/Completion/Core/_ignored b/Completion/Core/_ignored
index 4046f4c2d..61d6d3ea5 100644
--- a/Completion/Core/_ignored
+++ b/Completion/Core/_ignored
@@ -2,30 +2,54 @@
 
 # Use ignored matches.
 
-(( $compstate[ignored] )) || return 1
+[[ _matcher_num -gt 1 || $compstate[ignored] -eq 0 ]] && return 1
 
-local comp i _comp_no_ignore=yes tmp expl
+local comp _comp_no_ignore=yes tmp expl \
+      _completer _completer_num _matcher _matchers _matcher_num
 
 zstyle -a ":completion:${curcontext}:" completer comp ||
   comp=( "${(@)_completers[1,_completer_num-1][(R)_ignored(|:*),-1]}" )
 
-for i in "$comp[@]"; do
-  if [[ "$i" != _ignored ]] && "$i"; then
-    if zstyle -s ":completion:${curcontext}:" single-ignored tmp &&
-       [[ $compstate[old_list] != shown && $compstate[nmatches] -eq 1 ]]; then
-      case "$tmp" in
-      show) compstate[insert]='' compstate[list]='list force' tmp='' ;;
-      menu)
-        compstate[insert]=menu
-        _description original expl original    
-        compadd "$expl[@]" -S '' - "$PREFIX$SUFFIX"
-        ;;
-      *) tmp='' ;;
-      esac
-    fi
+_completer_num=1
 
-    return 0
+for tmp in "$comp[@]"; do
+  if [[ "$tmp" = *:-* ]]; then
+    _completer="${${tmp%:*}[2,-1]//_/-}${tmp#*:}"
+    tmp="${tmp%:*}"
+  elif [[ $tmp = *:* ]]; then
+    _completer="${tmp#*:}"
+    tmp="${tmp%:*}"
+  else
+    _completer="${tmp[2,-1]//_/-}"
   fi
+  curcontext="${curcontext/:[^:]#:/:${_completer}:}"
+
+  zstyle -a ":completion:${curcontext}:" matcher-list _matchers ||
+      _matchers=( '' )
+
+  _matcher_num=1
+  for _matcher in "$_matchers[@]"; do
+    if [[ "$tmp" != _ignored ]] && "$tmp"; then
+      if zstyle -s ":completion:${curcontext}:" single-ignored tmp &&
+         [[ $compstate[old_list] != shown &&
+            $compstate[nmatches] -eq 1 ]]; then
+        case "$tmp" in
+        show) compstate[insert]='' compstate[list]='list force' tmp='' ;;
+        menu)
+          compstate[insert]=menu
+          _description original expl original    
+          compadd "$expl[@]" -S '' - "$PREFIX$SUFFIX"
+          ;;
+        esac
+      fi
+
+      return 0
+    fi
+
+    (( _matcher_num++ ))
+  done
+
+  (( _completer_num++ ))
 done
 
 return 1
diff --git a/Completion/Core/_main_complete b/Completion/Core/_main_complete
index c4672b61f..f079e38e2 100644
--- a/Completion/Core/_main_complete
+++ b/Completion/Core/_main_complete
@@ -20,14 +20,15 @@ setopt localoptions nullglob rcexpandparam extendedglob
 unsetopt markdirs globsubst shwordsplit nounset ksharrays
 
 local func funcs ret=1 tmp _compskip format nm \
-      _completers _completer _completer_num curtag \
+      _completers _completer _completer_num curtag _comp_force_list \
       _matchers _matcher _matcher_num _comp_tags _comp_mesg \
       context state line opt_args val_args curcontext="$curcontext" \
       _last_nmatches=-1 _last_menu_style _def_menu_style _menu_style sel \
       _saved_exact="${compstate[exact]}" \
       _saved_lastprompt="${compstate[last_prompt]}" \
       _saved_list="${compstate[list]}" \
-      _saved_insert="${compstate[insert]}"
+      _saved_insert="${compstate[insert]}" \
+      _saved_colors="$ZLS_COLORS"
 
 typeset -U _lastdescr _comp_ignore
 
@@ -203,12 +204,11 @@ elif [[ nm -eq 0 &&
   fi
 fi
 
-if zstyle -s ":completion:${curcontext}:" force-list tmp &&
-   [[ "$compstate[list]" = *list* && 
-      ( "$tmp" = always ||
-        ( "$tmp" = [0-9]## && nm -ge tmp ) ) ]]; then
-  compstate[list]="$compstate[list] force"
-fi
+[[ "$_comp_force_list" = always ||
+   ( "$_comp_force_list" = ?*  && nm -ge _comp_force_list ) ]] &&
+    compstate[list]="$compstate[list] force"
+
+[[ "$compstate[old_list]" = keep ]] && ZLS_COLORS="$_saved_colors"
 
 # Now call the post-functions.
 
diff --git a/Completion/Core/_prefix b/Completion/Core/_prefix
index f6e3b0831..18e6e3270 100644
--- a/Completion/Core/_prefix
+++ b/Completion/Core/_prefix
@@ -2,9 +2,10 @@
 
 # Try to ignore the suffix. A bit like e-o-c-prefix.
 
-[[ -n "$SUFFIX" ]] || return 1
+[[ _matcher_num -gt 1 || -z "$SUFFIX" ]] && return 1
 
-local comp i
+local comp curcontext="$curcontext" tmp \
+      _completer _completer_num _matcher _matchers _matcher_num
 
 zstyle -a ":completion:${curcontext}:" completer comp ||
   comp=( "${(@)_completers[1,_completer_num-1][(R)_prefix(|:*),-1]}" )
@@ -16,8 +17,29 @@ else
 fi
 SUFFIX=''
 
-for i in "$comp[@]"; do
-  [[ "$i" != _prefix ]] && "$i" && return 0
+_completer_num=1
+
+for tmp in "$comp[@]"; do
+  if [[ "$tmp" = *:-* ]]; then
+    _completer="${${tmp%:*}[2,-1]//_/-}${tmp#*:}"
+    tmp="${tmp%:*}"
+  elif [[ $tmp = *:* ]]; then
+    _completer="${tmp#*:}"
+    tmp="${tmp%:*}"
+  else
+    _completer="${tmp[2,-1]//_/-}"
+  fi
+  curcontext="${curcontext/:[^:]#:/:${_completer}:}"
+
+  zstyle -a ":completion:${curcontext}:" matcher-list _matchers ||
+      _matchers=( '' )
+
+  _matcher_num=1
+  for _matcher in "$_matchers[@]"; do
+    [[ "$tmp" != _prefix ]] && "$tmp" && return 0
+    (( _matcher_num++ ))
+  done
+  (( _completer_num++ ))
 done
 
 return 1
diff --git a/Completion/Core/_setup b/Completion/Core/_setup
index ed7307e69..6d5f09ab3 100644
--- a/Completion/Core/_setup
+++ b/Completion/Core/_setup
@@ -59,3 +59,10 @@ if zstyle -a ":completion:${curcontext}:$1" menu val; then
 else
   _last_nmatches=-1
 fi
+
+[[ "$_comp_force_list" != always ]] &&
+  zstyle -s ":completion:${curcontext}:$1" force-list val &&
+    [[ "$val" = always ||
+       ( "$val" = [0-9]## &&
+         ( -z "$_comp_force_list" || _comp_force_list -lt val ) ) ]] &&
+    _comp_force_list="$val"
diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo
index 99530a348..c741959ce 100644
--- a/Doc/Zsh/compsys.yo
+++ b/Doc/Zsh/compsys.yo
@@ -1038,12 +1038,16 @@ item(tt(force-list))(
 If the completion code would show a list of completions at all, this
 style controls whether the list is shown even in cases when it would
 normally not do that. For example, normally the list is only shown if
-there are at least to different matches. By setting this style to
-`tt(always)', the list will always even be shown, even if there is
-only a single match which is immediately accepted. The style may also
+there are at least two different matches. By setting this style to
+`tt(always)', the list will always be shown, even if there is only a
+single match which is immediately accepted. The style may also
 be set to a number. In this case the list will be shown if there are
 at least that many matches, even if they would all insert the same
 string.
+
+This style is tested for the default tag and all tags used when
+generating matches. This allows one to turn unconditional listing on
+for certain types of matches.
 )
 kindex(format, completion style)
 item(tt(format))(
@@ -1221,6 +1225,23 @@ Note that during the execution of completion functions, the
 tt(EXTENDED_GLOB) option is in effect, so the characters `tt(#)',
 `tt(~)' and `tt(^)' have special meanings in the patterns.
 )
+kindex(insert-ids, completion style)
+item(tt(insert-ids))(
+The function that completes process IDs can be given the prefix of a
+command name to complete it to that process' ID. Since the function
+even in those cases has to insert the process ID, it has to be decided 
+when the string from the line will be converted to a process ID or a
+prefix of one. If this style is set to `tt(menu)' (the default),
+menucompletion will always be entered when the string on the line is
+not a number. If  it is set to `tt(single)', the string on the line
+will be converted to  the process ID only at the very end, when there
+is only one match left  (note that in this case the completion will
+not be able to insert characters in the line because it still has to
+match the process IDs, it just doesn't insert them yet). If the value
+is any other string, menucompletion will be entered when the string on
+the line is longer than the prefix of the IDs of all matching
+processes.
+)
 kindex(insert-unambiguous, completion style)
 item(tt(insert-unambiguous))(
 This is used by the tt(_match) and tt(_approximate) completer
@@ -2088,6 +2109,10 @@ has started trying to generate matches, it will append a minus sign
 and the number of errors accepted in this attempt to its name. So on the
 first try the field contains `tt(approximate-1)', on the
 second try `tt(approximate-2)', and so on.
+
+When tt(_approximate) is called directly, the number of errors to accept
+may be given directly with the tt(-a) option. It's argument should be
+the same as the value of the tt(accept) style, all in one string.
 )
 findex(_correct)
 item(tt(_correct))(
@@ -2106,7 +2131,11 @@ given, correction will not be performed, but correcting completion
 will be, and will accept as many errors as given by the numeric
 argument. Without a numeric argument, first correction and then
 correcting completion will be tried, with the first one accepting two
-errors  and the second one accepting three errors.
+errors and the second one accepting three errors.
+
+When tt(_correct) is called directly, the number of errors to accept
+may be given directly with the tt(-a) option. It's argument should be
+the same as the value of the tt(accept) style, all in one string.
 
 This completer function is intended to be used without the
 tt(_approximate) completer or, as in the example, just before
@@ -2168,6 +2197,11 @@ generate any expansions at all.
 
 In a different mode selected by the tt(completions) style, all
 em(completions) generated for the string on the line are inserted.
+
+When tt(_expand) is called directly, the different modes may be
+selected with options. The tt(-c) corresponds to the tt(completions)
+style, tt(-s) to tt(substitute), tt(-g) to tt(glob) and tt(-o) to
+tt(subst-globs-only).
 )
 findex(_history)
 item(tt(_history))(
diff --git a/Src/Zle/complete.mdd b/Src/Zle/complete.mdd
index 628058e2a..8d4a59d66 100644
--- a/Src/Zle/complete.mdd
+++ b/Src/Zle/complete.mdd
@@ -1,11 +1,11 @@
-hasexport=1
+name=zsh/complete
 
-moddeps="zle"
+moddeps="zsh/zle"
 
-autobins="compgen compadd compset"
+autobins="compadd compset"
 
 autoprefixconds="prefix suffix between after"
 
-autoparams="compmatchers"
+headers="comp.h"
 
-objects="complete.o"
+objects="complete.o compcore.o compmatch.o compresult.o"
diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c
index f6a871f0f..76fbaf58b 100644
--- a/Src/Zle/complist.c
+++ b/Src/Zle/complist.c
@@ -1589,7 +1589,7 @@ domenuselect(Hookdef dummy, Chdata dat)
 	    if ((step += lines - nlnct) < 0)
 		step = 1;
     }
-    if ((mstatus = getsparam("MENUPROMPT")) && !*mstatus)
+    if ((mstatus = dupstring(getsparam("MENUPROMPT"))) && !*mstatus)
 	mstatus = "%SScrolling active: current selection at %p%s";
     mhasstat = (mstatus && *mstatus);
     fdat = dat;