[PATCH] Fix some issues with POSIX and traditional behavior of the r operator.

Wolfgang Jenkner wjenkner at inode.at
Thu Sep 22 21:50:59 CEST 2011


In particular, r<return> inserted a literal \C-m  but it should do the
same thing as r<newline>.
---
 evil-replace.el |   36 +++++++++++++++++++++++-------------
 1 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/evil-replace.el b/evil-replace.el
index a8e1f1e..fa84e0b 100644
--- a/evil-replace.el
+++ b/evil-replace.el
@@ -45,19 +45,29 @@
   "Replace text from BEG to END with CHAR."
   :motion evil-forward-char
   (interactive "<R>"
-               (list (evil-save-cursor
-                       (evil-set-cursor evil-replace-state-cursor)
-                       (evil-read-key))))
-  (if (eq type 'block)
-      (save-excursion
-        (evil-apply-on-block 'evil-replace beg end nil char))
-    (goto-char beg)
-    (while (< (point) end)
-      (if (eq (char-after) ?\n)
-          (forward-char)
-        (delete-char 1)
-        (insert-char char 1)))
-    (goto-char (max beg (1- end)))))
+	       (list (evil-save-cursor
+		       (evil-set-cursor evil-replace-state-cursor)
+		       (let ((char (evil-read-key)))
+			 (cond
+			  ((= char ?\r) ?\n)
+			  ((= char ?\C-v) (evil-read-key))
+			  ((/= char ?\e) char))))))
+  (when char
+    (if (eq type 'block)
+	(save-excursion
+	  (evil-apply-on-block 'evil-replace beg end nil char))
+      (goto-char beg)
+      (while (< (point) end)
+	(if (eq (char-after) ?\n)
+	    (forward-char)
+	  (delete-char 1)
+	  (if (= char ?\n)
+	      (newline)
+	    (insert-char char 1))))
+      (if (= char ?\n)
+	  (when evil-auto-indent
+	    (indent-according-to-mode))
+	(goto-char (max beg (1- end)))))))
 
 (provide 'evil-replace)
 
-- 
1.7.6.1




More information about the implementations-list mailing list