Subject: [PATCH] add-zle-hook-widget zle-line-pre-redraw issue
From: Daniel Shahaf <[email-masked]>
To: [email-masked]
Date: Sat, 23 Jul 2016 21:23:35 +0000
List-Id: Zsh Workers List <zsh-workers.zsh.org>

Hooks registered with «add-zle-hook-widget zle-line-pre-redraw $hook»
aren't invoked.  In contrast, hooks registered with zle-line-finish are
invoked.

The reason appears to be that, while in azhw:zle-line-init $WIDGET is
"zle-line-init", in azhw:zle-line-pre-redraw $WIDGET is the name of the
widget the user invoked (e.g., "self-insert"), so the 'zstyle -a' does
not find the registered hooks.

Each of the following alternative patches solves the issue:

First option:
[[[
diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c
index ac31d4e..9f2742a 100644
--- a/Src/Zle/zle_main.c
+++ b/Src/Zle/zle_main.c
@@ -1054,7 +1055,7 @@ void redrawhook(void)
 	args[0] = initthingy->nam;
 	args[1] = NULL;
 	incompfunc = 0;
-	execzlefunc(initthingy, args, 0);
+	execzlefunc(initthingy, args, 1);
 	incompfunc = old_incompfunc;
 	unrefthingy(initthingy);
 	unrefthingy(lbindk);
]]]

Second option:
[[[
diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c
index ac31d4e..90e54d6 100644
--- a/Src/Zle/zle_main.c
+++ b/Src/Zle/zle_main.c
@@ -1044,6 +1044,10 @@ getrestchar(int inchar, char *outstr, int *outcount)
 void redrawhook(void)
 {
     Thingy initthingy;
+
+    zlecallhook("zle-line-pre-redraw", NULL);
+    return;
+
     if ((initthingy = rthingy_nocreate("zle-line-pre-redraw"))) {
 	int lastcmd_prev = lastcmd;
 	int old_incompfunc = incompfunc;
]]]

The principal differences seem to be which set of globals is
saved/restored or changed/restored; however, which set it should be is
all Greek to me.

Cheers,

Daniel
(I haven't tested the other hook types.)