about summary refs log tree commit diff
path: root/Functions
diff options
context:
space:
mode:
authorPaul Ackersviller <packersv@users.sourceforge.net>2007-03-18 23:19:59 +0000
committerPaul Ackersviller <packersv@users.sourceforge.net>2007-03-18 23:19:59 +0000
commit4beedf221eee5a8f4ae659fccd6f36c96c66cc69 (patch)
tree887d4c1f1f8dd1d9cfc5408b3c9c22020b0a774d /Functions
parent298de9ddb1ec77a23c7fb64e68f5ad404fbe74d3 (diff)
downloadzsh-4beedf221eee5a8f4ae659fccd6f36c96c66cc69.tar.gz
zsh-4beedf221eee5a8f4ae659fccd6f36c96c66cc69.tar.xz
zsh-4beedf221eee5a8f4ae659fccd6f36c96c66cc69.zip
Merge of trunk updates workers/20708 and workers/22854.
Diffstat (limited to 'Functions')
-rw-r--r--Functions/Zle/replace-string23
1 files changed, 23 insertions, 0 deletions
diff --git a/Functions/Zle/replace-string b/Functions/Zle/replace-string
new file mode 100644
index 000000000..31a7567db
--- /dev/null
+++ b/Functions/Zle/replace-string
@@ -0,0 +1,23 @@
+emulate -L zsh
+setopt extendedglob
+
+autoload -U read-from-minibuffer replace-string-again
+
+local p1="Replace: " p2="   with: "
+# Saving curwidget is necessary to avoid the widget name being overwritten.
+local REPLY previous curwidget=$WIDGET
+
+if (( ${+NUMERIC} )); then
+  (( $NUMERIC > 0 )) && previous=1
+else
+  zstyle -t ":zle:$WIDGET" edit-previous && previous=1
+fi
+
+read-from-minibuffer $p1 ${previous:+$_replace_string_src} || return 1
+_replace_string_src=$REPLY
+
+read-from-minibuffer "$p1$_replace_string_src$p2" \
+  ${previous:+$_replace_string_rep} || return 1
+_replace_string_rep=$REPLY
+
+replace-string-again $curwidget