Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: pws-N: zle -l
- X-seq: zsh-workers 7095
- From: Peter Stephenson <pws@xxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx (Zsh hackers list)
- Subject: PATCH: pws-N: zle -l
- Date: Tue, 22 Jun 1999 18:30:13 +0200
Does this look alright?
I deleted some obsolete options to the zle command. Only -c did anything,
but I imagine everyone's code now uses zle -C.
--- Doc/Zsh/mod_zle.yo.lb Sun Jun 20 16:13:07 1999
+++ Doc/Zsh/mod_zle.yo Tue Jun 22 18:25:17 1999
@@ -161,7 +161,7 @@
cindex(calling widgets)
cindex(widgets, defining)
cindex(defining widgets)
-xitem(tt(zle) tt(-l) [ tt(-L) ])
+xitem(tt(zle) tt(-l) [ tt(-Labr) ])
xitem(tt(zle) tt(-D) var(widget) ...)
xitem(tt(zle) tt(-A) var(old-widget) var(new-widget))
xitem(tt(zle) tt(-N) var(widget) [ var(function) ])
@@ -175,8 +175,17 @@
item(tt(-l) [ tt(-L) ])(
List all existing user-defined widgets. If the tt(-L)
option is used, list in the form of tt(zle)
-commands to create the widgets.
-Built-in widgets are not listed.
+commands to create the widgets; this is incompatible with any of the
+options tt(-a), tt(-b) or tt(-r). If the option tt(-b) is given, builtin
+widgets (including aliases) are listed, and if tt(-a) is given, all widgets
+are listed.
+
+In the normal listing format (without tt(-L)), a function name for a
+user-defined widget is shown in parentheses only if it differs from the
+widget name; if a builtin widget is an alias for another, the name of the
+other widget is shown following the string `tt( -> )'. If the option
+tt(-r) is given, a listing in raw format, consisting just of the names of
+the widgets, is shown.
)
item(tt(-D) var(widget) ...)(
Delete the named var(widget)s.
--- Src/Zle/zle_main.c.lb Tue Jun 22 10:02:48 1999
+++ Src/Zle/zle_main.c Tue Jun 22 18:10:38 1999
@@ -953,7 +953,7 @@
static struct builtin bintab[] = {
BUILTIN("bindkey", 0, bin_bindkey, 0, -1, 0, "evaMldDANmrsLR", NULL),
BUILTIN("vared", 0, bin_vared, 1, 7, 0, NULL, NULL),
- BUILTIN("zle", 0, bin_zle, 0, -1, 0, "lDANCLmMgGcR", NULL),
+ BUILTIN("zle", 0, bin_zle, 0, -1, 0, "lDANCLRbar", NULL),
};
/* The order of the entries in this table has to match the *HOOK
--- Src/Zle/zle_thingy.c.lb Sun Jun 20 14:56:39 1999
+++ Src/Zle/zle_thingy.c Tue Jun 22 18:15:11 1999
@@ -369,11 +369,28 @@
return op->func(name, args, ops, op->o);
}
+#define ZLIST_INT 1
+#define ZLIST_USR 2
+#define ZLIST_CMD 4
+#define ZLIST_RAW 8
+
/**/
static int
bin_zle_list(char *name, char **args, char *ops, char func)
{
- scanhashtable(thingytab, 1, 0, DISABLED, scanlistwidgets, ops['L']);
+ int flags = ops['r'] ? ZLIST_RAW : 0;
+ if (ops['L']) {
+ if (ops['b'] || ops['a'] || ops['r']) {
+ zwarnnam(name, "incompatible options for listing", NULL, 0);
+ return 1;
+ }
+ flags |= ZLIST_CMD;
+ }
+ if (!ops['b'])
+ flags |= ZLIST_USR;
+ if (ops['a'] || ops['b'])
+ flags |= ZLIST_INT;
+ scanhashtable(thingytab, 1, 0, DISABLED, scanlistwidgets, flags);
return 0;
}
@@ -405,9 +422,11 @@
Thingy t = (Thingy) hn;
Widget w = t->widget;
- if(w->flags & WIDGET_INT)
+ if (((w->flags & WIDGET_INT) && !(list & ZLIST_INT)) ||
+ (!(w->flags & WIDGET_INT) && !(list & ZLIST_USR)))
return;
- if(list) {
+ if (list & ZLIST_CMD) {
+ DPUTS(w->flags & WIDGET_INT, "BUG: zle -lL with internal widget");
printf("zle -%c ", (w->flags & WIDGET_NCOMP) ? 'C' : 'N');
if(t->nam[0] == '-')
fputs("-- ", stdout);
@@ -423,15 +442,23 @@
}
} else {
nicezputs(t->nam, stdout);
- if (w->flags & WIDGET_NCOMP) {
- fputs(" -C ", stdout);
- nicezputs(w->u.comp.wid, stdout);
- fputc(' ', stdout);
- nicezputs(w->u.comp.func, stdout);
- } else if(strcmp(t->nam, w->u.fnnam)) {
- fputs(" (", stdout);
- nicezputs(w->u.fnnam, stdout);
- fputc(')', stdout);
+ if (! (list & ZLIST_RAW)) {
+ if (w->flags & WIDGET_NCOMP) {
+ fputs(" -C ", stdout);
+ nicezputs(w->u.comp.wid, stdout);
+ fputc(' ', stdout);
+ nicezputs(w->u.comp.func, stdout);
+ } else if (w->flags & WIDGET_INT) {
+ if (t != w->first && t->nam[0] != '.' &&
+ w->first->nam[0] != '.') {
+ fputs(" -> ", stdout);
+ nicezputs(w->first->nam, stdout);
+ }
+ } else if (strcmp(t->nam, w->u.fnnam)) {
+ fputs(" (", stdout);
+ nicezputs(w->u.fnnam, stdout);
+ fputc(')', stdout);
+ }
}
}
putchar('\n');
--
Peter Stephenson <pws@xxxxxxxxxxxxxxxxx> Tel: +39 050 844536
WWW: http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy
Messages sorted by:
Reverse Date,
Date,
Thread,
Author