about summary refs log tree commit diff
path: root/Functions/Zle
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2010-01-18 12:47:09 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2010-01-18 12:47:09 +0000
commitc508c6e368ac7faef55a16d9c85a2fbdd21232fc (patch)
treec46f72ce11b8485f052698b94485bc95bfae77f3 /Functions/Zle
parent8890e6e19ffa0bede585527671987972137009c7 (diff)
downloadzsh-c508c6e368ac7faef55a16d9c85a2fbdd21232fc.tar.gz
zsh-c508c6e368ac7faef55a16d9c85a2fbdd21232fc.tar.xz
zsh-c508c6e368ac7faef55a16d9c85a2fbdd21232fc.zip
27604: substitution using regular expressions
Diffstat (limited to 'Functions/Zle')
-rw-r--r--Functions/Zle/replace-string-again12
1 files changed, 9 insertions, 3 deletions
diff --git a/Functions/Zle/replace-string-again b/Functions/Zle/replace-string-again
index 3d3486437..8f4d23854 100644
--- a/Functions/Zle/replace-string-again
+++ b/Functions/Zle/replace-string-again
@@ -13,7 +13,7 @@ if [[ -z $_replace_string_src ]]; then
   return 1
 fi
 
-if [[ $curwidget = *pattern* ]]; then
+if [[ $curwidget = *(pattern|regex)* ]]; then
     local rep2
     # The following horror is so that an & preceded by an even
     # number of backslashes is active, without stripping backslashes,
@@ -38,8 +38,14 @@ if [[ $curwidget = *pattern* ]]; then
 	rep=${match[5]}
     done
     rep2+=$rep
-    LBUFFER=${LBUFFER//(#bm)$~_replace_string_src/${(e)rep2}}
-    RBUFFER=${RBUFFER//(#bm)$~_replace_string_src/${(e)rep2}}
+    if [[ $curwidget = *regex* ]]; then
+      autoload -U regexp-replace
+      regexp-replace LBUFFER $_replace_string_src $rep2
+      regexp-replace RBUFFER $_replace_string_src $rep2
+    else
+      LBUFFER=${LBUFFER//(#bm)$~_replace_string_src/${(e)rep2}}
+      RBUFFER=${RBUFFER//(#bm)$~_replace_string_src/${(e)rep2}}
+    fi
 else
     LBUFFER=${LBUFFER//$_replace_string_src/$_replace_string_rep}
     RBUFFER=${RBUFFER//$_replace_string_src/$_replace_string_rep}