From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kevin Rodgers Newsgroups: gmane.emacs.help Subject: Re: viper-mode: "r " does not work as expected Date: Fri, 29 Apr 2005 12:55:08 -0600 Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1114968914 26282 80.91.229.2 (1 May 2005 17:35:14 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 1 May 2005 17:35:14 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun May 01 19:35:11 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DSIL7-0001Mo-6H for geh-help-gnu-emacs@m.gmane.org; Sun, 01 May 2005 19:34:45 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DSINc-0001eo-38 for geh-help-gnu-emacs@m.gmane.org; Sun, 01 May 2005 13:37:20 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DSI3a-0000uf-Tq for help-gnu-emacs@gnu.org; Sun, 01 May 2005 13:16:38 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DSI3R-0000nX-Vw for help-gnu-emacs@gnu.org; Sun, 01 May 2005 13:16:30 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DSI3N-0000Uk-EB for help-gnu-emacs@gnu.org; Sun, 01 May 2005 13:16:25 -0400 Original-Received: from [199.232.41.67] (helo=mx20.gnu.org) by monty-python.gnu.org with esmtp (TLS-1.0:RSA_ARCFOUR_SHA:16) (Exim 4.34) id 1DSI51-0003Wv-19 for help-gnu-emacs@gnu.org; Sun, 01 May 2005 13:18:07 -0400 Original-Received: from [80.91.229.2] (helo=ciao.gmane.org) by mx20.gnu.org with esmtp (Exim 4.34) id 1DRafX-0004zr-EL for help-gnu-emacs@gnu.org; Fri, 29 Apr 2005 14:56:55 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1DRaZY-0004Wt-3k for help-gnu-emacs@gnu.org; Fri, 29 Apr 2005 20:50:44 +0200 Original-Received: from 207.167.42.60 ([207.167.42.60]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 29 Apr 2005 20:50:44 +0200 Original-Received: from ihs_4664 by 207.167.42.60 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 29 Apr 2005 20:50:44 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-To: help-gnu-emacs@gnu.org Original-Lines: 58 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: 207.167.42.60 User-Agent: Mozilla Thunderbird 0.9 (X11/20041105) X-Accept-Language: en-us, en In-Reply-To: X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:26154 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:26154 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