mirror of
git://git.code.sf.net/p/zsh/code
synced 2024-09-26 22:10:45 +02:00
29894: display and use previous replacement in replace-string
This commit is contained in:
parent
a6e039e12e
commit
ec6914b061
@ -1,3 +1,8 @@
|
||||
2011-11-07 Peter Stephenson <pws@csr.com>
|
||||
|
||||
* 29894: Doc/Zsh/contrib.yo, Functions/Zle/replace-string:
|
||||
display previous replacement and reuse if source string is empty.
|
||||
|
||||
2011-11-04 Peter Stephenson <pws@csr.com>
|
||||
|
||||
* 29892: Functions/Zle/read-from-minibuffer,
|
||||
@ -15543,5 +15548,5 @@
|
||||
|
||||
*****************************************************
|
||||
* This is used by the shell to define $ZSH_PATCHLEVEL
|
||||
* $Revision: 1.5493 $
|
||||
* $Revision: 1.5494 $
|
||||
*****************************************************
|
||||
|
@ -2335,6 +2335,11 @@ regular expression matching is performed, else a literal string
|
||||
replacement. Note that the previous source and replacement text are the
|
||||
same whether pattern, regular expression or string matching is used.
|
||||
|
||||
In addition, tt(replace-string) shows the previous replacement above
|
||||
the prompt, so long as there was one during the current session; if the
|
||||
source string is empty, that replacement will be repeated without
|
||||
the widget prompting for a replacement string.
|
||||
|
||||
For example, starting from the line:
|
||||
|
||||
example(print This line contains fan and fond)
|
||||
|
@ -3,7 +3,15 @@ setopt extendedglob
|
||||
|
||||
autoload -Uz read-from-minibuffer replace-string-again
|
||||
|
||||
local p1="Replace: " p2=" with: "
|
||||
local p1 p2
|
||||
|
||||
if [[ -n $_replace_string_src ]]; then
|
||||
p1="[$_replace_string_src -> $_replace_string_rep]"$'\n'
|
||||
fi
|
||||
|
||||
p1+="Replace: "
|
||||
p2=" with: "
|
||||
|
||||
# Saving curwidget is necessary to avoid the widget name being overwritten.
|
||||
local REPLY previous curwidget=$WIDGET
|
||||
|
||||
@ -14,10 +22,12 @@ else
|
||||
fi
|
||||
|
||||
read-from-minibuffer $p1 ${previous:+$_replace_string_src} || return 1
|
||||
typeset -g _replace_string_src=$REPLY
|
||||
if [[ -n $REPLY ]]; then
|
||||
typeset -g _replace_string_src=$REPLY
|
||||
|
||||
read-from-minibuffer "$p1$_replace_string_src$p2" \
|
||||
${previous:+$_replace_string_rep} || return 1
|
||||
typeset -g _replace_string_rep=$REPLY
|
||||
read-from-minibuffer "$p1$_replace_string_src$p2" \
|
||||
${previous:+$_replace_string_rep} || return 1
|
||||
typeset -g _replace_string_rep=$REPLY
|
||||
fi
|
||||
|
||||
replace-string-again $curwidget
|
||||
|
Loading…
Reference in New Issue
Block a user