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

PATCH: more fun with `zle'



Instead of trying to fix the stuff reported 6950 or trying to improve
_oldlist for 6958 I just played a bit with user-defined widgets. Here
is one result:

This allows `zle -R' to take a list of words (after the statusline-
string) and makes these words be listed under the prompt like a
completion list (it's a interface for the listlist() function).
It also adds the `-c' flag that can be combined with `-R' to get rid
of such a list.

While playing with this I noticed a bug with things like execute-named-
command: if you do `M-x <TAB> ^L' listmatches() gets called with a
invalid list (and -- with debugging enabled -- says so). I don't have
a working 3.0.6 version any more, but I guess this can be in there,
too. So, Bart: the hunks that only add a `showinglist = 0' should
probably applied to it.

(Examples for the new stuff will follow...)

Bye
 Sven

diff -u -r kos/Zle/zle_main.c Src/Zle/zle_main.c
--- kos/Zle/zle_main.c	Wed Jul  7 08:50:32 1999
+++ Src/Zle/zle_main.c	Wed Jul  7 08:58:59 1999
@@ -948,7 +948,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, "lDANCLmMgGcRa",  NULL),
+    BUILTIN("zle",     0, bin_zle,     0, -1, 0, "lDANCLmMgGcRaU", NULL),
 };
 
 /* The order of the entries in this table has to match the *HOOK
diff -u -r kos/Zle/zle_misc.c Src/Zle/zle_misc.c
--- kos/Zle/zle_misc.c	Wed Jul  7 08:50:32 1999
+++ Src/Zle/zle_misc.c	Wed Jul  7 08:58:59 1999
@@ -736,6 +736,7 @@
 		    statusll = l + len + 1;
 		    zmult = 1;
 		    listlist(cmdll);
+		    showinglist = 0;
 		    zmult = zmultsav;
 		} else if (!nextnode(firstnode(cmdll))) {
 		    strcpy(ptr = cmdbuf, peekfirst(cmdll));
@@ -754,6 +755,7 @@
 			statusll = l + cmdambig + 1;
 			zmult = 1;
 			listlist(cmdll);
+			showinglist = 0;
 			zmult = zmultsav;
 		    }
 		    len = cmdambig;
diff -u -r kos/Zle/zle_thingy.c Src/Zle/zle_thingy.c
--- kos/Zle/zle_thingy.c	Wed Jul  7 08:50:32 1999
+++ Src/Zle/zle_thingy.c	Wed Jul  7 08:58:59 1999
@@ -340,7 +340,8 @@
 	{ 'A', bin_zle_link, 2,  2 },
 	{ 'N', bin_zle_new,  1,  2 },
 	{ 'C', bin_zle_complete, 3, 3 },
-	{ 'R', bin_zle_refresh, 0, 1 },
+	{ 'R', bin_zle_refresh, 0, -1 },
+	{ 'U', bin_zle_unget, 1, 1 },
 	{ 0,   bin_zle_call, 0, -1 },
     };
     struct opn const *op, *opp;
@@ -396,19 +397,46 @@
 bin_zle_refresh(char *name, char **args, char *ops, char func)
 {
     char *s = statusline;
-    int sl = statusll;
+    int sl = statusll, ocl = clearlist;
 
+    statusline = NULL;
+    statusll = 0;
     if (*args) {
-	statusline = *args;
-	statusll = strlen(statusline);
-    } else {
-	statusline = NULL;
-	statusll = 0;
-    }
+	if (**args) {
+	    statusline = *args;
+	    statusll = strlen(statusline);
+	}
+	if (*++args) {
+	    LinkList l = newlinklist();
+	    int zmultsav = zmult;
+
+	    for (; *args; args++)
+		addlinknode(l, *args);
+
+	    zmult = 1;
+	    listlist(l);
+	    showinglist = clearlist = 0;
+	    zmult = zmultsav;
+	} else if (ops['c'])
+	    clearlist = 1;
+    } else if (ops['c'])
+	clearlist = 1;
     zrefresh();
 
+    clearlist = ocl;
     statusline = s;
     statusll = sl;
+    return 0;
+}
+
+/**/
+static int
+bin_zle_unget(char *name, char **args, char *ops, char func)
+{
+    char *p = *args;
+
+    while (*p)
+	ungetkey((int) *p++);
     return 0;
 }
 
diff -u -r kos/Zle/zle_tricky.c Src/Zle/zle_tricky.c
--- kos/Zle/zle_tricky.c	Wed Jul  7 08:50:33 1999
+++ Src/Zle/zle_tricky.c	Wed Jul  7 08:59:00 1999
@@ -1773,6 +1773,7 @@
 	if (lst == COMP_LIST_EXPAND) {
 	    /* Only the list of expansions was requested. */
 	    listlist(vl);
+	    showinglist = 0;
 	    goto end;
 	}
 	/* Remove the current word and put the expansions there. */
diff -u -r kod/Zsh/mod_zle.yo Doc/Zsh/mod_zle.yo
--- kod/Zsh/mod_zle.yo	Wed Jul  7 08:50:41 1999
+++ Doc/Zsh/mod_zle.yo	Wed Jul  7 08:59:00 1999
@@ -177,7 +177,8 @@
 xitem(tt(zle) tt(-A) var(old-widget) var(new-widget))
 xitem(tt(zle) tt(-N) var(widget) [ var(function) ])
 xitem(tt(zle) tt(-C) var(widget) var(completion-widget) var(function))
-xitem(tt(zle) tt(-R) [ var(display-string) ])
+xitem(tt(zle) tt(-R) [ tt(-c) ] [ var(display-string) ] [ var(string) ... ])
+xitem(tt(zle) tt(-U) var(string))
 item(tt(zle) var(widget) tt([ -n) var(num) tt(]) tt([ -N ]) var(args) ...)(
 The tt(zle) builtin performs a number of different actions concerning
 ZLE.  Which operation it performs depends on its options:
@@ -227,11 +228,21 @@
 ifnzman(noderef(Completion Widgets))\
 .
 )
-item(tt(-R) [ var(display-string) ])(
+item(tt(-R) [ tt(-c) ] [ var(display-string) ] [ var(string) ... ])(
 Redisplay the command line; this is to be called from within a user-defined
 widget to allow changes to become visible.  If a var(display-string) is
-given, this is shown in the status line (immediately below the line being
-edited).
+given and not empty, this is shown in the status line (immediately
+below the line being edited).
+
+If the optional var(string)s are given they are listed below the
+prompt in the same way as completion lists are printed. If no
+var(string)s are given but the tt(-c) option is used such a list is
+cleared.
+)
+item(tt(-U) var(string))(
+This puts the characters in the var(string) in the input queue of
+ZLE. After the widget currently executed finishes ZLE will behave as
+if the characters in the var(string) were typed by the user.
 )
 item(var(widget) tt([ -n) var(num) tt(]) tt([ -N ]) var(args) ...)(
 Invoke the specified widget.  This can only be done when ZLE is

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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