From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6490 invoked from network); 29 Nov 1996 21:56:50 -0000 Received: from euclid.skiles.gatech.edu (list@130.207.146.50) by coral.primenet.com.au with SMTP; 29 Nov 1996 21:56:49 -0000 Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id QAA11607; Fri, 29 Nov 1996 16:45:06 -0500 (EST) Resent-Date: Fri, 29 Nov 1996 16:45:06 -0500 (EST) From: Zefram Message-Id: <10208.199611292145@stone.dcs.warwick.ac.uk> Subject: vi-replace-chars compatibility fix To: zsh-workers@math.gatech.edu (Z Shell workers mailing list) Date: Fri, 29 Nov 1996 21:45:39 +0000 (GMT) X-Patch: 137 X-Loop: zefram@dcs.warwick.ac.uk X-Stardate: [-31]8499.53 X-US-Congress: Moronic fuckers Content-Type: text Resent-Message-ID: <"REw2Z.0.Ir2.Xbrdo"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/2496 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu -----BEGIN PGP SIGNED MESSAGE----- This patch modifies the behaviour of vi-replace-chars to really match the vi behaviour. The comment above the function explains the issue involved. -zefram Index: Src/zle_vi.c =================================================================== RCS file: /home/zefram/usr/cvsroot/zsh/Src/zle_vi.c,v retrieving revision 1.19 diff -c -r1.19 zle_vi.c *** Src/zle_vi.c 1996/11/25 23:55:04 1.19 --- Src/zle_vi.c 1996/11/29 00:44:01 *************** *** 448,460 **** /* vi-replace-chars has some oddities relating to vi-repeat-change. In * * the real vi, if one does 3r at the end of a line, it feeps without * ! * reading the argument. A successful rx followed by 3. at the end of * ! * a line (or 3rx followed by . at the end of a line) will obviously * ! * feep after the ., even though it has the argument available. Here * ! * repeating is tied very closely to argument reading, such that we * ! * can't do that. The solution is to just read the argument even if * ! * the command will fail -- not exactly vi compatible, but it is more * ! * consistent (consider dd in an empty file in vi). */ /**/ void vireplacechars(void) --- 448,464 ---- /* vi-replace-chars has some oddities relating to vi-repeat-change. In * * the real vi, if one does 3r at the end of a line, it feeps without * ! * reading the argument, and won't repeat the action. A successful rx * ! * followed by 3. at the end of a line (or 3rx followed by . at the end * ! * of a line) will obviously feep after the ., even though it has the * ! * argument available. Here repeating is tied very closely to argument * ! * reading, so some trickery is needed to emulate this. When repeating * ! * a change, we always read the argument normally, even if the count * ! * was bad. When recording a change for repeating, and a bad count is * ! * given, we squash the repeat buffer to avoid repeating the partial * ! * command; we've lost the previous change, but that can't be avoided * ! * without a rewrite of the repeat code. */ ! /**/ void vireplacechars(void) *************** *** 462,475 **** int ch; startvichange(1); ! /* get key */ ! if((ch = vigetkey()) == -1) { ! vichgflag = 0; feep(); return; } ! /* check argument range */ ! if (zmult < 0 || zmult + cs > findeol()) { vichgflag = 0; feep(); return; --- 466,489 ---- int ch; startvichange(1); ! /* check argument range */ ! if (zmult < 1 || zmult + cs > findeol()) { ! if(vichgrepeat) { ! int obeep = opts[BEEP]; ! opts[BEEP] = 0; ! vigetkey(); ! opts[BEEP] = obeep; ! } ! if(vichgflag) { ! free(vichgbuf); ! vichgbuf = NULL; ! vichgflag = 0; ! } feep(); return; } ! /* get key */ ! if((ch = vigetkey()) == -1) { vichgflag = 0; feep(); return; -----BEGIN PGP SIGNATURE----- Version: 2.6.2 iQCVAwUBMp40DHD/+HJTpU/hAQHvjAP/SeQefx9zQKIQujzIeqqVGLMKjDEkRYvw TUJuZ2g/DRpcUQZH0WSlwqdQPB3EDGbBN5au1qnfA8glcK77u4Xet31Jc/Xpdxkr pwzllMJRee0vll5XBd9UIudKks2HXc5CVy58ctRtrSRi5Yh/SM6pWGgp2mIj4vdX XNMOoYHSU8E= =K3kz -----END PGP SIGNATURE-----