In normal state, if I type r then hit <return>, I get the following: ;; This^Mbuffer is for notes you don't want to save, and for Lisp evaluation. Instead of inserting ^M, I expected a new line like the following: ;; This buffer is for notes you don't want to save, and for Lisp evaluation. This occurs in both windows and linux. Hitting <escape> after r also acts differently than vim, but that's less of an issue for me. - Tom
Tom Short <[email protected]> writes:
In normal state, if I type r then hit <return>, I get the following:
;; This^Mbuffer is for notes you don't want to save, and for Lisp evaluation.
Instead of inserting ^M, I expected a new line like the following:
;; This buffer is for notes you don't want to save, and for Lisp evaluation.
I noticed this as well and tried to implement the behaviour specified in http://pubs.opengroup.org/onlinepubs/9699919799/utilities/vi.html (search for Replace Character) Wolfgang
From 0607ce03be295e5362c4e2afd78e39f81c19defd Mon Sep 17 00:00:00 2001 From: Wolfgang Jenkner <[email protected]> Date: Thu, 22 Sep 2011 21:50:59 +0200 Subject: [PATCH] Fix some issues with POSIX and traditional behavior of the r operator.
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
On 2011-09-23 15:28 +0200, Wolfgang Jenkner wrote:
I noticed this as well and tried to implement the behaviour specified in
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/vi.html
Thanks for the patch, applied in commit 1cf75ed with some modifications (I moved the \r -> \n stuff into `evil-read-key'). -- Vegard
Vegard Øye <[email protected]> writes:
On 2011-09-23 15:28 +0200, Wolfgang Jenkner wrote:
I noticed this as well and tried to implement the behaviour specified in
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/vi.html
Thanks for the patch, applied in commit 1cf75ed with some modifications (I moved the \r -> \n stuff into `evil-read-key').
Thanks, but ... Wolfgang
From d24096579015c5b66d55c492ca2cdafe2bb0ee6e Mon Sep 17 00:00:00 2001 From: Wolfgang Jenkner <[email protected]> Date: Mon, 26 Sep 2011 17:06:58 +0200 Subject: [PATCH] Fix rearrangement of the last submission.
Make <return> quotable again. By the way, <newline> (= <linefeed> = C-j) is never quoted, because this is consistent with both POSIX vi(1p) and the usual emacs behavior. On the other hand, on typing C-vC-j vim inserts a NULL character, which looks like a bug. --- evil-compatibility.el | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/evil-compatibility.el b/evil-compatibility.el index 8779181..7d7740f 100644 --- a/evil-compatibility.el +++ b/evil-compatibility.el @@ -34,10 +34,10 @@ Translates it according to the input method." 'self-insert-command) t) (use-global-map new-global-map) (setq char (aref (read-key-sequence prompt nil t) 0)) - (when (memq char '(?\C-q ?\C-v)) - (setq char (read-quoted-char))) - (or (cdr (assq char '((?\r . ?\n)))) - char)) + (if (memq char '(?\C-q ?\C-v)) + (read-quoted-char) + (or (cdr (assq char '((?\r . ?\n)))) + char))) (use-global-map old-global-map)))) ;; `make-char-table' requires this property in Emacs 22 -- 1.7.6.1
Wolfgang Jenkner <[email protected]> writes:
Vegard Øye <[email protected]> writes:
On 2011-09-23 15:28 +0200, Wolfgang Jenkner wrote:
I noticed this as well and tried to implement the behaviour specified in
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/vi.html
Thanks for the patch, applied in commit 1cf75ed with some modifications (I moved the \r -> \n stuff into `evil-read-key').
Thanks, but ...
And also...
From 658b3748c7735b11fc90f9eb0d43963a2d7de77b Mon Sep 17 00:00:00 2001 From: Wolfgang Jenkner <[email protected]> Date: Mon, 26 Sep 2011 19:03:27 +0200 Subject: [PATCH] Special handling of r<escape> (do nothing) was lost in translation.
Not sure about the existing uses of evil-read-key in evil-insert-digraph. --- evil-compatibility.el | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/evil-compatibility.el b/evil-compatibility.el index 7d7740f..5cd6df4 100644 --- a/evil-compatibility.el +++ b/evil-compatibility.el @@ -36,8 +36,9 @@ Translates it according to the input method." (setq char (aref (read-key-sequence prompt nil t) 0)) (if (memq char '(?\C-q ?\C-v)) (read-quoted-char) - (or (cdr (assq char '((?\r . ?\n)))) - char))) + (unless (eq char ?\e) + (or (cdr (assq char '((?\r . ?\n)))) + char)))) (use-global-map old-global-map)))) ;; `make-char-table' requires this property in Emacs 22 -- 1.7.6.1
participants (3)
-
Tom Short -
Vegard Øye -
Wolfgang Jenkner