From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3630 invoked from network); 1 May 2008 11:30:15 -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.4 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; 1 May 2008 11:30:15 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 46422 invoked from network); 1 May 2008 11:30:09 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 1 May 2008 11:30:09 -0000 Received: (qmail 4537 invoked by alias); 1 May 2008 11:30:07 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 24900 Received: (qmail 4520 invoked from network); 1 May 2008 11:30:06 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 1 May 2008 11:30:06 -0000 Received: from cluster-d.mailcontrol.com (cluster-d.mailcontrol.com [217.69.20.190]) by bifrost.dotsrc.org (Postfix) with ESMTP id 32AD480ED172 for ; Thu, 1 May 2008 13:30:02 +0200 (CEST) Received: from cameurexb01.EUROPE.ROOT.PRI ([62.189.241.200]) by rly48d.srv.mailcontrol.com (MailControl) with ESMTP id m41BTxDY013029 for ; Thu, 1 May 2008 12:30:00 +0100 Received: from news01 ([10.103.143.38]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.3959); Thu, 1 May 2008 12:29:54 +0100 Date: Thu, 1 May 2008 12:29:54 +0100 From: Peter Stephenson To: zsh-workers Subject: Re: oddity with history-incremental-{,pattern-}search-backward Message-ID: <20080501122954.6f4c487f@news01> In-Reply-To: <237967ef0804301442t22e78955y35ae367d82d3e338@mail.gmail.com> References: <237967ef0804301442t22e78955y35ae367d82d3e338@mail.gmail.com> Organization: CSR X-Mailer: Claws Mail 3.3.1 (GTK+ 2.12.5; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 01 May 2008 11:29:54.0643 (UTC) FILETIME=[AD93C230:01C8AB7E] X-Scanned-By: MailControl A-08-00-04 (www.mailcontrol.com) on 10.68.0.158 X-Virus-Scanned: ClamAV 0.91.2/7006/Thu May 1 12:01:28 2008 on bifrost X-Virus-Status: Clean On Wed, 30 Apr 2008 23:42:40 +0200 "Mikael Magnusson" wrote: > With the new pattern isearch thingy, if i search for whatever and > press ctrl-r a couple of times, it finds older items as it should, but > when i press backspace, it seems to somehow erase the ^r going forward > in history again. I would expect it to just delete the character right > away... It's very easy to add a way of doing this, using the backward delete/kill word widgets (the mnemonic is obvious: they repeatedly have the effect of backward delete character). Much of the code change is reindentation. I've also documented the commands in isearch better, rather than just saying "yeah, this does stuff, too". Index: Doc/Zsh/zle.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/zle.yo,v retrieving revision 1.67 diff -u -r1.67 zle.yo --- Doc/Zsh/zle.yo 1 May 2008 10:58:24 -0000 1.67 +++ Doc/Zsh/zle.yo 1 May 2008 11:24:28 -0000 @@ -1106,32 +1106,65 @@ is available in the mini-buffer. An interrupt signal, as defined by the stty setting, will stop the search and go back to the original line. An undefined key will have the same effect. The supported functions are: -tt(backward-delete-char), -tt(vi-backward-delete-char), -tt(clear-screen), -tt(redisplay), -tt(quoted-insert), -tt(vi-quoted-insert), -tt(accept-and-hold), -tt(accept-and-infer-next-history), -tt(accept-line) and -tt(accept-line-and-down-history). -tt(magic-space) just inserts a space. -tt(vi-cmd-mode) toggles between the `tt(main)' and `tt(vicmd)' keymaps; +startitem() +xitem(tt(accept-and-hold)) +xitem(tt(accept-and-infer-next-history)) +xitem(tt(accept-line)) +item(tt(accept-line-and-down-history))( +Perform the usual function after exiting incremental search. +The command line displayed is executed. +) +xitem(tt(backward-delete-char)) +item(tt(vi-backward-delete-char))( +Back up one place in the search history. If the search has been +repeated this does not immediately erase a character in the +minibuffer. +) +xitem(tt(backward-delete-word)) +xitem(tt(backward-kill-word)) +item(tt(vi-backward-kill-word))( +Back up one character in the minibuffer; if multiple searches +have been performed since the character was inserted the search +history is rewound to the point just before the character was +entered. Hence this has the effect of repeating +tt(backward-delete-char). +) +item(tt(clear-screen))( +Clear the screen, remaining in incremental search mode. +) +item(tt(history-incremental-search-backward))( +Find the next occurrence of the contents of the mini-buffer. +) +item(tt(history-incremental-search-forward))( +Invert the sense of the search. +) +item(tt(magic-space))( +Inserts a non-magical space. +) +xitem(tt(quoted-insert)) +item(tt(vi-quoted-insert))( +Quote the character to insert into the minibuffer. +) +item(tt(redisplay))( +Redisplay the command line, remaining in incremental search mode. +) +item(tt(vi-cmd-mode))( +Toggle between the `tt(main)' and `tt(vicmd)' keymaps; the `tt(main)' keymap (insert mode) will be selected initially. -tt(history-incremental-search-backward) will get the -next occurrence of the contents of the mini-buffer. -tt(history-incremental-search-forward) inverts the sense of the search. -tt(vi-repeat-search) and tt(vi-rev-repeat-search) are similarly supported. -The direction of the search is indicated in the mini-buffer. - -Any multi-character string -that is not bound to one of the above functions will beep and interrupt the -search, leaving the last found line in the buffer. Any single character that -is not bound to one of the above functions, or tt(self-insert) or -tt(self-insert-unmeta), will have the same effect but the function will be -executed. +) +xitem(tt(vi-repeat-search)) +item(tt(vi-rev-repeat-search))( +Repeat the search. The direction of the search is indicated in the +mini-buffer. +) +enditem() + +Any multi-character string that is not bound to one of the above functions +will beep and interrupt the search, leaving the last found line in the +buffer. Any single character that is not bound to one of the above +functions, or tt(self-insert) or tt(self-insert-unmeta), will have the same +effect but the function will be executed. When called from a widget function by the tt(zle) command, the incremental search commands can take a string argument. This will be treated as a Index: Src/Zle/zle_hist.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_hist.c,v retrieving revision 1.53 diff -u -r1.53 zle_hist.c --- Src/Zle/zle_hist.c 28 Apr 2008 15:45:43 -0000 1.53 +++ Src/Zle/zle_hist.c 1 May 2008 11:24:28 -0000 @@ -1445,26 +1445,37 @@ if(selectkeymap(invicmdmode() ? "main" : "vicmd", 0)) feep = 1; goto ref; - } else if(cmd == Th(z_vibackwarddeletechar) || - cmd == Th(z_backwarddeletechar)) { - if (top_spot) { - get_isrch_spot(--top_spot, &hl, &pos, &pat_hl, &pat_pos, - &end_pos, &zlemetacs, &sbptr, &dir, &nomatch); - patprog = NULL; - nosearch = 1; - skip_pos = 0; - } else - feep = 1; - if (nomatch) { - memcpy(ibuf, nomatch == 2 ? INVALID_TEXT : FAILING_TEXT, - BAD_TEXT_LEN); - statusline = ibuf; - skip_pos = 1; + } else if (cmd == Th(z_vibackwarddeletechar) || + cmd == Th(z_backwarddeletechar) || + cmd == Th(z_vibackwardkillword) || + cmd == Th(z_backwardkillword) || + cmd == Th(z_backwarddeleteword)) { + int only_one = (cmd == Th(z_vibackwarddeletechar) || + cmd == Th(z_backwarddeletechar)); + int old_sbptr = sbptr; + if (top_spot) { + for (;;) { + get_isrch_spot(--top_spot, &hl, &pos, &pat_hl, + &pat_pos, &end_pos, &zlemetacs, + &sbptr, &dir, &nomatch); + if (only_one || !top_spot || old_sbptr != sbptr) + break; + } + patprog = NULL; + nosearch = 1; + skip_pos = 0; + } else + feep = 1; + if (nomatch) { + memcpy(ibuf, nomatch == 2 ? INVALID_TEXT : FAILING_TEXT, + BAD_TEXT_LEN); + statusline = ibuf; + skip_pos = 1; } he = quietgethist(hl); zt = GETZLETEXT(he); /* - * Set the line for the cases where we won't go passed + * Set the line for the cases where we won't go past * the usual line-setting logic: if we're not on a match, * or if we don't have enough to search for. */ -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070