unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Kevin Rodgers <ihs_4664@yahoo.com>
Subject: Re: viper-mode: "r <Return>" does not work as expected
Date: Fri, 29 Apr 2005 12:55:08 -0600	[thread overview]
Message-ID: <d4tvjl$rd0$1@sea.gmane.org> (raw)
In-Reply-To: <d4t9js$ikg$1@wsc10.lrz-muenchen.de>

Olaf Dietrich wrote:
 > I've just played a little bit with viper-cmd.el; the original
 > function is
 >
 > | (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)
 > |       ))
 >
 > Since I have never work with (emacs) lisp before, I don't
 > know whether my attempts made any sense, but if I (simple
 > enough) changed e.g. "(delete-char 1 t)" to "(delete-char 3 t)"
 > than 3 instead of 1 character were replaced by a single new
 > one. But I wasn't able to find out whether the line
 >
 > |       (if (eq char ?\C-m) (setq char ?\n))
 >
 > is executed at all. Adding something like "(insert ?A)"
 > inserted an additional "A", but I wasn't able to change
 > char by e.g. "(setq char ?A)".
 >
 > Any ideas what to try next?

Report it as a bug.  I have many years of Emacs Lisp experience, and
I've been playing with that function today, too.  And it is badly
broken.

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.

It would be a lot easier to fix if viper was properly designed i.e. one
function to read the character and one function to insert it instead of
combining those functions into viper-special-read-and-insert-char.

-- 
Kevin Rodgers

  reply	other threads:[~2005-04-29 18:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <d4861u$28v$1@wsc10.lrz-muenchen.de>
2005-04-28  7:32 ` viper-mode: "r <Return>" does not work as expected Olaf Dietrich
2005-04-28 18:44   ` Kevin Rodgers
     [not found]   ` <mailman.3342.1114714165.2895.help-gnu-emacs@gnu.org>
2005-04-29  7:28     ` Olaf Dietrich
2005-04-29 12:34       ` Olaf Dietrich
2005-04-29 18:55         ` Kevin Rodgers [this message]
2005-05-06  7:27   ` Olaf Dietrich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='d4tvjl$rd0$1@sea.gmane.org' \
    --to=ihs_4664@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).