Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

zle -lL with arguments



"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 <pws@xxxxxxx>            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



Messages sorted by: Reverse Date, Date, Thread, Author