summaryrefslogtreecommitdiff
path: root/Src
diff options
context:
space:
mode:
Diffstat (limited to 'Src')
-rw-r--r--Src/Zle/zle_main.c18
-rw-r--r--Src/Zle/zle_thingy.c7
-rw-r--r--Src/Zle/zle_vi.c2
3 files changed, 17 insertions, 10 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;
}
diff --git a/Src/Zle/zle_thingy.c b/Src/Zle/zle_thingy.c
index 209949df2..140aeb06a 100644
--- a/Src/Zle/zle_thingy.c
+++ b/Src/Zle/zle_thingy.c
@@ -639,7 +639,7 @@ zle_usable()
static int
bin_zle_call(char *name, char **args, UNUSED(Options ops), UNUSED(char func))
{
- Thingy t, savbindk = bindk;
+ Thingy t;
struct modifier modsave = zmod;
int ret, saveflag = 0, setbindk = 0;
char *wname = *args++, *keymap_restore = NULL, *keymap_tmp;
@@ -704,10 +704,7 @@ bin_zle_call(char *name, char **args, UNUSED(Options ops), UNUSED(char func))
}
t = rthingy(wname);
- if (setbindk)
- bindk = t;
- ret = execzlefunc(t, args);
- bindk = savbindk;
+ ret = execzlefunc(t, args, setbindk);
unrefthingy(t);
if (saveflag)
zmod = modsave;
diff --git a/Src/Zle/zle_vi.c b/Src/Zle/zle_vi.c
index 9058905f9..2549af80c 100644
--- a/Src/Zle/zle_vi.c
+++ b/Src/Zle/zle_vi.c
@@ -181,7 +181,7 @@ getvirange(int wf)
* a number of lines is used. If the function used
* returns 1, we fail.
*/
- if ((k2 == bindk) ? dovilinerange() : execzlefunc(k2, zlenoargs))
+ if ((k2 == bindk) ? dovilinerange() : execzlefunc(k2, zlenoargs, 1))
ret = -1;
if(vichgrepeat)
zmult = mult1;