Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
vi-replace-chars and vi-repeat-last-change
- X-seq: zsh-workers 1696
- From: Zefram <A.Main@xxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxxx (Z Shell workers mailing list)
- Subject: vi-replace-chars and vi-repeat-last-change
- Date: Thu, 18 Jul 1996 15:24:00 +0100 (BST)
-----BEGIN PGP SIGNED MESSAGE-----
The patch below makes vi-replace-chars repeat correctly with
vi-repeat-change. The comment added explains the details.
-zefram
Index: Src/zle_vi.c
===================================================================
RCS file: /home/zefram/usr/cvsroot/zsh/Src/zle_vi.c,v
retrieving revision 1.11
diff -c -r1.11 zle_vi.c
*** zle_vi.c 1996/07/17 16:12:28 1.11
--- zle_vi.c 1996/07/18 12:44:13
***************
*** 442,468 ****
startvitext(0);
}
/**/
void
vireplacechars(void)
{
int ch;
! /* check argument range */
! if (zmult < 0)
! return;
! if (zmult + cs > findeol()) {
feep();
return;
}
! /* get key */
! if((ch = vigetkey()) == -1) {
feep();
return;
}
- ungetkey(ch);
- startvichange(1);
- getkey(0);
/* do change */
if (ch == '\r' || ch == '\n') {
/* <return> handled specially */
--- 442,476 ----
startvitext(0);
}
+ /* 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)
{
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;
}
/* do change */
if (ch == '\r' || ch == '\n') {
/* <return> handled specially */
-----BEGIN PGP SIGNATURE-----
Version: 2.6.2
iQCVAwUBMe4yjnD/+HJTpU/hAQHcfwP/aLd1MTv3VEbFfH/6cCVEgUXWmFMgsOvK
RJOiYSKyagqOTjCuRJn+Klf+lVqRC3W59B21JkQr8L8FgNM9G/pKw7ea/fYiTyiY
Kehm34n4hW1eEBfZQPJXO3YmesNIrKfmDRWB0yKQNvnCPLQ7hGdcC3Bgo9GiBSp6
PM6HqjJtmyE=
=As9e
-----END PGP SIGNATURE-----
Messages sorted by:
Reverse Date,
Date,
Thread,
Author