From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4124 invoked from network); 11 May 2008 18:32:55 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.4 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 11 May 2008 18:32:55 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 37770 invoked from network); 11 May 2008 18:32:51 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 11 May 2008 18:32:51 -0000 Received: (qmail 3374 invoked by alias); 11 May 2008 18:32:48 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 24994 Received: (qmail 3361 invoked from network); 11 May 2008 18:32:47 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 11 May 2008 18:32:47 -0000 Received: from mtaout01-winn.ispmail.ntl.com (mtaout01-winn.ispmail.ntl.com [81.103.221.47]) by bifrost.dotsrc.org (Postfix) with ESMTP id 0F6BB80ED172 for ; Sun, 11 May 2008 20:32:42 +0200 (CEST) Received: from aamtaout03-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout01-winn.ispmail.ntl.com with ESMTP id <20080511183616.MXRU14647.mtaout01-winn.ispmail.ntl.com@aamtaout03-winn.ispmail.ntl.com> for ; Sun, 11 May 2008 19:36:16 +0100 Received: from pws-pc ([81.107.40.67]) by aamtaout03-winn.ispmail.ntl.com with ESMTP id <20080511184033.GDKT26699.aamtaout03-winn.ispmail.ntl.com@pws-pc> for ; Sun, 11 May 2008 19:40:33 +0100 Date: Sun, 11 May 2008 19:31:45 +0100 From: Peter Stephenson To: zsh-workers Subject: Re: down-line-or-search doesn't go to last entry Message-ID: <20080511193145.29b04a6e@pws-pc> In-Reply-To: <237967ef0805110723g53c9f63ct7e11d33d7daf8c64@mail.gmail.com> References: <237967ef0805110723g53c9f63ct7e11d33d7daf8c64@mail.gmail.com> X-Mailer: Claws Mail 3.3.1 (GTK+ 2.12.5; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV 0.91.2/7090/Sun May 11 20:03:45 2008 on bifrost X-Virus-Status: Clean On Sun, 11 May 2008 16:23:54 +0200 "Mikael Magnusson" wrote: > I have {up,down}-line-or-search bound to Up/Down, and I noticed > recently that down-line-or-search won't go to the empty entry anymore. > Ie if you press up and then down, it will still have the previous > entry in the cmdline, I have to press page down where I have > down-history to get back to the empty line. I have been annoying myself silly with this over yet another two hours of my life that will never come again. There is one bug in zlinecmp() that I've recently introduced. However, I don't think that's the main problem, which is the second test for whether a search line is acceptable. In recent versions of the shell, the test has been looking to ensure the search text *differs* from the line you're trying it against, which obviously doesn't make sense. It was already doing something such in 4.2. This is complicated by the fact that until I changed it to using metafied strings the comparisons were being done in interesting ways which have changed subtly over the shell's history (though I haven't gone back before 4.2). The upshot seems to be the test previously fortuitously failed due to the fact that it was being passed the length of the current editing line, not the length of the search string. I am guessing that the real point of this second test is to compare if the line is different from the one you've just left, and hence it shouldn't involve the search string at all, just the line you're leaving and the line you're trying. Those more energetic may wish, as an exercise, to compare with the archive. Let's see how this works. Index: Src/Zle/zle_hist.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_hist.c,v retrieving revision 1.56 diff -u -r1.56 zle_hist.c --- Src/Zle/zle_hist.c 5 May 2008 01:14:06 -0000 1.56 +++ Src/Zle/zle_hist.c 11 May 2008 18:13:17 -0000 @@ -111,7 +111,7 @@ mbstate_t hstate, istate; #endif - while (*hptr == *iptr) { + while (*iptr && *hptr == *iptr) { hptr++; iptr++; } @@ -470,13 +470,15 @@ if (!(he = quietgethist(histline))) return 1; + metafy_line(); while ((he = movehistent(he, -1, hist_skip_flags))) { if (isset(HISTFINDNODUPS) && he->node.flags & HIST_DUP) continue; zt = GETZLETEXT(he); if (zlinecmp(zt, str) < 0 && - (*args || strcmp(zt, str) != 0)) { + (*args || strcmp(zt, zlemetaline) != 0)) { if (--n <= 0) { + unmetafy_line(); zle_setline(he); srch_hl = histline; srch_cs = zlecs; @@ -484,6 +486,7 @@ } } } + unmetafy_line(); return 1; } @@ -524,13 +527,15 @@ if (!(he = quietgethist(histline))) return 1; + metafy_line(); while ((he = movehistent(he, 1, hist_skip_flags))) { if (isset(HISTFINDNODUPS) && he->node.flags & HIST_DUP) continue; zt = GETZLETEXT(he); if (zlinecmp(zt, str) < (he->histnum == curhist) && - (*args || strcmp(zt, str) != 0)) { + (*args || strcmp(zt, zlemetaline) != 0)) { if (--n <= 0) { + unmetafy_line(); zle_setline(he); srch_hl = histline; srch_cs = zlecs; @@ -538,6 +543,7 @@ } } } + unmetafy_line(); return 1; } -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/