about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-09-23 13:47:45 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-09-23 13:47:45 +0000
commita2977ce2045f6c290a55c3819f8526ba331a077a (patch)
tree517eff51721ebed09edb08820994567427ea7e0c
parent284eb7399747fba1f26901647b51719f79fb55b0 (diff)
downloadzsh-a2977ce2045f6c290a55c3819f8526ba331a077a.tar.gz
zsh-a2977ce2045f6c290a55c3819f8526ba331a077a.tar.xz
zsh-a2977ce2045f6c290a55c3819f8526ba331a077a.zip
manual/8020
-rw-r--r--Doc/Zsh/mod_deltochar.yo10
-rw-r--r--Src/Zle/deltochar.c18
2 files changed, 21 insertions, 7 deletions
diff --git a/Doc/Zsh/mod_deltochar.yo b/Doc/Zsh/mod_deltochar.yo
index d90a6fc47..7ee8c798e 100644
--- a/Doc/Zsh/mod_deltochar.yo
+++ b/Doc/Zsh/mod_deltochar.yo
@@ -1,12 +1,18 @@
 texinode(The deltochar Module)(The example Module)(The complist Module)(Zsh Modules)
 sect(The deltochar Module)
-The tt(deltochar) module makes available one ZLE function:
+The tt(deltochar) module makes available two ZLE functions:
 
 startitem()
 tindex(delete-to-char)
 item(tt(delete-to-char))(
 Read a character from the keyboard, and
-delete from the cursor position up to but not including the next
+delete from the cursor position up to and including the next
 (or, with repeat count var(n), the var(n)th) instance of that character.
+Negative repeat counts mean delete backwards.
+)
+tindex(zap-to-char)
+item(tt(zap-to-char))(
+This behaves like tt(delete-to-char), except that the final occurence of
+the character itself is not deleted.
 )
 enditem()
diff --git a/Src/Zle/deltochar.c b/Src/Zle/deltochar.c
index d6a579d5c..566a578f1 100644
--- a/Src/Zle/deltochar.c
+++ b/Src/Zle/deltochar.c
@@ -31,19 +31,21 @@
 #include "deltochar.pro"
 
 static Widget w_deletetochar;
+static Widget w_zaptochar;
 
 /**/
 static int
 deltochar(char **args)
 {
     int c = getkey(0), dest = cs, ok = 0, n = zmult;
+    int zap = (bindk->widget == w_zaptochar);
 
     if (n > 0) {
 	while (n-- && dest != ll) {
 	    while (dest != ll && line[dest] != c)
 		dest++;
 	    if (dest != ll) {
-		if (n > 0)
+		if (!zap || n > 0)
 		    dest++;
 		if (!n) {
 		    forekill(dest - cs, 0);
@@ -60,7 +62,7 @@ deltochar(char **args)
 		dest--;
 	    if (line[dest] == c) {
 		if (!n) {
-		    backkill(cs - dest - 1, 1);
+		    backkill(cs - dest - zap, 1);
 		    ok++;
 		}
 		if (dest)
@@ -84,9 +86,14 @@ boot_deltochar(Module m)
 {
     w_deletetochar = addzlefunction("delete-to-char", deltochar,
                                     ZLE_KILL | ZLE_KEEPSUFFIX);
-    if (w_deletetochar)
-	return 0;
-    zwarnnam(m->nam, "name clash when adding ZLE function `delete-to-char'",
+    if (w_deletetochar) {
+	w_zaptochar = addzlefunction("zap-to-char", deltochar,
+				     ZLE_KILL | ZLE_KEEPSUFFIX);
+	if (w_zaptochar)
+	    return 0;
+	deletezlefunction(w_deletetochar);
+    }
+    zwarnnam(m->nam, "deltochar: name clash when adding ZLE functions",
 	     NULL, 0);
     return -1;
 }
@@ -98,6 +105,7 @@ int
 cleanup_deltochar(Module m)
 {
     deletezlefunction(w_deletetochar);
+    deletezlefunction(w_zaptochar);
     return 0;
 }