From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8578 invoked by alias); 4 Nov 2011 13:43:56 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 29891 Received: (qmail 7701 invoked from network); 4 Nov 2011 13:43:53 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at csr.com does not designate permitted sender hosts) Date: Fri, 4 Nov 2011 13:03:21 +0000 From: Peter Stephenson To: "Zsh Hackers' List" Subject: zle -lL with arguments Message-ID: <20111104130321.5caf514f@pwslap01u.europe.root.pri> Organization: Cambridge Silicon Radio X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.101.11.233] X-Scanned-By: MailControl 7.6.3 (www.mailcontrol.com) on 10.68.0.163 "zle -l" with arguments is a bit bizarre: it doesn't print anything, just tests if the widget exists. This should really be a different option, but presumably we're stuck with this now. Currently "zle -lL" with arguments doesn't do anything different from that, so is therefore not a useful combination. I propose to make this list matching user-defined widgets in the usual "-L" form. This fixes a gap that seems to need "grep" at the moment (which doesn't have widget-name completion). Index: Doc/Zsh/zle.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/zle.yo,v retrieving revision 1.94 diff -p -u -r1.94 zle.yo --- Doc/Zsh/zle.yo 27 May 2011 14:29:03 -0000 1.94 +++ Doc/Zsh/zle.yo 4 Nov 2011 13:02:16 -0000 @@ -392,11 +392,16 @@ commands to create the widgets. When combined with the tt(-a) option, all widget names are listed, including the builtin ones. In this case the tt(-L) option is ignored. -If at least one var(string) is given, nothing will be printed but the -return status will be zero if all var(string)s are names of existing -widgets (or of user-defined widgets if the tt(-a) flag is not given) -and non-zero if at least one var(string) is not a name of an defined -widget. +If at least one var(string) is given, and tt(-a) is present or tt(-L) is +not used, nothing will be printed. The return status will be zero if +all var(string)s are names of existing widgets and non-zero if at least one +var(string) is not a name of a defined widget. If tt(-a) is also +present, all widget names are used for the comparison including builtin +widgets, else only user-defined widgets are used. + +If at least one var(string) is present and the tt(-L) option is used, +user-defined widgets matching any var(string) are listed in the form of +tt(zle) commands to create the widgets. ) item(tt(-D) var(widget) ...)( Delete the named var(widget)s. Index: Src/Zle/zle_thingy.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_thingy.c,v retrieving revision 1.34 diff -p -u -r1.34 zle_thingy.c --- Src/Zle/zle_thingy.c 20 Apr 2008 21:17:30 -0000 1.34 +++ Src/Zle/zle_thingy.c 4 Nov 2011 13:02:16 -0000 @@ -394,9 +394,13 @@ bin_zle_list(UNUSED(char *name), char ** Thingy t; for (; *args && !ret; args++) { - if (!(t = (Thingy) thingytab->getnode2(thingytab, *args)) || + HashNode hn = thingytab->getnode2(thingytab, *args); + if (!(t = (Thingy) hn) || (!OPT_ISSET(ops,'a') && (t->widget->flags & WIDGET_INT))) ret = 1; + else if (OPT_ISSET(ops,'L')) { + scanlistwidgets(hn, 1); + } } return ret; } @@ -483,6 +487,12 @@ bin_zle_keymap(char *name, char **args, return selectkeymap(*args, 0); } +/* + * List a widget. + * If list is negative, just print the name. + * If list is 0, use abbreviated format. + * If list is positive, output as a command. + */ /**/ static void scanlistwidgets(HashNode hn, int list) -- Peter Stephenson Software Engineer Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog