From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6360 invoked from network); 10 Sep 2004 11:00:40 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 10 Sep 2004 11:00:40 -0000 Received: (qmail 88036 invoked from network); 10 Sep 2004 11:00:34 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 10 Sep 2004 11:00:34 -0000 Received: (qmail 15757 invoked by alias); 10 Sep 2004 11:00:22 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 20348 Received: (qmail 15670 invoked from network); 10 Sep 2004 11:00:21 -0000 Received: from unknown (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 10 Sep 2004 11:00:21 -0000 Received: (qmail 85412 invoked from network); 10 Sep 2004 10:59:22 -0000 Received: from lhuumrelay3.lnd.ops.eu.uu.net (62.189.58.19) by a.mx.sunsite.dk with SMTP; 10 Sep 2004 10:59:19 -0000 Received: from MAILSWEEPER01.csr.com (mailhost1.csr.com [62.189.183.235]) by lhuumrelay3.lnd.ops.eu.uu.net (8.11.0/8.11.0) with ESMTP id i8AAxHv18324 for ; Fri, 10 Sep 2004 10:59:17 GMT Received: from EXCHANGE02.csr.com (unverified [192.168.137.45]) by MAILSWEEPER01.csr.com (Content Technologies SMTPRS 4.3.12) with ESMTP id for ; Fri, 10 Sep 2004 11:58:24 +0100 Received: from news01.csr.com ([192.168.143.38]) by EXCHANGE02.csr.com with Microsoft SMTPSVC(5.0.2195.6713); Fri, 10 Sep 2004 12:00:20 +0100 Received: from news01.csr.com (localhost.localdomain [127.0.0.1]) by news01.csr.com (8.12.11/8.12.11) with ESMTP id i8AAxFMh020702 for ; Fri, 10 Sep 2004 11:59:15 +0100 Received: from csr.com (pws@localhost) by news01.csr.com (8.12.11/8.12.11/Submit) with ESMTP id i8AAxFkl020699 for ; Fri, 10 Sep 2004 11:59:15 +0100 Message-Id: <200409101059.i8AAxFkl020699@news01.csr.com> X-Authentication-Warning: news01.csr.com: pws owned process doing -bs To: zsh-workers@sunsite.dk Subject: Re: Difficulties with _oldlist In-reply-to: References: <200409081656.i88Gu7dA011749@news01.csr.com> Date: Fri, 10 Sep 2004 11:59:15 +0100 From: Peter Stephenson X-OriginalArrivalTime: 10 Sep 2004 11:00:20.0056 (UTC) FILETIME=[5CD98580:01C49725] X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=0.0 required=6.0 tests=none autolearn=no version=2.63 X-Spam-Hits: 0.0 Bart Schaefer wrote: > Hmm, interesting. I'd rather put the name of the function in yet another > variable (WIDGETFUNC ?) and have it available for "zle -C" widgets, too. > > For "zle -N" widgets, I think WIDGETSTYLE should initially be unset, so it > can be tested with [[ -z ]] to differentiate completion from "normal" when > inside a widget function. (If it's just the function name, there's no way > of preventing a function having the same name as a builtin widget, thereby > confusing matters.) This sounds reasonable. It's easier to make WIDGETSTYLE set to the empty string for zle -N widgets, rather than unset, since otherwise we need to set up the parameters differently for the two types. However, it would be possible to post process the list to unset it. (Not setting up the variable at all isn't an option since then we can't guarantee it's unset.) I think it's OK as it is, however, since it gives you an easy test. Index: Doc/Zsh/zle.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/zle.yo,v retrieving revision 1.42 diff -u -r1.42 zle.yo --- Doc/Zsh/zle.yo 9 Sep 2004 10:12:46 -0000 1.42 +++ Doc/Zsh/zle.yo 10 Sep 2004 09:56:53 -0000 @@ -732,15 +732,21 @@ item(tt(WIDGET) (scalar))( The name of the widget currently being executed; read-only. ) +vindex(WIDGETFUNC) +item(tt(WIDGETFUNC) (scalar))( +The name of the shell function that implements a widget defined with +either tt(zle -N) or tt(zle -C). In the former case, this is the second +argument to the tt(zle -N) command that defined the widget, or +the first argument if there was no second argument. In the latter case +this is the the third argument to the tt(zle -C) command that defined the +widget. Read-only. +) vindex(WIDGETSTYLE) -item(tt(WIDGET) (scalar))( -Describes the implementation behind the widget currently being executed; -the second argument that followed tt(zle -C) or tt(zle -N) when the widget -was defined, if any. If the widget was defined with tt(zle -N) and there was -no second argument this is the same as the first argument. Hence for -tt(zle -N) this gives the name of the function that implements the widget, -and for tt(zle -C) this gives the internal completion widget that defines -the type of completion. Read-only. +item(tt(WIDGETSTYLE) (scalar))( +Describes the implementation behind the completion widget currently being +executed; the second argument that followed tt(zle -C) when the widget was +defined. This is the name of a builtin completion widget. For widgets +defined with tt(zle -N) this is set to the empty string. Read-only. ) enditem() Index: Src/Zle/zle_params.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_params.c,v retrieving revision 1.17 diff -u -r1.17 zle_params.c --- Src/Zle/zle_params.c 9 Sep 2004 10:12:47 -0000 1.17 +++ Src/Zle/zle_params.c 10 Sep 2004 09:56:53 -0000 @@ -93,6 +93,8 @@ zleunsetfn, NULL }, { "WIDGET", PM_SCALAR | PM_READONLY, NULL, FN(get_widget), zleunsetfn, NULL }, + { "WIDGETFUNC", PM_SCALAR | PM_READONLY, NULL, FN(get_widgetfunc), + zleunsetfn, NULL }, { "WIDGETSTYLE", PM_SCALAR | PM_READONLY, NULL, FN(get_widgetstyle), zleunsetfn, NULL }, { NULL, 0, NULL, NULL, NULL, NULL } @@ -282,6 +284,21 @@ /**/ static char * +get_widgetfunc(UNUSED(Param pm)) +{ + Widget widget = bindk->widget; + int flags = widget->flags; + + if (flags & WIDGET_INT) + return ".internal"; /* Don't see how this can ever be returned... */ + else if (flags & WIDGET_NCOMP) + return widget->u.comp.func; + else + return widget->u.fnnam; +} + +/**/ +static char * get_widgetstyle(UNUSED(Param pm)) { Widget widget = bindk->widget; @@ -292,7 +309,7 @@ else if (flags & WIDGET_NCOMP) return widget->u.comp.wid; else - return widget->u.fnnam; + return ""; } /**/ -- Peter Stephenson Software Engineer CSR Ltd., Science Park, Milton Road, Cambridge, CB4 0WH, UK Tel: +44 (0)1223 692070 ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This footnote also confirms that this email message has been swept by MIMEsweeper for the presence of computer viruses. www.mimesweeper.com **********************************************************************