zsh-workers
 help / color / mirror / code / Atom feed
* Re: PATCH: widget listing/testing
  1999-06-23  8:03 PATCH: widget listing/testing Sven Wischnowsky
@ 1999-06-23  7:43 ` Peter Stephenson
  1999-06-24 14:59 ` Bart Schaefer
  1 sibling, 0 replies; 4+ messages in thread
From: Peter Stephenson @ 1999-06-23  7:43 UTC (permalink / raw)
  To: zsh-workers

Sven Wischnowsky wrote:
> This makes `zle -la' list the names of all widgets, including the
> builtin ones (and only the names).

I also sent a patch for this yesterday, but it's stuck permanently in the
mail queue without telling anyone (and both the disks I have access to
filled up, so situtation completely normal).  It handled zle -la, but you
got a long format listing like zle -l which showed you aliases where
appropriate unless you also gave -r for raw, and there was also a -b for
builtin widgets only.

-- 
Peter Stephenson <pws@ibmth.df.unipi.it>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy


^ permalink raw reply	[flat|nested] 4+ messages in thread

* PATCH: widget listing/testing
@ 1999-06-23  8:03 Sven Wischnowsky
  1999-06-23  7:43 ` Peter Stephenson
  1999-06-24 14:59 ` Bart Schaefer
  0 siblings, 2 replies; 4+ messages in thread
From: Sven Wischnowsky @ 1999-06-23  8:03 UTC (permalink / raw)
  To: zsh-workers


This makes `zle -la' list the names of all widgets, including the
builtin ones (and only the names).
It also makes `zle -l [-a]' accept optional arguments: in this case
nothing will be printed, but the return status is set to aero if all
arguments name existing widgets and to one if at least one argument is 
not the name of a widget. I.e. you can easily test if a widget is
defined by saying `zle -la foo && ...'.

There is also a hunk for compinit that `zle -c's menu-select if it is
defined. (We could also try automatic loading of `complist' here...)

Bye
 Sven

diff -u os/Zle/zle_main.c Src/Zle/zle_main.c
--- os/Zle/zle_main.c	Tue Jun 22 21:03:51 1999
+++ Src/Zle/zle_main.c	Tue Jun 22 21:18:59 1999
@@ -955,7 +955,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, "lDANCLmMgGcRa",  NULL),
 };
 
 /* The order of the entries in this table has to match the *HOOK
diff -u os/Zle/zle_thingy.c Src/Zle/zle_thingy.c
--- os/Zle/zle_thingy.c	Tue Jun 22 21:03:51 1999
+++ Src/Zle/zle_thingy.c	Tue Jun 22 21:21:47 1999
@@ -318,9 +318,10 @@
 /*
  * The available operations are:
  *
- *   -l   list user-defined widgets (no arguments)
+ *   -l   list widgets/test for existence
  *   -D   delete widget names
  *   -A   link the two named widgets (2 arguments)
+ *   -C   create completion widget (3 arguments)
  *   -N   create new user-defined widget (1 or 2 arguments)
  *        invoke a widget (1 argument)
  */
@@ -334,7 +335,7 @@
 	int (*func) _((char *, char **, char *, char));
 	int min, max;
     } const opns[] = {
-	{ 'l', bin_zle_list, 0,  0 },
+	{ 'l', bin_zle_list, 0, -1 },
 	{ 'D', bin_zle_del,  1, -1 },
 	{ 'A', bin_zle_link, 2,  2 },
 	{ 'N', bin_zle_new,  1,  2 },
@@ -373,8 +374,21 @@
 static int
 bin_zle_list(char *name, char **args, char *ops, char func)
 {
-    scanhashtable(thingytab, 1, 0, DISABLED, scanlistwidgets, ops['L']);
-    return 0;
+    if (!*args) {
+	scanhashtable(thingytab, 1, 0, DISABLED, scanlistwidgets,
+		      (ops['a'] ? -1 : ops['L']));
+	return 0;
+    } else {
+	int ret = 0;
+	Thingy t;
+
+	for (; *args && !ret; args++) {
+	    if (!(t = (Thingy) thingytab->getnode2(thingytab, *args)) ||
+		(!ops['a'] && (t->widget->flags & WIDGET_INT)))
+		ret = 1;
+	}
+	return ret;
+    }
 }
 
 /**/
@@ -405,6 +419,10 @@
     Thingy t = (Thingy) hn;
     Widget w = t->widget;
 
+    if(list < 0) {
+	printf("%s\n", hn->nam);
+	return;
+    }
     if(w->flags & WIDGET_INT)
 	return;
     if(list) {
diff -u od/Zsh/mod_zle.yo Doc/Zsh/mod_zle.yo
--- od/Zsh/mod_zle.yo	Tue Jun 22 21:03:37 1999
+++ Doc/Zsh/mod_zle.yo	Tue Jun 22 21:31:16 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(-L) ] [ tt(-a) ] [ var(string) ... ])
 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) ])
@@ -176,7 +176,15 @@
 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.
+
+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.
 )
 item(tt(-D) var(widget) ...)(
 Delete the named var(widget)s.
diff -u oc/Core/compinit Completion/Core/compinit
--- oc/Core/compinit	Tue Jun 22 14:01:43 1999
+++ Completion/Core/compinit	Tue Jun 22 21:37:31 1999
@@ -346,6 +346,7 @@
   menu-expand-or-complete reverse-menu-complete; do
   zle -C $_i_line .$_i_line _main_complete
 done
+zle -la menu-select && zle -C menu-select .menu-select _main_complete
 
 _i_done=''
 

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: PATCH: widget listing/testing
  1999-06-23  8:03 PATCH: widget listing/testing Sven Wischnowsky
  1999-06-23  7:43 ` Peter Stephenson
@ 1999-06-24 14:59 ` Bart Schaefer
  1999-06-24 15:13   ` Peter Stephenson
  1 sibling, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 1999-06-24 14:59 UTC (permalink / raw)
  To: zsh-workers

On Jun 23, 10:03am, Sven Wischnowsky wrote:
} Subject: PATCH: widget listing/testing
}
} This makes `zle -la' list the names of all widgets, including the
} builtin ones (and only the names).

So, which version of this patch are we eventually going to get in pws-24?
The one that made it to zsh-workers, or the more interesting one that PWS
says is in limbo somewhere?

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: PATCH: widget listing/testing
  1999-06-24 14:59 ` Bart Schaefer
@ 1999-06-24 15:13   ` Peter Stephenson
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Stephenson @ 1999-06-24 15:13 UTC (permalink / raw)
  To: zsh-workers

"Bart Schaefer" wrote:
> On Jun 23, 10:03am, Sven Wischnowsky wrote:
> } Subject: PATCH: widget listing/testing
> }
> } This makes `zle -la' list the names of all widgets, including the
> } builtin ones (and only the names).
> 
> So, which version of this patch are we eventually going to get in pws-24?
> The one that made it to zsh-workers, or the more interesting one that PWS
> says is in limbo somewhere?

I've just put in Sven's, since it's simpler and it does the job required,
which is getting the names of widgets.  The one I sent is still in the mail
list marked as `deferred', which suggests it hasn't been trying very hard,
and I've deleted all the patches on the disk here due to chronic disk space
shortage, so it may have gone now anyway.

-- 
Peter Stephenson <pws@ibmth.df.unipi.it>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1999-06-24 15:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-06-23  8:03 PATCH: widget listing/testing Sven Wischnowsky
1999-06-23  7:43 ` Peter Stephenson
1999-06-24 14:59 ` Bart Schaefer
1999-06-24 15:13   ` Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).