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-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham
	autolearn_force=no version=3.4.0
Date: Wed, 13 Jan 2016 00:57:44 +0000
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: Mikael Magnusson <mikachu@gmail.com>
Cc: m0viefreak <m0viefreak.cm@googlemail.com>,
	Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: PATCH: Add zle-line-pre-redraw hook for highlighting
Message-ID: <20160113005744.GA32206@tarsus.local2>
References: <CAHYJk3QvRnYxLMb8XsoWB1hU92Qti_fEKt1JgxkyDARrhf1g7g@mail.gmail.com>
 <1450245754-2760-1-git-send-email-mikachu@gmail.com>
 <CAH+w=7btpFWXkgHFjHwMFWZcrVu-ap5+=PAkeidze8NJsz+SoA@mail.gmail.com>
 <20151219094913.GF2358@tarsus.local2>
 <5692D87E.20304@googlemail.com>
 <CAHYJk3SWaSvRTCbQGS5iN60JBx4Z49Emfc6dewLrxQ0w_5xrDg@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <CAHYJk3SWaSvRTCbQGS5iN60JBx4Z49Emfc6dewLrxQ0w_5xrDg@mail.gmail.com>
User-Agent: Mutt/1.5.23 (2014-03-12)
X-Seq: zsh-workers 37590

Mikael Magnusson wrote on Mon, Jan 11, 2016 at 16:26:22 +0100:
> On Sun, Jan 10, 2016 at 11:17 PM, m0viefreak
> <m0viefreak.cm@googlemail.com> wrote:
> >
> >
> > On 19.12.2015 10:49, Daniel Shahaf wrote:
> >> Bart Schaefer wrote on Wed, Dec 16, 2015 at 00:05:01 -0800:
> >>> On Dec 15, 2015 10:27 PM, "Mikael Magnusson" <mikachu@gmail.com> wrote:
> >>>> I haven't received any complaints about 36650 from testers, so I'll go ahead
> >>>> and push this.
> >>
> >> Hooray!
> >>
> >> This should fix between 2 and 5 z-sy-h issues:
> >> https://github.com/zsh-users/zsh-syntax-highlighting/issues/245
> >
> > One remaining issue with this approach is the fact that this new hook is
> > not triggered when a minibuffer such as isearch is active and BUFFER
> > changes.
> >
> > Is it possible to add support for that, too?
> >
> > I don't know the zle internals very well, and I couldn't figure out the
> > right spot to place a call to the hook without causing performance
> > issues due to multiple (useless) calls.
> 
> You can probably add your redraw hook at the end of your
> zle-isearch-update and zle-isearch-exit hooks (not sure if both are
> needed). If you don't use them already, just point them directly at
> your redraw hook function.

Like the enclosed patch, then?  I'd use this in z-sy-h, and in that
context I can't ask every user to change their zle-isearch-update hook,
and there's no equivalent of $chpwd_functions for that hook either.

I've tested this patch from (an experimental branch of) z-sy-h and it
seems to work fine: highlighting is now applied during isearch.  (The
underline 'isearch' highlighting was not applied to the fg=green parts
of the command-line, but that's a separate issue.)

Cheers,

Daniel

diff --git a/Src/Zle/zle_hist.c b/Src/Zle/zle_hist.c
index 95d96c9..abd6e17 100644
--- a/Src/Zle/zle_hist.c
+++ b/Src/Zle/zle_hist.c
@@ -1480,6 +1480,7 @@ doisearch(char **args, int dir, int pattern)
 	    isearch_active = 0;
     ref:
 	zlecallhook("zle-isearch-update", NULL);
+	redrawhook();
 	zrefresh();
 	if (!(cmd = getkeycmd()) || cmd == Th(z_sendbreak)) {
 	    int i;
@@ -1694,6 +1695,7 @@ doisearch(char **args, int dir, int pattern)
     statusline = NULL;
     unmetafy_line();
     zlecallhook("zle-isearch-exit", NULL);
+    redrawhook();
     if (exitfn)
 	exitfn(zlenoargs);
     selectkeymap(okeymap, 1);
diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c
index 7862d48..6e2bfde 100644
--- a/Src/Zle/zle_main.c
+++ b/Src/Zle/zle_main.c
@@ -1025,7 +1025,8 @@ getrestchar(int inchar, char *outstr, int *outcount)
 /**/
 #endif
 
-static void redrawhook()
+/**/
+void redrawhook(void)
 {
     Thingy initthingy;
     if ((initthingy = rthingy_nocreate("zle-line-pre-redraw"))) {

