From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6410 invoked from network); 25 Apr 2006 10:00:24 -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 10:00:24 -0000 Received: (qmail 97462 invoked from network); 25 Apr 2006 10:00:18 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 25 Apr 2006 10:00:18 -0000 Received: (qmail 19235 invoked by alias); 25 Apr 2006 10:00:11 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 22427 Received: (qmail 19225 invoked from network); 25 Apr 2006 10:00:10 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 25 Apr 2006 10:00:10 -0000 Received: (qmail 96780 invoked from network); 25 Apr 2006 10:00:10 -0000 Received: from cluster-c.mailcontrol.com (168.143.177.190) by a.mx.sunsite.dk with SMTP; 25 Apr 2006 10:00:09 -0000 Received: from exchange03.csr.com (uuk202166.uk.customer.alter.net [62.189.241.194] (may be forged)) by rly23c.srv.mailcontrol.com (MailControl) with ESMTP id k3P9r3mt002665 for ; Tue, 25 Apr 2006 11:00:00 +0100 Received: from csr.com ([10.103.143.38]) by exchange03.csr.com with Microsoft SMTPSVC(5.0.2195.6713); Tue, 25 Apr 2006 10:58:05 +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: <060424200611.ZM996@torch.brasslantern.com> References: <060423085310.ZM31491@torch.brasslantern.com> <200604232308.k3NN8Wtj004945@pwslaptop.csr.com> <060424200611.ZM996@torch.brasslantern.com> Date: Tue, 25 Apr 2006 10:58:05 +0100 From: Peter Stephenson Message-ID: X-OriginalArrivalTime: 25 Apr 2006 09:58:05.0084 (UTC) FILETIME=[BF2E05C0:01C6684E] Content-Type: text/plain MIME-Version: 1.0 X-Scanned-By: MailControl A-06-00-04 (www.mailcontrol.com) on 10.67.0.133 Bart Schaefer wrote: > Incidentally I just noticed that within a widget called by using > execute-named-command, the value of $KEYS is carriage return. I'm not > sure what I expected it to be, but that wasn't it. I suppose the right answer is the \M-x sequence, or whatever called execute-named-command, followed by the command name, followed by a newline? > } There's still no easy way to execute the command in the right > } environment so that WIDGET is set to the read command that we want to > } execute. > > It really *should* be the case that > > local -h WIDGET > > creates a new parameter named WIDGET that is neither read-only nor > special, but apparently the usual parameter rules don't apply to the > ZLE specials. I think it's not just ZLE; I think it's all readonly specials are treated in such away that you can't replace them. The big problem in this case is that the zle parameters need to be removed after the execution of the widget, so they're paranoid about being hidden (although here the local scope should end first). I'm not sure how easy this is to fix generally. Here's a patch that allows you to request that zle sets the widget in the way that it does at the top level. It's actually done by storing the global Thingy in the variable bindk, so it's not quite that simple, but should have the desired effect, and do it more consistently than just setting WIDGET. Note that the option comes after the widget (zle widget -w) as with other options specific to calling widgets. Index: Doc/Zsh/zle.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/zle.yo,v retrieving revision 1.52 diff -u -r1.52 zle.yo --- Doc/Zsh/zle.yo 23 Apr 2006 23:13:47 -0000 1.52 +++ Doc/Zsh/zle.yo 25 Apr 2006 09:46:31 -0000 @@ -338,7 +338,7 @@ xitem(tt(zle) tt(-K) var(keymap)) xitem(tt(zle) tt(-F) [ tt(-L) ] [ var(fd) [ var(handler) ] ]) xitem(tt(zle) tt(-I)) -item(tt(zle) var(widget) tt([ -n) var(num) tt(]) tt([ -N ] [ -K) var(keymap) tt(]) var(args) ...)( +item(tt(zle) var(widget) tt([ -n) var(num) tt(]) tt([ -Nw ] [ -K) var(keymap) tt(]) var(args) ...)( The tt(zle) builtin performs a number of different actions concerning ZLE. @@ -535,7 +535,7 @@ notification. To test if a zle widget may be called at this point, execute tt(zle) with no arguments and examine the return status. ) -item(var(widget) tt([ -n) var(num) tt(]) tt([ -N ] [ -K) var(keymap) tt(]) var(args) ...)( +item(var(widget) tt([ -n) var(num) tt(]) tt([ -Nw ] [ -K) var(keymap) tt(]) var(args) ...)( Invoke the specified widget. This can only be done when ZLE is active; normally this will be within a user-defined widget. @@ -548,6 +548,12 @@ during the execution of the widget. The previous keymap will be restored when the widget exits. +Normally, calling a widget in this way does not set the special +parameter tt(WIDGET) and related parameters, so that the environment +appears as if the top-level widget called by the user were still +active. With the option tt(-w), tt(WIDGET) and related parameters are set +to reflect the widget being executed by the tt(zle) call. + Any further arguments will be passed to the widget. If it is a shell function, these are passed down as positional parameters; for builtin widgets it is up to the widget in question what it does with them. @@ -559,7 +565,7 @@ The return status reflects the success or failure of the operation carried out by the widget, or if it is a user-defined widget the return status of -the shell function. +the shell function. A non-zero return status causes the shell to beep when the widget exits, unless the tt(BEEP) options was unset or the widget was called via the Index: Src/Zle/zle_thingy.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_thingy.c,v retrieving revision 1.26 diff -u -r1.26 zle_thingy.c --- Src/Zle/zle_thingy.c 25 Mar 2006 18:50:44 -0000 1.26 +++ Src/Zle/zle_thingy.c 25 Apr 2006 09:46:32 -0000 @@ -639,9 +639,9 @@ static int bin_zle_call(char *name, char **args, UNUSED(Options ops), UNUSED(char func)) { - Thingy t; + Thingy t, savbindk = bindk; struct modifier modsave = zmod; - int ret, saveflag = 0; + int ret, saveflag = 0, setbindk = 0; char *wname = *args++, *keymap_restore = NULL, *keymap_tmp; if (!wname) @@ -692,6 +692,9 @@ if (selectkeymap(keymap_tmp, 0)) return 1; break; + case 'w': + setbindk = 1; + break; default: zwarnnam(name, "unknown option: %s", *args, 0); return 1; @@ -701,7 +704,10 @@ } t = rthingy(wname); + if (setbindk) + bindk = t; ret = execzlefunc(t, args); + bindk = savbindk; unrefthingy(t); if (saveflag) zmod = modsave; -- 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