about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2004-09-02 14:34:33 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2004-09-02 14:34:33 +0000
commitfb7907257503b2c8915d3623c694bfb21122b7df (patch)
tree8f2b50888038a35a484088e30173f5880aea6767 /Src
parentd24593bf3862046a4093226f21ce276bd23d0ae3 (diff)
downloadzsh-fb7907257503b2c8915d3623c694bfb21122b7df.tar.gz
zsh-fb7907257503b2c8915d3623c694bfb21122b7df.tar.xz
zsh-fb7907257503b2c8915d3623c694bfb21122b7df.zip
20303: zle -I test and running zle widgets in traps
Diffstat (limited to 'Src')
-rw-r--r--Src/Zle/zle_thingy.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/Src/Zle/zle_thingy.c b/Src/Zle/zle_thingy.c
index 53eb927f9..c252eee1e 100644
--- a/Src/Zle/zle_thingy.c
+++ b/Src/Zle/zle_thingy.c
@@ -619,6 +619,23 @@ bin_zle_complete(char *name, char **args, UNUSED(Options ops), UNUSED(char func)
 
 /**/
 static int
+zle_usable()
+{
+    return zleactive && !incompctlfunc && !incompfunc
+#if 0
+	/*
+	 * PWS experiment: commenting this out allows zle widgets
+	 * in signals, hooks etc.  I'm not sure if this has a down side;
+	 * it ought to be that zleactive is good enough to test whether
+	 * widgets are callable.
+	 */
+	&& sfcontext == SFC_WIDGET
+#endif
+	   ;
+}
+
+/**/
+static int
 bin_zle_call(char *name, char **args, UNUSED(Options ops), UNUSED(char func))
 {
     Thingy t;
@@ -629,10 +646,9 @@ bin_zle_call(char *name, char **args, UNUSED(Options ops), UNUSED(char func))
     if (!wname) {
 	if (saveflag)
 	    zmod = modsave;
-	return (!zleactive || incompctlfunc || incompfunc ||
-		sfcontext != SFC_WIDGET);
+	return !zle_usable();
     }
-    if(!zleactive || incompctlfunc || incompfunc || sfcontext != SFC_WIDGET) {
+    if(!zle_usable()) {
 	zwarnnam(name, "widgets can only be called when ZLE is active",
 	    NULL, 0);
 	return 1;
@@ -685,10 +701,15 @@ bin_zle_call(char *name, char **args, UNUSED(Options ops), UNUSED(char func))
 static int
 bin_zle_invalidate(UNUSED(char *name), UNUSED(char **args), UNUSED(Options ops), UNUSED(char func))
 {
+    /*
+     * Trash zle if trashable, but only indicate that zle is usable
+     * if it's possible to call a zle widget next.  This is not
+     * true if a completion widget is active.
+     */
     if (zleactive) {
 	if (!trashedzle)
 	    trashzle();
-	return 0;
+	return !zle_usable();
     } else
 	return 1;
 }