From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2628 invoked from network); 6 Nov 1998 07:27:39 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 6 Nov 1998 07:27:39 -0000 Received: (from list@localhost) by math.gatech.edu (8.9.1/8.9.1) id CAA14265; Fri, 6 Nov 1998 02:21:59 -0500 (EST) Resent-Date: Fri, 6 Nov 1998 02:21:59 -0500 (EST) From: "Bart Schaefer" Message-Id: <981105231353.ZM32715@candle.brasslantern.com> Date: Thu, 5 Nov 1998 23:13:53 -0800 In-Reply-To: <13889.57739.993748.165972@catbus.alphatech.com> Comments: In reply to greg@alphatech.com (Greg Klanderman) "[patch] deltochar" (Nov 5, 12:34pm) References: <13889.57739.993748.165972@catbus.alphatech.com> X-Mailer: Z-Mail (4.0b.820 20aug96) To: greg@alphatech.com, zsh-workers@math.gatech.edu (Zsh list) Subject: PATCH: 3.1.5 - cumulative reverse-kills (Re: [patch] deltochar) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Resent-Message-ID: <"o1KfS1.0.qU3.NEgGs"@math> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/4570 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu 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