From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11210 invoked from network); 23 Apr 2006 23:08:54 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.1 (2006-03-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,FORGED_RCVD_HELO autolearn=ham version=3.1.1 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 23 Apr 2006 23:08:54 -0000 Received: (qmail 54647 invoked from network); 23 Apr 2006 23:08:48 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 23 Apr 2006 23:08:48 -0000 Received: (qmail 7439 invoked by alias); 23 Apr 2006 23:08:39 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 10172 Received: (qmail 7429 invoked from network); 23 Apr 2006 23:08:38 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 23 Apr 2006 23:08:38 -0000 Received: (qmail 53470 invoked from network); 23 Apr 2006 23:08:38 -0000 Received: from mta08-winn.ispmail.ntl.com (HELO mtaout02-winn.ispmail.ntl.com) (81.103.221.48) by a.mx.sunsite.dk with SMTP; 23 Apr 2006 23:08:37 -0000 Received: from aamtaout02-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout02-winn.ispmail.ntl.com with ESMTP id <20060423230836.OZVE29040.mtaout02-winn.ispmail.ntl.com@aamtaout02-winn.ispmail.ntl.com> for ; Mon, 24 Apr 2006 00:08:36 +0100 Received: from pwslaptop.csr.com ([81.107.43.247]) by aamtaout02-winn.ispmail.ntl.com with ESMTP id <20060423230836.PVAI24467.aamtaout02-winn.ispmail.ntl.com@pwslaptop.csr.com> for ; Mon, 24 Apr 2006 00:08:36 +0100 Received: from pwslaptop.csr.com (pwslaptop.csr.com [127.0.0.1]) by pwslaptop.csr.com (8.13.4/8.13.4) with ESMTP id k3NN8XOe004949 for ; Mon, 24 Apr 2006 00:08:33 +0100 Received: from pwslaptop.csr.com (pws@localhost) by pwslaptop.csr.com (8.13.4/8.13.4/Submit) with ESMTP id k3NN8Wtj004945 for ; Mon, 24 Apr 2006 00:08:32 +0100 Message-Id: <200604232308.k3NN8Wtj004945@pwslaptop.csr.com> X-Authentication-Warning: pwslaptop.csr.com: pws owned process doing -bs From: Peter Stephenson To: zsh-users@sunsite.dk Subject: Re: Problem with motion commands defined using match-word-by-style used with vi-delete In-Reply-To: Your message of "Sun, 23 Apr 2006 08:53:10 PDT." <060423085310.ZM31491@torch.brasslantern.com> Date: Mon, 24 Apr 2006 00:08:31 +0100 Bart Schaefer wrote: > } I fear my time would be > } better spent implementing .recursive-edit-read-one-key. > > There must be a better name for it than that. GNU emacs appears to call > it read-key-sequence. Here's a simple internal widget that reads a key sequence and sets REPLY to the command bound to it (so you can run zle on that). The key sequence reading is just like normal operation, so you can even use M-x. I think this is better than reading just the key sequence, but no doubt you'll let me know if this doesn't do the job. It's so easy to implement I'll commit it anyway. (I called it read-command because a command is what you get back, but pedantically it ought to be something like read-key-sequence-and-return-command; that didn't seem very memorable.) You need to use it something like: local REPLY if zle read-command && [[ $REPLY != undefined-key ]]; then zle $REPLY zle -M "I just executed $REPLY!" else zle -M "No such command" fi Index: Doc/Zsh/zle.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/zle.yo,v retrieving revision 1.51 diff -u -r1.51 zle.yo --- Doc/Zsh/zle.yo 21 Mar 2006 19:19:15 -0000 1.51 +++ Doc/Zsh/zle.yo 23 Apr 2006 23:06:56 -0000 @@ -103,6 +103,12 @@ detect loops the process will be stopped if there are twenty such replacements without a real command being read. +A key sequence typed by the user can be turned into a command name for use +in user-defined widgets with the tt(read-command) widget, described +ifzman(below)\ +ifnzman(in noderef(Miscellaneous) below)\ +. + texinode(Zle Builtins)(Zle Widgets)(Keymaps)(Zsh Line Editor) sect(Zle Builtins) cindex(zle, builtin commands) @@ -1767,6 +1773,16 @@ construct into the editor buffer. The latter is equivalent to tt(push-input) followed by tt(get-line). ) +tindex(read-command) +item(tt(read-command))( +Only useful from a user-defined widget. A keystroke is read just as in +normal operation, but instead of the command being executed the name +of the command that would be executed is stored in the shell parameter +tt(REPLY). This can be used as the argument of a future tt(zle) +command. If the key sequence is not bound, status 1 is returned; +typically, however, tt(REPLY) is set to tt(undefined-key) to indicate +a useless key sequence. +) tindex(recursive-edit) item(tt(recursive-edit))( Only useful from a user-defined widget. At this point in the function, Index: Src/Zle/iwidgets.list =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/iwidgets.list,v retrieving revision 1.8 diff -u -r1.8 iwidgets.list --- Src/Zle/iwidgets.list 24 Nov 2005 10:25:34 -0000 1.8 +++ Src/Zle/iwidgets.list 23 Apr 2006 23:06:56 -0000 @@ -86,6 +86,7 @@ "quoted-insert", quotedinsert, ZLE_MENUCMP | ZLE_KEEPSUFFIX "quote-line", quoteline, 0 "quote-region", quoteregion, 0 +"read-command", readcommand, 0 "recursive-edit", recursiveedit, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_LASTCOL "redisplay", redisplay, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_LASTCOL "redo", redo, ZLE_KEEPSUFFIX Index: Src/Zle/zle_keymap.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_keymap.c,v retrieving revision 1.24 diff -u -r1.24 zle_keymap.c --- Src/Zle/zle_keymap.c 28 Jan 2006 15:02:26 -0000 1.24 +++ Src/Zle/zle_keymap.c 23 Apr 2006 23:06:57 -0000 @@ -1441,3 +1441,16 @@ return; linkkeymap(km, "main", 0); } + +/**/ +mod_export int +readcommand(UNUSED(char **args)) +{ + Thingy thingy = getkeycmd(); + + if (!thingy) + return 1; + + setsparam("REPLY", ztrdup(thingy->nam)); + return 0; +} -- Peter Stephenson Web page still at http://www.pwstephenson.fsnet.co.uk/