From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28610 invoked from network); 19 Jan 2009 12:20:58 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 19 Jan 2009 12:20:58 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 48670 invoked from network); 19 Jan 2009 12:20:51 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 19 Jan 2009 12:20:51 -0000 Received: (qmail 28949 invoked by alias); 19 Jan 2009 12:20:45 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 26366 Received: (qmail 28940 invoked from network); 19 Jan 2009 12:20:45 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 19 Jan 2009 12:20:45 -0000 Received: from cluster-g.mailcontrol.com (cluster-g.mailcontrol.com [208.87.233.190]) by bifrost.dotsrc.org (Postfix) with ESMTPS id 22153802720F for ; Mon, 19 Jan 2009 13:20:41 +0100 (CET) Received: from cameurexb01.EUROPE.ROOT.PRI ([193.128.72.68]) by rly30g.srv.mailcontrol.com (MailControl) with ESMTP id n0JCKEaM001296 for ; Mon, 19 Jan 2009 12:20:39 GMT Received: from news01 ([10.103.143.38]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.3959); Mon, 19 Jan 2009 12:12:10 +0000 Date: Mon, 19 Jan 2009 12:12:04 +0000 From: Peter Stephenson To: zsh-workers@sunsite.dk Subject: Re: changing bindings in isearch mode? Message-ID: <20090119121204.4697b6a2@news01> In-Reply-To: <20090119094453.4f66076b@news01> References: <18801.32959.693653.15539@gargle.gargle.HOWL> <20090117175659.1a37c70f@pws-pc> <20090119094453.4f66076b@news01> Organization: CSR X-Mailer: Claws Mail 3.5.0 (GTK+ 2.12.8; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 19 Jan 2009 12:12:10.0251 (UTC) FILETIME=[278F15B0:01C97A2F] X-Scanned-By: MailControl A_08_51_00 (www.mailcontrol.com) on 10.71.0.140 X-Virus-Scanned: ClamAV 0.92.1/8877/Mon Jan 19 11:18:35 2009 on bifrost X-Virus-Status: Clean On Mon, 19 Jan 2009 09:44:53 +0000 Peter Stephenson wrote: > On Sat, 17 Jan 2009 13:23:53 -0500 > Greg Klanderman wrote: > > Just glancing over the code, it would appear not too hard to create a > > keymap for isearch, add an isearch-exit widget, and add a case for it > > in doisearch. Does that seem like a reasonable solution? > > Yes, it looks like you're right. I was indeed thinking about this over the weekend and why no one had done it before. It really does look like it's that simple; this is quite a lot of oomph for a small patch. I've added the "isearch" keymap and the "accept-search" thingy: there's no corresponding widget, it's tested for directly in isearch mode. The name "accept-search" exercised me a bit. I called the latter that (rather than something with "i" or "incremental") because the search method in use is logically irrelevant, even if for now it's only useful in isearch mode, just as there isn't any point in having "accept-emacs-line" or "accept-vi-line" if you're in emacs or vi mode. (You could bind it for use in your own search mode, for example.) I kept the word "search" even if logically it should be something like "result" to avoid ambiguity with what you're accepting. I thought about "exit-search", but "accept-" is already used to mean "keep the value you've just arrived at and return to higher level processing", so it seemed a natural extension and made it clear that you were keeping the result. Index: Doc/Zsh/zle.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/zle.yo,v retrieving revision 1.75 diff -u -r1.75 zle.yo --- Doc/Zsh/zle.yo 9 Dec 2008 17:37:01 -0000 1.75 +++ Doc/Zsh/zle.yo 19 Jan 2009 11:58:07 -0000 @@ -60,12 +60,13 @@ findex(bindkey, use of) tt(bindkey) can be used to manipulate keymap names. -Initially, there are four keymaps: +Initially, there are five keymaps: startsitem() sitem(tt(emacs))(EMACS emulation) sitem(tt(viins))(vi emulation - insert mode) sitem(tt(vicmd))(vi emulation - command mode) +sitem(tt(isearch))(incremental search mode) sitem(tt(.safe))(fallback keymap) endsitem() @@ -76,7 +77,7 @@ vindex(VISUAL) vindex(EDITOR) -In addition to these four names, either `tt(emacs)' or `tt(viins)' is +In addition to these names, either `tt(emacs)' or `tt(viins)' is also linked to the name `tt(main)'. If one of the tt(VISUAL) or tt(EDITOR) environment variables contain the string `tt(vi)' when the shell starts up then it will be `tt(viins)', otherwise it will be `tt(emacs)'. @@ -1115,7 +1116,10 @@ search to the beginning of the line. A restricted set of editing functions -is available in the mini-buffer. An interrupt signal, as defined by the stty +is available in the mini-buffer. Keys are looked up in the special +tt(isearch) keymap, and if not found there in the main keymap (note +that by default the tt(isearch) keymap is empty). +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: @@ -1133,6 +1137,11 @@ repeated this does not immediately erase a character in the minibuffer. ) +item(tt(accept-search))( +Exit incremental search, retaining the command line but performing no +further action. Note that this function is not bound by default +and has no effect outside incremental search. +) xitem(tt(backward-delete-word)) xitem(tt(backward-kill-word)) item(tt(vi-backward-kill-word))( Index: Src/Zle/iwidgets.list =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/iwidgets.list,v retrieving revision 1.11 diff -u -r1.11 iwidgets.list --- Src/Zle/iwidgets.list 26 Apr 2008 19:51:09 -0000 1.11 +++ Src/Zle/iwidgets.list 19 Jan 2009 11:58:07 -0000 @@ -13,6 +13,7 @@ "accept-and-menu-complete", acceptandmenucomplete, ZLE_MENUCMP | ZLE_KEEPSUFFIX "accept-line", acceptline, 0 "accept-line-and-down-history", acceptlineanddownhistory, 0 +"accept-search", NULL, 0 "argument-base", argumentbase, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_LASTCOL | ZLE_NOTCOMMAND "auto-suffix-remove", handlesuffix, ZLE_NOTCOMMAND "auto-suffix-retain", handlesuffix, ZLE_KEEPSUFFIX | ZLE_NOTCOMMAND Index: Src/Zle/zle_hist.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_hist.c,v retrieving revision 1.59 diff -u -r1.59 zle_hist.c --- Src/Zle/zle_hist.c 30 Oct 2008 01:47:32 -0000 1.59 +++ Src/Zle/zle_hist.c 19 Jan 2009 11:58:07 -0000 @@ -49,6 +49,10 @@ /**/ int previous_search_len = 0; +/* Local keymap in isearch mode */ + +/**/ +Keymap isearch_keymap; /*** History text manipulation utilities ***/ @@ -1141,6 +1145,8 @@ if (!(he = quietgethist(hl))) return; + selectlocalmap(isearch_keymap); + clearlist = 1; if (*args) { @@ -1572,6 +1578,8 @@ feep = 1; else goto ins; + } else if (cmd == Th(z_acceptsearch)) { + break; } else { if(cmd == Th(z_selfinsertunmeta)) { fixunmeta(); @@ -1640,6 +1648,8 @@ */ if (savekeys >= 0 && kungetct > savekeys) kungetct = savekeys; + + selectlocalmap(NULL); } static Histent Index: Src/Zle/zle_keymap.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_keymap.c,v retrieving revision 1.30 diff -u -r1.30 zle_keymap.c --- Src/Zle/zle_keymap.c 11 Nov 2008 22:40:17 -0000 1.30 +++ Src/Zle/zle_keymap.c 19 Jan 2009 11:58:07 -0000 @@ -1176,6 +1176,8 @@ char buf[3], *ed; int i; + isearch_keymap = newkeymap(NULL, "isearch"); + /* vi insert mode and emacs mode: * * 0-31 taken from the tables * * 32-126 self-insert * @@ -1274,6 +1276,8 @@ else linkkeymap(emap, "main", 0); + linkkeymap(isearch_keymap, "isearch", 0); + /* the .safe map cannot be modified or deleted */ smap->flags |= KM_IMMUTABLE; } -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070