all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* viper-mode: viper-replace-char-subr
@ 2005-05-02  7:36 Olaf Dietrich
  2005-05-06  7:43 ` Olaf Dietrich
  0 siblings, 1 reply; 2+ messages in thread
From: Olaf Dietrich @ 2005-05-02  7:36 UTC (permalink / raw)


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 bug-gnu-emacs@gnu.org 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: <d4q3ib$1s7$1@wsc10.lrz-muenchen.de>
and <mailman.130.1114968001.2819.help-gnu-emacs@gnu.org>)
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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: viper-mode: viper-replace-char-subr
  2005-05-02  7:36 viper-mode: viper-replace-char-subr Olaf Dietrich
@ 2005-05-06  7:43 ` Olaf Dietrich
  0 siblings, 0 replies; 2+ messages in thread
From: Olaf Dietrich @ 2005-05-06  7:43 UTC (permalink / raw)


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 bug-gnu-emacs@gnu.org 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: <d4q3ib$1s7$1@wsc10.lrz-muenchen.de>
> and <mailman.130.1114968001.2819.help-gnu-emacs@gnu.org>)
> 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-05-06  7:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-05-02  7:36 viper-mode: viper-replace-char-subr Olaf Dietrich
2005-05-06  7:43 ` Olaf Dietrich

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.