* Adding recall of previous search to isearch
@ 1996-05-16 0:56 Wayne Davison
0 siblings, 0 replies; only message in thread
From: Wayne Davison @ 1996-05-16 0:56 UTC (permalink / raw)
To: Zsh hacking and development
Here's a patch that adds the recall of the last isearch if you press
fwd/bck-isearch with an empty isearch started (i.e. the usual emacs
behaviour).
It also fixes one pretty rare bug in the backing-up line refresh. You
can see it if you start an isearch in one direction until it fails,
switch directions and find that string on some other line, and then hit
backspace.
..wayne..
---8<------8<------8<------8<---cut here--->8------>8------>8------>8---
Index: zle_hist.c
@@ -666,6 +666,8 @@
int sbptr = 0, cmd, top_spot = 0, pos, sibuf = 80;
int nomatch = 0, skip_line = 0, skip_pos = 0;
int odir = dir, *obindtab = bindtab;
+ static char *previous_search = NULL;
+ static int previous_search_len = 0;
strcpy(ibuf, ISEARCH_PROMPT);
memcpy(ibuf + NORM_PROMPT_POS, (dir == 1) ? "fwd" : "bck", 3);
@@ -770,7 +772,7 @@
skip_pos = 1;
}
s = zle_get_event(histline);
- if (!sbptr || (sbptr == 1 && sbuf[0] == '^')) {
+ if (nomatch || !sbptr || (sbptr == 1 && sbuf[0] == '^')) {
int i = cs;
setline(s);
cs = i;
@@ -813,6 +815,14 @@
dir = odir;
skip_pos = 1;
rpt:
+ if (!sbptr && previous_search_len) {
+ if (previous_search_len > sibuf - FIRST_SEARCH_CHAR - 2) {
+ ibuf = hrealloc(ibuf, sibuf, sibuf + previous_search_len);
+ sbuf = ibuf + FIRST_SEARCH_CHAR;
+ sibuf += previous_search_len;
+ }
+ memcpy(sbuf, previous_search, sbptr = previous_search_len);
+ }
memcpy(ibuf + NORM_PROMPT_POS, (dir == 1) ? "fwd" : "bck", 3);
continue;
case z_sendstring:
@@ -839,6 +849,8 @@
ungetkey(c);
else
feep();
+ if (cmd == z_sendbreak)
+ sbptr = 0;
goto brk;
}
ins:
@@ -856,6 +868,11 @@
}
}
brk:
+ if (sbptr) {
+ zsfree(previous_search);
+ previous_search = zalloc(sbptr);
+ memcpy(previous_search, sbuf, previous_search_len = sbptr);
+ }
statusline = NULL;
bindtab = obindtab;
}
---8<------8<------8<------8<---cut here--->8------>8------>8------>8---
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1996-05-16 1:22 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-05-16 0:56 Adding recall of previous search to isearch Wayne Davison
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).