From: Mikael Magnusson <mikachu@gmail.com>
To: zsh workers <zsh-workers@zsh.org>
Subject: Add a hook on isearch
Date: Sat, 18 Sep 2010 18:50:42 +0200 [thread overview]
Message-ID: <AANLkTinEDT7WjY3JFUuMXiN7mHLCYo5OJfsgs2jGW1Sd@mail.gmail.com> (raw)
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
next reply other threads:[~2010-09-18 16:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-18 16:50 Mikael Magnusson [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AANLkTinEDT7WjY3JFUuMXiN7mHLCYo5OJfsgs2jGW1Sd@mail.gmail.com \
--to=mikachu@gmail.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).