zsh-workers
 help / color / mirror / code / Atom feed
* [patch] deltochar
@ 1998-11-05 17:34 Greg Klanderman
  1998-11-06  7:13 ` PATCH: 3.1.5 - cumulative reverse-kills (Re: [patch] deltochar) Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Greg Klanderman @ 1998-11-05 17:34 UTC (permalink / raw)
  To: Zsh list


Reverse kills were not handled correctly.  Also, kill the text so it
can be yanked, like emacs does.

There is still a minor bug in that consecutive reverse deltochar's do
not accumulate into a single kill.  They do going forwards.

Can someone tell me what the ZLE_KILL does in the call to
addzlefunction, and if it's needed?

greg
(please copy me on replies)


1998-11-05  Greg Klanderman  <greg@alphatech.com>

	* Src/Zle/deltochar.c (deltochar): kill (saving in kill ring)
	instead of deleting.  properly handle reverse kills.


--- Src/Zle/deltochar.c.orig	Thu Nov  5 11:21:36 1998
+++ Src/Zle/deltochar.c	Thu Nov  5 12:23:28 1998
@@ -45,7 +45,7 @@
 	    if (dest != ll) {
 		dest++;
 		if (!n) {
-		    foredel(dest - cs);
+		    forekill(dest - cs, 0);
 		    ok++;
 		}
 	    }
@@ -58,9 +58,13 @@
 	    while (dest != 0 && line[dest] != c)
 		dest--;
 	    if (line[dest] == c && !n) {
-		backdel(cs - dest);
+		backkill(cs - dest, 1);
 		ok++;
 	    }
+            else if (dest)
+              dest--;
+            else
+              n = 0;
 	}
     }
     if (!ok)
@@ -71,7 +75,8 @@
 int
 boot_deltochar(Module m)
 {
-    w_deletetochar = addzlefunction("delete-to-char", deltochar, ZLE_KEEPSUFFIX);
+    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'",


^ permalink raw reply	[flat|nested] 3+ messages in thread

* PATCH: 3.1.5 - cumulative reverse-kills (Re: [patch] deltochar)
  1998-11-05 17:34 [patch] deltochar Greg Klanderman
@ 1998-11-06  7:13 ` Bart Schaefer
  1998-11-06 14:10   ` Greg Klanderman
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 1998-11-06  7:13 UTC (permalink / raw)
  To: greg, Zsh list

On Nov 5, 12:34pm, Greg Klanderman wrote:
} Subject: [patch] deltochar
}
} Reverse kills were not handled correctly.  Also, kill the text so it
} can be yanked, like emacs does.

I'm being sort of nitpicky here, but I think the following is a better
patch.  It makes the reverse kill case parallel the forward kill case
more closely.

} There is still a minor bug in that consecutive reverse deltochar's do
} not accumulate into a single kill.  They do going forwards.

The problem is that using prefix-arg between the kills causes the kill
ring to advance. In zle_main.c, execzlefunc(), approx. lines 566-579,
`lastcmd' gets set to the hardwired widget flags of whatever function
has been called. In the case of universal-argument, neg-argument, and
digit-argument, it should be passing through the previous command's
flags unchanged.

The patch below fixes this; I've been rather conservative with where I
added ZLE_NOTCOMMAND, there may be a few more widgets that should use
it.

} Can someone tell me what the ZLE_KILL does in the call to
} addzlefunction, and if it's needed?

When a cut function that does -not- have the ZLE_KILL flag is called,
the killring number gets incremented.  So having that flag turned on
should cause repeated kills by this function to be added to the same
kill ring entry.

Here's the patch.

Index: Src/Zle/deltochar.c
===================================================================
RCS file: /extra/cvsroot/zsh/zsh-3.1/Src/Zle/deltochar.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 deltochar.c
--- deltochar.c	1998/06/01 17:08:45	1.1.1.1
+++ deltochar.c	1998/11/06 06:38:20
@@ -45,7 +45,7 @@
 	    if (dest != ll) {
 		dest++;
 		if (!n) {
-		    foredel(dest - cs);
+		    forekill(dest - cs, 0);
 		    ok++;
 		}
 	    }
@@ -57,9 +57,13 @@
 	while (n++ && dest != 0) {
 	    while (dest != 0 && line[dest] != c)
 		dest--;
-	    if (line[dest] == c && !n) {
-		backdel(cs - dest);
-		ok++;
+	    if (line[dest] == c) {
+		if (!n) {
+		    backkill(cs - dest, 1);
+		    ok++;
+		}
+		if (dest)
+		    dest--;
 	    }
 	}
     }
