Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
X-Qmail-Scanner-Diagnostics: from hermes.apache.org by f.primenet.com.au (envelope-from <danielsh@apache.org>, uid 7791) with qmail-scanner-2.11 
 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1.  
 Clear:RC:0(140.211.11.3):SA:0(-1.3/5.0):. 
 Processed in 0.1806 secs); 23 Jul 2016 21:23:50 -0000
X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au
X-Spam-Level: 
X-Spam-Status: No, score=-1.3 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS,
	RP_MATCHES_RCVD autolearn=unavailable autolearn_force=no version=3.4.1
X-Envelope-From: danielsh@apache.org
X-Qmail-Scanner-Mime-Attachments: |
X-Qmail-Scanner-Zip-Files: |
Received-SPF: none (ns1.primenet.com.au: domain at apache.org does not designate permitted sender hosts)
Date: Sat, 23 Jul 2016 21:23:35 +0000
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: zsh-workers@zsh.org
Subject: [PATCH] add-zle-hook-widget zle-line-pre-redraw issue
Message-ID: <20160723212335.GA20872@tarsus.local2>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
User-Agent: Mutt/1.5.23 (2014-03-12)
X-Seq: zsh-workers 38927

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.)

