From: Zefram <zefram@dcs.warwick.ac.uk>
To: zsh-workers@math.gatech.edu (Z Shell workers mailing list)
Subject: history search bug{,fix}
Date: Sat, 4 Jan 1997 19:51:48 +0000 (GMT) [thread overview]
Message-ID: <3851.199701041951@stone.dcs.warwick.ac.uk> (raw)
-----BEGIN PGP SIGNED MESSAGE-----
There is a bug is history-search-{for,back}ward. If the previous
command executed was one of history-beginning-serach-{for,back}ward or
{up,down}-line-or-search, it assumes that it already knows the extent of
the word it is supposed to search for, which it doesn't. The solution is
to ignore the previous command, and look at the actual first word anyway.
As this was the only thing the ZLE_HISTSEACH flag was used for, that
can be removed.
-zefram
*** Src/Zle/zle.h 1997/01/03 07:23:25 1.8
--- Src/Zle/zle.h 1997/01/04 08:39:45
***************
*** 62,68 ****
#define ZLE_LINEMOVE (1<<4)
#define ZLE_ARG (1<<5)
#define ZLE_KILL (1<<6)
- #define ZLE_HISTSEARCH (1<<7)
#define ZLE_NEGARG (1<<8)
#define ZLE_INSERT (1<<9)
#define ZLE_DELETE (1<<10)
--- 62,67 ----
*** Src/Zle/zle_bindings.c 1997/01/03 07:23:25 1.4
--- Src/Zle/zle_bindings.c 1997/01/04 08:43:38
***************
*** 72,78 ****
C("down-case-word", downcaseword, 0)
C("down-history", downhistory, 0)
C("down-line-or-history", downlineorhistory, ZLE_MOVEMENT | ZLE_LINEMOVE)
! C("down-line-or-search", downlineorsearch, ZLE_MOVEMENT | ZLE_LINEMOVE | ZLE_HISTSEARCH)
C("emacs-backward-word", emacsbackwardword, ZLE_MOVEMENT)
C("emacs-forward-word", emacsforwardword, ZLE_MOVEMENT)
C("end-of-buffer-or-history", endofbufferorhistory, ZLE_MOVEMENT)
--- 72,78 ----
C("down-case-word", downcaseword, 0)
C("down-history", downhistory, 0)
C("down-line-or-history", downlineorhistory, ZLE_MOVEMENT | ZLE_LINEMOVE)
! C("down-line-or-search", downlineorsearch, ZLE_MOVEMENT | ZLE_LINEMOVE)
C("emacs-backward-word", emacsbackwardword, ZLE_MOVEMENT)
C("emacs-forward-word", emacsforwardword, ZLE_MOVEMENT)
C("end-of-buffer-or-history", endofbufferorhistory, ZLE_MOVEMENT)
***************
*** 91,102 ****
C("forward-word", forwardword, ZLE_MOVEMENT)
C("get-line", getline, 0)
C("gosmacs-transpose-chars", gosmacstransposechars, 0)
! C("history-beginning-search-backward", historybeginningsearchbackward, ZLE_HISTSEARCH)
! C("history-beginning-search-forward", historybeginningsearchforward, ZLE_HISTSEARCH)
C("history-incremental-search-backward", historyincrementalsearchbackward, 0)
C("history-incremental-search-forward", historyincrementalsearchforward, 0)
! C("history-search-backward", historysearchbackward, ZLE_HISTSEARCH)
! C("history-search-forward", historysearchforward, ZLE_HISTSEARCH)
C("infer-next-history", infernexthistory, 0)
C("insert-last-word", insertlastword, ZLE_INSERT)
C("kill-buffer", killbuffer, ZLE_KILL)
--- 91,102 ----
C("forward-word", forwardword, ZLE_MOVEMENT)
C("get-line", getline, 0)
C("gosmacs-transpose-chars", gosmacstransposechars, 0)
! C("history-beginning-search-backward", historybeginningsearchbackward, 0)
! C("history-beginning-search-forward", historybeginningsearchforward, 0)
C("history-incremental-search-backward", historyincrementalsearchbackward, 0)
C("history-incremental-search-forward", historyincrementalsearchforward, 0)
! C("history-search-backward", historysearchbackward, 0)
! C("history-search-forward", historysearchforward, 0)
C("infer-next-history", infernexthistory, 0)
C("insert-last-word", insertlastword, ZLE_INSERT)
C("kill-buffer", killbuffer, ZLE_KILL)
***************
*** 134,140 ****
C("up-case-word", upcaseword, 0)
C("up-history", uphistory, 0)
C("up-line-or-history", uplineorhistory, ZLE_LINEMOVE | ZLE_MOVEMENT)
! C("up-line-or-search", uplineorsearch, ZLE_MOVEMENT | ZLE_LINEMOVE | ZLE_HISTSEARCH)
C("vi-add-eol", viaddeol, 0)
C("vi-add-next", viaddnext, 0)
C("vi-backward-blank-word", vibackwardblankword, ZLE_MOVEMENT)
--- 134,140 ----
C("up-case-word", upcaseword, 0)
C("up-history", uphistory, 0)
C("up-line-or-history", uplineorhistory, ZLE_LINEMOVE | ZLE_MOVEMENT)
! C("up-line-or-search", uplineorsearch, ZLE_MOVEMENT | ZLE_LINEMOVE)
C("vi-add-eol", viaddeol, 0)
C("vi-add-next", viaddnext, 0)
C("vi-backward-blank-word", vibackwardblankword, ZLE_MOVEMENT)
*** Src/Zle/zle_hist.c 1997/01/03 07:23:26 1.4
--- Src/Zle/zle_hist.c 1997/01/04 09:03:18
***************
*** 340,363 ****
setline(s);
}
- static int histpos;
-
/**/
void
historysearchbackward(void)
{
! int t0, ohistline = histline;
char *s;
remember_edits();
! if (lastcmd & ZLE_HISTSEARCH)
! t0 = histpos;
! else {
! for (t0 = 0; t0 < ll && !iblank(line[t0]); t0++);
! if (t0 < ll)
! t0++;
! histpos = t0;
! }
for (;;) {
histline--;
if (!(s = zle_get_event(histline))) {
--- 340,356 ----
setline(s);
}
/**/
void
historysearchbackward(void)
{
! int histpos, ohistline = histline;
char *s;
remember_edits();
! for (histpos = 0; histpos < ll && !iblank(line[histpos]); histpos++);
! if (histpos < ll)
! histpos++;
for (;;) {
histline--;
if (!(s = zle_get_event(histline))) {
***************
*** 365,371 ****
histline = ohistline;
return;
}
! if (metadiffer(s, (char *) line, t0) < 0 &&
metadiffer(s, (char *) line, ll))
break;
}
--- 358,364 ----
histline = ohistline;
return;
}
! if (metadiffer(s, (char *) line, histpos) < 0 &&
metadiffer(s, (char *) line, ll))
break;
}
***************
*** 376,393 ****
void
historysearchforward(void)
{
! int t0, ohistline = histline;
char *s;
remember_edits();
! if (lastcmd & ZLE_HISTSEARCH)
! t0 = histpos;
! else {
! for (t0 = 0; t0 < ll && !iblank(line[t0]); t0++);
! if (t0 < ll)
! t0++;
! histpos = t0;
! }
for (;;) {
histline++;
if (!(s = zle_get_event(histline))) {
--- 369,381 ----
void
historysearchforward(void)
{
! int histpos, ohistline = histline;
char *s;
remember_edits();
! for (histpos = 0; histpos < ll && !iblank(line[histpos]); histpos++);
! if (histpos < ll)
! histpos++;
for (;;) {
histline++;
if (!(s = zle_get_event(histline))) {
***************
*** 395,401 ****
histline = ohistline;
return;
}
! if (metadiffer(s, (char *) line, t0) < (histline == curhist) &&
metadiffer(s, (char *) line, ll))
break;
}
--- 383,389 ----
histline = ohistline;
return;
}
! if (metadiffer(s, (char *) line, histpos) < (histline == curhist) &&
metadiffer(s, (char *) line, ll))
break;
}
-----BEGIN PGP SIGNATURE-----
Version: 2.6.2
iQCVAwUBMs4fCHD/+HJTpU/hAQH3UQP+JHvA3F5SmV16Y4wWqpv1WBgRsAf3G2qf
x2nOC9+uqEtE8iMtSisuV4AZH08UjCp01NqGVtE5iwS+6CW7l6/yxA23FyN/VrBv
3E1xs0i9yI+kLqPL9e631RhskAI40rEyZsXcVQEeFirccz59FsPhN46SBdHAbwEY
rYuo/ngsREo=
=tFCb
-----END PGP SIGNATURE-----
next reply other threads:[~1997-01-04 19:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-01-04 19:51 Zefram [this message]
1997-01-04 23:34 ` Wayne Davison
1997-01-04 23:47 ` Zefram
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=3851.199701041951@stone.dcs.warwick.ac.uk \
--to=zefram@dcs.warwick.ac.uk \
--cc=zsh-workers@math.gatech.edu \
/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).