From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 510 invoked from network); 25 Apr 2006 14:52:44 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.1 (2006-03-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.1 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 25 Apr 2006 14:52:44 -0000 Received: (qmail 66048 invoked from network); 25 Apr 2006 14:52:37 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 25 Apr 2006 14:52:37 -0000 Received: (qmail 16888 invoked by alias); 25 Apr 2006 14:52:35 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 22431 Received: (qmail 16878 invoked from network); 25 Apr 2006 14:52:34 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 25 Apr 2006 14:52:34 -0000 Received: (qmail 65750 invoked from network); 25 Apr 2006 14:52:34 -0000 Received: from cluster-c.mailcontrol.com (168.143.177.190) by a.mx.sunsite.dk with SMTP; 25 Apr 2006 14:52:32 -0000 Received: from exchange03.csr.com (uuk202166.uk.customer.alter.net [62.189.241.194] (may be forged)) by rly12c.srv.mailcontrol.com (MailControl) with ESMTP id k3PEqUgq021671 for ; Tue, 25 Apr 2006 15:52:30 +0100 Received: from csr.com ([10.103.143.38]) by exchange03.csr.com with Microsoft SMTPSVC(5.0.2195.6713); Tue, 25 Apr 2006 15:52:26 +0100 To: zsh-workers@sunsite.dk (Zsh hackers list) Subject: Re: Problem with motion commands defined using match-word-by-style used with vi-delete In-reply-to: <060425072847.ZM1813@torch.brasslantern.com> References: <060423085310.ZM31491@torch.brasslantern.com> <200604232308.k3NN8Wtj004945@pwslaptop.csr.com> <060424200611.ZM996@torch.brasslantern.com> <060425072847.ZM1813@torch.brasslantern.com> Comments: In-reply-to Bart Schaefer message dated "Tue, 25 Apr 2006 07:28:47 -0700." Date: Tue, 25 Apr 2006 15:52:27 +0100 From: Peter Stephenson Message-ID: X-OriginalArrivalTime: 25 Apr 2006 14:52:26.0948 (UTC) FILETIME=[DE789840:01C66877] Content-Type: text/plain MIME-Version: 1.0 X-Scanned-By: MailControl A-06-00-04 (www.mailcontrol.com) on 10.67.0.122 Bart Schaefer wrote: > So ... shouldn't getvirange() do this part too? What harm could it be? > > } + bindk = t; > } ret = execzlefunc(t, args); > } + bindk = savbindk; It depends: is it useful to know that the motion commands are running as part of a vi command? Changing it would make it more consistent with Nicholas' proposed use. The following patch makes this feature an argument to execzlefunc(); it looks like it would be sensible to use this for stand-alone widgets that aren't run directly by the user, too. Index: Src/Zle/zle_main.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_main.c,v retrieving revision 1.84 diff -u -r1.84 zle_main.c --- Src/Zle/zle_main.c 7 Mar 2006 21:31:43 -0000 1.84 +++ Src/Zle/zle_main.c 25 Apr 2006 14:48:10 -0000 @@ -862,7 +862,7 @@ eofsent = 1; break; } - if (execzlefunc(bindk, zlenoargs)) { + if (execzlefunc(bindk, zlenoargs, 0)) { handlefeep(zlenoargs); if (eofsent) break; @@ -1011,7 +1011,7 @@ char *args[2]; args[0] = initthingy->nam; args[1] = NULL; - execzlefunc(initthingy, args); + execzlefunc(initthingy, args, 1); unrefthingy(initthingy); errflag = retflag = 0; } @@ -1040,14 +1040,22 @@ return s; } -/* execute a widget */ +/* + * Execute a widget. The third argument indicates that the global + * variable bindk should be set temporarily so that WIDGET etc. + * reflect the command being executed. + */ /**/ int -execzlefunc(Thingy func, char **args) +execzlefunc(Thingy func, char **args, int set_bindk) { int r = 0, ret = 0; Widget w; + Thingy save_bindk = bindk; + + if (set_bindk) + bindk = func; if(func->flags & DISABLED) { /* this thingy is not the name of a widget */ @@ -1143,6 +1151,8 @@ refthingy(func); lbindk = func; } + if (set_bindk) + bindk = save_bindk; return ret; } Index: Src/Zle/zle_thingy.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_thingy.c,v retrieving revision 1.27 diff -u -r1.27 zle_thingy.c --- Src/Zle/zle_thingy.c 25 Apr 2006 10:10:51 -0000 1.27 +++ Src/Zle/zle_thingy.c 25 Apr 2006 14:48:11 -0000 @@ -639,7 +639,7 @@ static int bin_zle_call(char *name, char **args, UNUSED(Options ops), UNUSED(char func)) { - Thingy t, savbindk = bindk; + Thingy t; struct modifier modsave = zmod; int ret, saveflag = 0, setbindk = 0; char *wname = *args++, *keymap_restore = NULL, *keymap_tmp; @@ -704,10 +704,7 @@ } t = rthingy(wname); - if (setbindk) - bindk = t; - ret = execzlefunc(t, args); - bindk = savbindk; + ret = execzlefunc(t, args, setbindk); unrefthingy(t); if (saveflag) zmod = modsave; Index: Src/Zle/zle_vi.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_vi.c,v retrieving revision 1.13 diff -u -r1.13 zle_vi.c --- Src/Zle/zle_vi.c 1 Nov 2005 02:50:30 -0000 1.13 +++ Src/Zle/zle_vi.c 25 Apr 2006 14:48:12 -0000 @@ -181,7 +181,7 @@ * a number of lines is used. If the function used * returns 1, we fail. */ - if ((k2 == bindk) ? dovilinerange() : execzlefunc(k2, zlenoargs)) + if ((k2 == bindk) ? dovilinerange() : execzlefunc(k2, zlenoargs, 1)) ret = -1; if(vichgrepeat) zmult = mult1; -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070 To access the latest news from CSR copy this link into a web browser: http://www.csr.com/email_sig.php