diff options
author | Peter Stephenson <pws@users.sourceforge.net> | 2008-04-07 09:44:33 +0000 |
---|---|---|
committer | Peter Stephenson <pws@users.sourceforge.net> | 2008-04-07 09:44:33 +0000 |
commit | 84e1cb93ad1364800bddbd1f71cb142beaa4c100 (patch) | |
tree | 5cebddcc8fb728e18c48374fdc22d42faf2f5e18 | |
parent | 71e5f09d583166ceca0eae8847c6679c0e5b49f4 (diff) | |
download | zsh-84e1cb93ad1364800bddbd1f71cb142beaa4c100.tar.gz zsh-84e1cb93ad1364800bddbd1f71cb142beaa4c100.tar.xz zsh-84e1cb93ad1364800bddbd1f71cb142beaa4c100.zip |
restore read-from-minibuffer save/restore
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | Doc/Zsh/zle.yo | 8 | ||||
-rw-r--r-- | Functions/Zle/read-from-minibuffer | 50 |
3 files changed, 48 insertions, 17 deletions
diff --git a/ChangeLog b/ChangeLog index 498b44922..a6c8181e8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-04-07 Peter Stephenson <pws@csr.com> + + * 24797: Doc/Zsh/zle.yo, Functions/Zle/read-from-minibuffer: + document POSTDISPLAY highlighting; restore read-from-minibuffer + save/restore mechanism using variables to avoid problems with + not restoring special ZLE variables when they go out of scope. + 2008-04-05 Peter Stephenson <p.w.stephenson@ntlworld.com> * İsmail Dönmez <ismail@namtrac.org>: 24793: Doc/Zsh/zle.yo: diff --git a/Doc/Zsh/zle.yo b/Doc/Zsh/zle.yo index f81e88f52..dfd682b4f 100644 --- a/Doc/Zsh/zle.yo +++ b/Doc/Zsh/zle.yo @@ -778,8 +778,12 @@ vindex(region_highlight) item(tt(region_highlight) (array))( Each element of this array may be set to a string that describes highlighting for an arbitrary region of the command line that will -take effect the next time the command line is redisplayed. Each -string consists of the following parts: +take effect the next time the command line is redisplayed. Highlighting +of the non-editable parts of the command line in tt(PREDISPLAY) +and tt(POSTDISPLAY) are possible, but note that the tt(P) flag +is needed for character indexing to include tt(PREDISPLAY). + +Each string consists of the following parts: startlist() list(Optionally, a `tt(P)' to signify that the start and end offset that diff --git a/Functions/Zle/read-from-minibuffer b/Functions/Zle/read-from-minibuffer index 8c9051551..fce6b5319 100644 --- a/Functions/Zle/read-from-minibuffer +++ b/Functions/Zle/read-from-minibuffer @@ -21,21 +21,41 @@ done local pretext="$PREDISPLAY$LBUFFER$RBUFFER$POSTDISPLAY " -local LBUFFER="$2" -local RBUFFER="$3" -local PREDISPLAY="$pretext${1:-? }" -local POSTDISPLAY= -local -a region_highlight -region_highlight=("P${#pretext} ${#PREDISPLAY} bold") +# 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[@]}") -if [[ -n $keys ]]; then - zle -R - read -k $keys - stat=$? -else - zle recursive-edit -K main - stat=$? - (( stat )) || REPLY=$BUFFER -fi +{ + LBUFFER="$2" + RBUFFER="$3" + PREDISPLAY="$pretext${1:-? }" + POSTDISPLAY= + region_highlight=("P${#pretext} ${#PREDISPLAY} bold") + + if [[ -n $keys ]]; then + zle -R + read -k $keys + stat=$? + else + zle recursive-edit -K main + 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 |