From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: widget listing/testing
Date: Wed, 23 Jun 1999 10:03:01 +0200 (MET DST) [thread overview]
Message-ID: <199906230803.KAA05929@beta.informatik.hu-berlin.de> (raw)
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
next reply other threads:[~1999-06-23 8:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-06-23 8:03 Sven Wischnowsky [this message]
1999-06-23 7:43 ` Peter Stephenson
1999-06-24 14:59 ` Bart Schaefer
1999-06-24 15:13 ` Peter Stephenson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=199906230803.KAA05929@beta.informatik.hu-berlin.de \
--to=wischnow@informatik.hu-berlin.de \
--cc=zsh-workers@sunsite.auc.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).