bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: viper-mode: viper-replace-char-subr


From: Olaf Dietrich
Subject: Re: viper-mode: viper-replace-char-subr
Date: Fri, 6 May 2005 09:43:01 +0200
User-agent: Mutt/1.5.6+20040907i

The problem described below (inserting a new line break in an existing
line by "r <Return>" in viper-mode, GNU Emacs 21.4.1) can be solved
by a patch to viper-cmd.el distributed with the currently stable
Emacs 21.4.1.

The patch is derived from a comparison of the current CVS version
of viper (viper-version "3.11.4 of February 19, 2005") and the one
distributed with Emacs 21.4.1 (viper-version "3.11.1 of September 9,
2001"); only the fourth insertion seems to be necessary to remove
the described problem, but all four deal with similar ^M stuff.

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



--- 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)
 





Olaf Dietrich (2005-05-02T09:36:57+0200):
> This bug report will be sent to the Free Software Foundation,
> not to your local site managers!
> Please write in English, because the Emacs maintainers do not have
> translators to read other languages for them.
> 
> Your bug report will be posted to the address@hidden mailing list,
> and to the gnu.emacs.bug news group.
> 
> In GNU Emacs 21.4.1 (i686-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
>  of 2005-04-20 on gracvn
> configured using `configure  --prefix=/var/autofs/misc/apps/DIR/emacs-21.4'
> Important settings:
>   value of $LC_ALL: nil
>   value of $LC_COLLATE: nil
>   value of $LC_CTYPE: nil
>   value of $LC_MESSAGES: nil
>   value of $LC_MONETARY: nil
>   value of $LC_NUMERIC: nil
>   value of $LC_TIME: nil
>   value of $LANG: C
>   locale-coding-system: nil
>   default-enable-multibyte-characters: t
> 
> Please describe exactly what actions triggered the bug
> and the precise symptoms of the bug:
> 
> 
> This may be a bug of viper-mode:
> 
> 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.
> 
> (The alternative "r C-j" _does_ work, but is not what my fingers
> are used to do in vi.)
> 
> It seems that the function
> 
> | (defun viper-replace-char-subr (com arg)
> |   (let ((inhibit-quit t)
> |         char)
> |     (viper-set-complex-command-for-undo)
> |     (or (eq viper-intermediate-command 'viper-repeat)
> |         (viper-special-read-and-insert-char))
> |
> |       (if (eq char ?\C-m) (setq char ?\n))
> |
> |       (delete-char 1 t)
> |
> |       (setq char (if com viper-d-char (viper-char-at-pos 'backward)))
> |       (if com (insert char))
> |
> |       (setq viper-d-char char)
> |
> |       (viper-loop (1- (if (> arg 0) arg (- arg)))
> |                   (delete-char 1 t)
> |                   (insert char))
> |
> |       (viper-adjust-undo)
> |       (backward-char arg)
> |       ))
> 
> should avoid this, see in particular the line
> 
> |       (if (eq char ?\C-m) (setq char ?\n))
> 
> but this doesn't work. In a Usenet discussion
> (e.g., Message-ID: <address@hidden>
> and <address@hidden>)
> in gnu.emacs.help, Kevin Rodgers remarked about this:
> 
> : The first problem is that the (if (eq char ?\C-m) (setq char ?\n)) form
> : occurs before char has been set.  The second problem is that when that
> : form is evaluated and char is reset, it has already been inserted; but
> : no attempt is made to undo that and re-insert the proper newline
> : character.
> 
> Olaf
> 
> 
> Recent input:
> <help-echo> <help-echo> <help-echo> <help-echo> <help-echo> 
> <help-echo> <menu-bar> <help-menu> <report-emacs-bug>
> 
> Recent messages:
> (emacs 
> /var/autofs/misc/apps/DIR/emacs-21.4/share/emacs/21.4/lisp/emulation/viper-cmd.el)
> Loading disp-table...done
> Loading tool-bar...done
> Loading image...done
> Loading tooltip...done
> For information about the GNU Project and its goals, type C-h C-p.
> Loading emacsbug...done
> Loading view...done




reply via email to

[Prev in Thread] Current Thread [Next in Thread]