Olaf Dietrich <[EMAIL PROTECTED]>:
> 
> Inserting a new line break in an existing line by "r <Return>"
> (more exactly: replacing the current character by a newline)
> does not work; instead, '^M' appears as replacement text.

By comparing the current CVS version of viper (viper-version "3.11.4
of February 19, 2005") to the one distributed with Emacs 21.4.1
(viper-version "3.11.1 of September 9, 2001"), I found the following
patch for viper-cmd.el the makes "r <Return>" work (only the fourth
insertion seems to be necessary to remove the described problem,
but all four seem to deal with similar ^M stuff).

Thanks to Kevin Rodgers and to Michael Kifer for their help,
Olaf


(crossposted to gnu.emacs.help and comp.emacs;
followups to: gnu.emacs.help;
and apologies in advance if a former version of this post (stupidly
cross-posted to a moderated group) should pop up here)


--- emacs-21.4/lisp/emulation/viper-cmd.el      2002-06-10 15:05:03.000000000 
+0200
+++ viper-cmd.el        2005-05-03 10:22:57.860007000 +0200
@@ -789,6 +789,13 @@
                 ;; The next 2 cmds are intended to prevent the input method
                 ;; from swallowing ^M, ^Q and other special characters
                 (setq ch (read-char))
+;; start copy from viper 3.11.4 (2005-02-19)
+                ;; replace ^M with the newline
+                (if (eq ch ?\C-m) (setq ch ?\n))
+                ;; Make sure ^V and ^Q work as quotation chars
+                (if (memq ch '(?\C-v ?\C-q))
+                    (setq ch (read-char)))
+;; end copy from viper 3.11.4 (2005-02-19)
                 (viper-set-unread-command-events ch)
                 (quail-input-method nil)
 
@@ -806,6 +813,13 @@
               ;; quail-input-method
               (let (unread-command-events)
                 (setq ch (read-char))
+;; start copy from viper 3.11.4 (2005-02-19)
+                ;; replace ^M with the newline
+                (if (eq ch ?\C-m) (setq ch ?\n))
+                ;; Make sure ^V and ^Q work as quotation chars
+                (if (memq ch '(?\C-v ?\C-q))
+                    (setq ch (read-char)))
+;; end copy from viper 3.11.4 (2005-02-19)
                 (viper-set-unread-command-events ch)
                 (quail-start-translation nil)
 
@@ -818,9 +832,24 @@
                 ))
              ((and (boundp 'iso-accents-mode) iso-accents-mode)
               (setq ch (aref (read-key-sequence nil) 0))
+;; start copy from viper 3.11.4 (2005-02-19)
+              ;; replace ^M with the newline
+              (if (eq ch ?\C-m) (setq ch ?\n))
+              ;; Make sure ^V and ^Q work as quotation chars
+              (if (memq ch '(?\C-v ?\C-q))
+                  (setq ch (aref (read-key-sequence nil) 0)))
+;; end copy from viper 3.11.4 (2005-02-19)
               (insert ch))
              (t
               (setq ch (read-char))
+;; the following 7 lines make "r <Ret>" work as expected
+;; start copy from viper 3.11.4 (2005-02-19)
+              ;; replace ^M with the newline
+              (if (eq ch ?\C-m) (setq ch ?\n))
+              ;; Make sure ^V and ^Q work as quotation chars
+              (if (memq ch '(?\C-v ?\C-q))
+                  (setq ch (read-char)))
+;; end copy from viper 3.11.4 (2005-02-19)
               (insert ch))
              )
        (setq last-command-event
@@ -2554,7 +2583,9 @@
     (or (eq viper-intermediate-command 'viper-repeat)
        (viper-special-read-and-insert-char))
 
-      (if (eq char ?\C-m) (setq char ?\n))
+;; start copy from viper 3.11.4 (2005-02-19)
+;;      (if (eq char ?\C-m) (setq char ?\n))
+;; end copy from viper 3.11.4 (2005-02-19)
 
       (delete-char 1 t)
 

_______________________________________________
Help-gnu-emacs mailing list
Help-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs

Reply via email to