about summary refs log tree commit diff
path: root/Src/Zle/zle_main.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2006-04-25 15:00:25 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2006-04-25 15:00:25 +0000
commit949f5b6deefb7d4944f1b59fe2264ac0821a3304 (patch)
tree7de8db95eb7906e55339494e59963f56ba54038b /Src/Zle/zle_main.c
parent20198effd4b511d27fc8f594f23352ff0ff57f2c (diff)
downloadzsh-949f5b6deefb7d4944f1b59fe2264ac0821a3304.tar.gz
zsh-949f5b6deefb7d4944f1b59fe2264ac0821a3304.tar.xz
zsh-949f5b6deefb7d4944f1b59fe2264ac0821a3304.zip
22431: set WIDGET etc. more consistently when executing zle functions
Diffstat (limited to 'Src/Zle/zle_main.c')
-rw-r--r--Src/Zle/zle_main.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c
index f21dea9cc..904bf148e 100644
--- a/Src/Zle/zle_main.c
+++ b/Src/Zle/zle_main.c
@@ -862,7 +862,7 @@ zlecore(void)
 		eofsent = 1;
 		break;
 	    }
-	    if (execzlefunc(bindk, zlenoargs)) {
+	    if (execzlefunc(bindk, zlenoargs, 0)) {
 		handlefeep(zlenoargs);
 		if (eofsent)
 		    break;
@@ -1011,7 +1011,7 @@ zleread(char **lp, char **rp, int flags, int context)
 	char *args[2];
 	args[0] = initthingy->nam;
 	args[1] = NULL;
-	execzlefunc(initthingy, args);
+	execzlefunc(initthingy, args, 1);
 	unrefthingy(initthingy);
 	errflag = retflag = 0;
     }
@@ -1040,14 +1040,22 @@ zleread(char **lp, char **rp, int flags, int context)
     return s;
 }
 
-/* execute a widget */
+/*
+ * Execute a widget.  The third argument indicates that the global
+ * variable bindk should be set temporarily so that WIDGET etc.
+ * reflect the command being executed.
+ */
 
 /**/
 int
-execzlefunc(Thingy func, char **args)
+execzlefunc(Thingy func, char **args, int set_bindk)
 {
     int r = 0, ret = 0;
     Widget w;
+    Thingy save_bindk = bindk;
+
+    if (set_bindk)
+	bindk = func;
 
     if(func->flags & DISABLED) {
 	/* this thingy is not the name of a widget */
@@ -1143,6 +1151,8 @@ execzlefunc(Thingy func, char **args)
 	refthingy(func);
 	lbindk = func;
     }
+    if (set_bindk)
+	bindk = save_bindk;
     return ret;
 }