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

Add a hook on isearch



This might make something explode, but it's probably pretty useful.

function _show_surroundings() {
  typeset -a output
  typeset -A star
  star[$HISTNO]="*"
  for ((i = HISTNO - ${NUMERIC:-5}; i < HISTNO + ${NUMERIC:-5} && i <
HISTCMD; i++)); do
    output=( "$star[$i]$i: $history[$i]" $output )
  done
  zle -M ${(pj:\n:)output}
}
zle -N zle-isearch-update _show_surroundings

% edit .zshrc
bck-i-search: edit .zshrc_
2293: src
*2292: edit .zshrc
2291: zle-isearch-update() { zle _show_surroundings }
2290: zle-isearch-update() { zle -M $HISTNO }
2289: zle-isearch-update() { zle -M lol }
2288: zle -N zle-isearch-update
2287: echo $history[HISTCMD]

commit 8ab10e2394da712db896662316fb4df304c212ef
Author: Mikael Magnusson <mikachu@xxxxxxxxx>
Date:   Sat Sep 18 18:46:38 2010 +0200

    Add zle-isearch-update

diff --git a/Src/Zle/zle_hist.c b/Src/Zle/zle_hist.c
index d9586b8..1daf8e1 100644
--- a/Src/Zle/zle_hist.c
+++ b/Src/Zle/zle_hist.c
@@ -1472,7 +1472,16 @@ doisearch(char **args, int dir, int pattern)
 	} else
 	    isearch_active = 0;
     ref:
+        if ((cmd = rthingy_nocreate("zle-isearch-update"))) {
+           char *args[2];
+           args[0] = cmd->nam;
+           args[1] = NULL;
+           execzlefunc(cmd, args, 1);
+           unrefthingy(cmd);
+        }
+
 	zrefresh();
+
 	if (!(cmd = getkeycmd()) || cmd == Th(z_sendbreak)) {
 	    int i;
 	    aborted = 1;


-- 
Mikael Magnusson



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