summaryrefslogtreecommitdiff
path: root/Functions/Zle/read-from-minibuffer
diff options
context:
space:
mode:
authorFrank Terbeck <ft@bewatermyfriend.org>2011-12-01 10:02:04 +0100
committerFrank Terbeck <ft@bewatermyfriend.org>2011-12-01 10:02:04 +0100
commitd8da5ea2f2bc5f837d0b364fff2636ebdb2f90ca (patch)
tree9fd9a57486ac4702608d92088ffd91f52971244f /Functions/Zle/read-from-minibuffer
parentaf2bb4fdb09414d21922d3fafe4e3a0ac1332f01 (diff)
parent9d71f4c207fb34e8d64af0443c83231b1cc3b494 (diff)
downloadzsh-d8da5ea2f2bc5f837d0b364fff2636ebdb2f90ca.tar.gz
zsh-d8da5ea2f2bc5f837d0b364fff2636ebdb2f90ca.zip
Merge commit 'zsh-4.3.13' into debian
Diffstat (limited to 'Functions/Zle/read-from-minibuffer')
-rw-r--r--Functions/Zle/read-from-minibuffer35
1 files changed, 11 insertions, 24 deletions
diff --git a/Functions/Zle/read-from-minibuffer b/Functions/Zle/read-from-minibuffer
index fce6b5319..57e926884 100644
--- a/Functions/Zle/read-from-minibuffer
+++ b/Functions/Zle/read-from-minibuffer
@@ -19,26 +19,19 @@ while getopts "k:" opt; do
done
(( OPTIND > 1 )) && shift $(( OPTIND - 1 ))
+local readprompt="$1" lbuf_init="$2" rbuf_init="$3"
+
+# Use anonymous function to make sure special values get restored,
+# even if this function is called as a widget.
+# local +h ensures special parameters stay special.
+() {
local pretext="$PREDISPLAY$LBUFFER$RBUFFER$POSTDISPLAY
"
-# We could use the local variables mechanism to save these
-# values, but if read-from-minibuffer is called as a widget
-# (which isn't actually all that useful) the values won't be
-# restored because the variables are already local at the current
-# level and don't get restored when they go out of scope.
-# We could do it with an additional function level.
- local save_lbuffer=$LBUFFER
- local save_rbuffer=$RBUFFER
- local save_predisplay=$PREDISPLAY
- local save_postdisplay=$POSTDISPLAY
- local -a save_region_highlight
- save_region_highlight=("${region_highlight[@]}")
-
-{
- LBUFFER="$2"
- RBUFFER="$3"
- PREDISPLAY="$pretext${1:-? }"
- POSTDISPLAY=
+ local +h LBUFFER="$lbuf_init"
+ local +h RBUFFER="$rbuf_init"
+ local +h PREDISPLAY="$pretext${readprompt:-? }"
+ local +h POSTDISPLAY=
+ local +h -a region_highlight
region_highlight=("P${#pretext} ${#PREDISPLAY} bold")
if [[ -n $keys ]]; then
@@ -50,12 +43,6 @@ done
stat=$?
(( stat )) || REPLY=$BUFFER
fi
-} always {
- LBUFFER=$save_lbuffer
- RBUFFER=$save_rbuffer
- PREDISPLAY=$save_predisplay
- POSTDISPLAY=$save_postdisplay
- region_highlight=("${save_region_highlight[@]}")
}
return $stat