zsh-workers
 help / color / mirror / code / Atom feed
* Add a hook on isearch
@ 2010-09-18 16:50 Mikael Magnusson
  2010-09-18 20:00 ` Bart Schaefer
  2010-09-23  9:40 ` Peter Stephenson
  0 siblings, 2 replies; 5+ messages in thread
From: Mikael Magnusson @ 2010-09-18 16:50 UTC (permalink / raw)
  To: zsh workers

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@gmail.com>
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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-09-23 10:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-18 16:50 Add a hook on isearch Mikael Magnusson
2010-09-18 20:00 ` Bart Schaefer
2010-09-19 14:54   ` Mikael Magnusson
2010-09-20  9:02   ` Peter Stephenson
2010-09-23  9:40 ` Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).