@@ -71,7 +75,8 @@
 int
 boot_deltochar(Module m)
 {
-    w_deletetochar = addzlefunction("delete-to-char", deltochar, ZLE_KEEPSUFFIX);
+    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'",
Index: Src/Zle/iwidgets.list
===================================================================
RCS file: /extra/cvsroot/zsh/zsh-3.1/Src/Zle/iwidgets.list,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 iwidgets.list
--- iwidgets.list	1998/06/01 17:08:45	1.1.1.1
+++ iwidgets.list	1998/11/06 07:04:37
@@ -24,7 +24,7 @@
 "beginning-of-line", beginningofline, 0
 "beginning-of-line-hist", beginningoflinehist, 0
 "capitalize-word", capitalizeword, 0
-"clear-screen", clearscreen, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_LASTCOL
+"clear-screen", clearscreen, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_LASTCOL | ZLE_NOTCOMMAND
 "complete-word", completeword, ZLE_MENUCMP | ZLE_KEEPSUFFIX
 "copy-prev-word", copyprevword, 0
 "copy-region-as-kill", copyregionaskill, ZLE_KEEPSUFFIX
@@ -32,7 +32,7 @@
 "delete-char-or-list", deletecharorlist, ZLE_MENUCMP | ZLE_KEEPSUFFIX
 "delete-word", deleteword, ZLE_KEEPSUFFIX
 "describe-key-briefly", describekeybriefly, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_LASTCOL
-"digit-argument", digitargument, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_LASTCOL
+"digit-argument", digitargument, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_LASTCOL | ZLE_NOTCOMMAND
 "down-case-word", downcaseword, 0
 "down-history", downhistory, 0
 "down-line-or-history", downlineorhistory, ZLE_LINEMOVE | ZLE_LASTCOL
@@ -73,7 +73,7 @@
 "magic-space", magicspace, 0
 "menu-complete", menucomplete, ZLE_MENUCMP | ZLE_KEEPSUFFIX
 "menu-expand-or-complete", menuexpandorcomplete, ZLE_MENUCMP | ZLE_KEEPSUFFIX
-"neg-argument", negargument, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_LASTCOL
+"neg-argument", negargument, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_LASTCOL | ZLE_NOTCOMMAND
 "overwrite-mode", overwritemode, 0
 "pound-insert", poundinsert, 0
 "push-input", pushinput, 0
@@ -95,7 +95,7 @@
 "transpose-words", transposewords, 0
 "undefined-key", undefinedkey, 0
 "undo", undo, 0
-"universal-argument", universalargument, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_LASTCOL
+"universal-argument", universalargument, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_LASTCOL | ZLE_NOTCOMMAND
 "up-case-word", upcaseword, 0
 "up-history", uphistory, 0
 "up-line-or-history", uplineorhistory, ZLE_LINEMOVE | ZLE_LASTCOL
Index: Src/Zle/zle.h
===================================================================
RCS file: /extra/cvsroot/zsh/zsh-3.1/Src/Zle/zle.h,v
retrieving revision 1.3
diff -u -r1.3 zle.h
--- zle.h	1998/11/04 17:13:56	1.3
+++ zle.h	1998/11/06 07:05:06
@@ -56,6 +56,7 @@
 #define ZLE_LASTCOL     (1<<5)    /* command maintains lastcol correctly */
 #define ZLE_KILL	(1<<6)
 #define ZLE_KEEPSUFFIX	(1<<9)    /* DON'T remove added suffix */
+#define ZLE_NOTCOMMAND	(1<<10)   /* widget should not alter lastcmd */
 
 /* thingies */
 
Index: Src/Zle/zle_main.c
===================================================================
RCS file: /extra/cvsroot/zsh/zsh-3.1/Src/Zle/zle_main.c,v
retrieving revision 1.4
diff -u -r1.4 zle_main.c
--- zle_main.c	1998/11/04 17:13:56	1.4
+++ zle_main.c	1998/11/06 07:05:01
@@ -576,7 +576,8 @@
 	if(!(wflags & ZLE_LASTCOL))
 	    lastcol = -1;
 	w->u.fn();
-	lastcmd = wflags;
+	if (!(wflags & ZLE_NOTCOMMAND))
+	    lastcmd = wflags;
     } else {
 	List l = getshfunc(w->u.fnnam);
 

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: PATCH: 3.1.5 - cumulative reverse-kills (Re: [patch] deltochar)
  1998-11-06  7:13 ` PATCH: 3.1.5 - cumulative reverse-kills (Re: [patch] deltochar) Bart Schaefer
@ 1998-11-06 14:10   ` Greg Klanderman
  0 siblings, 0 replies; 3+ messages in thread
From: Greg Klanderman @ 1998-11-06 14:10 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: greg, Zsh list


>>>>> "Bart" == Bart Schaefer <schaefer@brasslantern.com> writes:
Bart> 
Bart> On Nov 5, 12:34pm, Greg Klanderman wrote:
Bart> } Subject: [patch] deltochar
Bart> }
Bart> } Reverse kills were not handled correctly.  Also, kill the text so it
Bart> } can be yanked, like emacs does.
Bart> 
Bart> I'm being sort of nitpicky here, but I think the following is a better
Bart> patch.  It makes the reverse kill case parallel the forward kill case
Bart> more closely.

Looks better to me, thanks.
greg


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1998-11-06 14:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-11-05 17:34 [patch] deltochar Greg Klanderman
1998-11-06  7:13 ` PATCH: 3.1.5 - cumulative reverse-kills (Re: [patch] deltochar) Bart Schaefer
1998-11-06 14:10   ` Greg Klanderman

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

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 NNTP newsgroup(s).