about summary refs log tree commit diff
path: root/Src/Zle/zle_main.c
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>2000-03-14 11:12:08 +0000
committerTanaka Akira <akr@users.sourceforge.net>2000-03-14 11:12:08 +0000
commite91bdf82c9c7b9589bfd813cd7f571d50090f05b (patch)
tree5cd5e45d947125500f6cdf3e1748dc02872a2e21 /Src/Zle/zle_main.c
parent0e7c726c326ec255e00ce43818c793d974bc2268 (diff)
downloadzsh-e91bdf82c9c7b9589bfd813cd7f571d50090f05b.tar.gz
zsh-e91bdf82c9c7b9589bfd813cd7f571d50090f05b.tar.xz
zsh-e91bdf82c9c7b9589bfd813cd7f571d50090f05b.zip
zsh-workers/10128
Diffstat (limited to 'Src/Zle/zle_main.c')
-rw-r--r--Src/Zle/zle_main.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c
index 020710f07..1ba625685 100644
--- a/Src/Zle/zle_main.c
+++ b/Src/Zle/zle_main.c
@@ -992,6 +992,28 @@ trashzle(void)
 	kungetct = 0;
 }
 
+/* Hook functions. Used to allow access to zle parameters if zle is
+ * active. */
+
+static int
+zlebeforetrap(Hookdef dummy, void *dat)
+{
+    if (zleactive) {
+	startparamscope();
+	makezleparams(1);
+    }
+    return 0;
+}
+
+static int
+zleaftertrap(Hookdef dummy, void *dat)
+{
+    if (zleactive)
+	endparamscope();
+
+    return 0;
+}
+
 static struct builtin bintab[] = {
     BUILTIN("bindkey", 0, bin_bindkey, 0, -1, 0, "evaMldDANmrsLR", NULL),
     BUILTIN("vared",   0, bin_vared,   1,  7, 0, NULL,             NULL),
@@ -1049,6 +1071,8 @@ setup_(Module m)
 int
 boot_(Module m)
 {
+    addhookfunc("before_trap", (Hookfn) zlebeforetrap);
+    addhookfunc("after_trap", (Hookfn) zleaftertrap);
     addbuiltins(m->nam, bintab, sizeof(bintab)/sizeof(*bintab));
     addhookdefs(m->nam, zlehooks, sizeof(zlehooks)/sizeof(*zlehooks));
     return 0;
@@ -1063,6 +1087,8 @@ cleanup_(Module m)
 	    NULL, 0);
 	return 1;
     }
+    deletehookfunc("before_trap", (Hookfn) zlebeforetrap);
+    deletehookfunc("after_trap", (Hookfn) zleaftertrap);
     deletebuiltins(m->nam, bintab, sizeof(bintab)/sizeof(*bintab));
     deletehookdefs(m->nam, zlehooks, sizeof(zlehooks)/sizeof(*zlehooks));
     return 0;