Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Add a hook on isearch



On Sat, 18 Sep 2010 18:50:42 +0200
Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> commit 8ab10e2394da712db896662316fb4df304c212ef
> Author: Mikael Magnusson <mikachu@xxxxxxxxx>
> Date:   Sat Sep 18 18:46:38 2010 +0200
> 
>     Add zle-isearch-update

I tried this and it seemed to work...  There may be things you shouldn't be
doing at that point but I'm not sure what they are.

The exit hook needed to be after setting statusline to NULL.  Apart from
that, I'm not sure what the best place is.

Index: Doc/Zsh/zle.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/zle.yo,v
retrieving revision 1.88
diff -p -u -r1.88 zle.yo
--- Doc/Zsh/zle.yo	8 Sep 2010 12:32:32 -0000	1.88
+++ Doc/Zsh/zle.yo	23 Sep 2010 09:32:30 -0000
@@ -887,6 +887,28 @@ If they do not exist, no special action 
 provided is identical to that for any other editing widget.
 
 startitem()
+tindex(zle-isearch-exit)
+item(tt(zle-isearch-exit))(
+Executed at the end of incremental search at the point where the isearch
+prompt is removed from the display.  See tt(zle-isearch-update) for
+an example.
+)
+tindex(zle-isearch-update)
+item(tt(zle-isearch-update))(
+Executed within incremental search when the display is about to be
+redrawn.  Additional output below the incremental search prompt can be
+generated by using `tt(zle -M)' within the widget.  For example,
+
+example(zle-isearch-update+LPAR()RPAR() { zle -M "Line $HISTNO"; }
+zle -N zle-isearch-update)
+
+Note the line output by `tt(zle -M)' is not deleted on exit from
+incremental search.  This can be done from a tt(zle-isearch-exit)
+widget:
+
+example(zle-isearch-exit+LPAR()RPAR() { zle -M ""; }
+zle -N zle-isearch-exit)
+)
 tindex(zle-line-init)
 item(tt(zle-line-init))(
 Executed every time the line editor is started to read a new line
Index: Src/Zle/zle_hist.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_hist.c,v
retrieving revision 1.65
diff -p -u -r1.65 zle_hist.c
--- Src/Zle/zle_hist.c	27 Apr 2010 08:58:35 -0000	1.65
+++ Src/Zle/zle_hist.c	23 Sep 2010 09:32:31 -0000
@@ -1472,6 +1472,7 @@ doisearch(char **args, int dir, int patt
 	} else
 	    isearch_active = 0;
     ref:
+	zlecallhook("zle-isearch-update", NULL);
 	zrefresh();
 	if (!(cmd = getkeycmd()) || cmd == Th(z_sendbreak)) {
 	    int i;
@@ -1670,6 +1671,7 @@ doisearch(char **args, int dir, int patt
     }
     statusline = NULL;
     unmetafy_line();
+    zlecallhook("zle-isearch-exit", NULL);
     if (exitfn)
 	exitfn(zlenoargs);
     selectkeymap(okeymap, 1);

-- 
Peter Stephenson <pws@xxxxxxx>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom



Messages sorted by: Reverse Date, Date, Thread, Author