From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16872 invoked from network); 4 Jan 1997 19:45:35 -0000 Received: from euclid.skiles.gatech.edu (list@130.207.146.50) by coral.primenet.com.au with SMTP; 4 Jan 1997 19:45:35 -0000 Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id OAA07102; Sat, 4 Jan 1997 14:50:38 -0500 (EST) Resent-Date: Sat, 4 Jan 1997 14:50:38 -0500 (EST) From: Zefram Message-Id: <3851.199701041951@stone.dcs.warwick.ac.uk> Subject: history search bug{,fix} To: zsh-workers@math.gatech.edu (Z Shell workers mailing list) Date: Sat, 4 Jan 1997 19:51:48 +0000 (GMT) X-Patch: 183 X-Loop: zefram@dcs.warwick.ac.uk X-Stardate: [-31]8679.13 X-US-Congress: Moronic fuckers Content-Type: text Resent-Message-ID: <"aZJFe.0.vk1.EIhpo"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/2721 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu -----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-----