From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8654 invoked from network); 28 Jan 2009 04:59:01 -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.6 required=5.0 tests=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; 28 Jan 2009 04:59:01 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 42804 invoked from network); 28 Jan 2009 04:58:57 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 28 Jan 2009 04:58:57 -0000 Received: (qmail 10032 invoked by alias); 28 Jan 2009 04:58:52 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 26465 Received: (qmail 10016 invoked from network); 28 Jan 2009 04:58:52 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 28 Jan 2009 04:58:52 -0000 Received: from QMTA09.westchester.pa.mail.comcast.net (qmta09.westchester.pa.mail.comcast.net [76.96.62.96]) by bifrost.dotsrc.org (Postfix) with ESMTP id 433CE80271F0 for ; Wed, 28 Jan 2009 05:58:48 +0100 (CET) Received: from OMTA08.westchester.pa.mail.comcast.net ([76.96.62.12]) by QMTA09.westchester.pa.mail.comcast.net with comcast id 8hDq1b00B0Fqzac59syokj; Wed, 28 Jan 2009 04:58:48 +0000 Received: from smtp.klanderman.net ([98.217.254.247]) by OMTA08.westchester.pa.mail.comcast.net with comcast id 8syW1b0065M2Np63UsyWvm; Wed, 28 Jan 2009 04:58:30 +0000 Received: from lwm.klanderman.net (unknown [192.168.100.50]) by smtp.klanderman.net (Postfix) with ESMTP id 2E282B30147 for ; Tue, 27 Jan 2009 23:58:47 -0500 (EST) Received: by lwm.klanderman.net (Postfix, from userid 500) id 080D79FC5EF; Tue, 27 Jan 2009 23:58:47 -0500 (EST) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="freuxDNnEp" Content-Transfer-Encoding: 7bit Message-ID: <18815.58886.978206.504757@gargle.gargle.HOWL> Date: Tue, 27 Jan 2009 23:58:46 -0500 From: Greg Klanderman To: Zsh list Subject: PATCH: keymap for execute-named-command Reply-To: gak@klanderman.net X-Mailer: VM 7.17 under 21.4 (patch 17) "Jumbo Shrimp" XEmacs Lucid X-Virus-Scanned: ClamAV 0.92.1/8913/Tue Jan 27 18:40:47 2009 on bifrost X-Virus-Status: Clean --freuxDNnEp Content-Type: text/plain; charset=us-ascii Content-Description: message body text Content-Transfer-Encoding: 7bit Hi, After binding to a user defined widget, I found that the execute-named-command and where-is widgets no longer work because like isearch and menu-select they have hard-coded a check for accept-line. This patch adds a local keymap for these widgets to use when reading the command name making it easier to use a user-defined widget in your main keymap to replace accept-line. thanks, Greg --freuxDNnEp Content-Type: text/plain Content-Disposition: inline; filename="zsh-command.patch" Content-Transfer-Encoding: 7bit Index: Doc/Zsh/zle.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/zle.yo,v retrieving revision 1.76 diff -u -r1.76 zle.yo --- Doc/Zsh/zle.yo 19 Jan 2009 17:57:43 -0000 1.76 +++ Doc/Zsh/zle.yo 28 Jan 2009 04:26:28 -0000 @@ -60,13 +60,14 @@ findex(bindkey, use of) tt(bindkey) can be used to manipulate keymap names. -Initially, there are five keymaps: +Initially, there are six 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(command))(read a command name) sitem(tt(.safe))(fallback keymap) endsitem() @@ -1862,7 +1868,9 @@ item(tt(execute-named-cmd) (ESC-x) (unbound) (unbound))( Read the name of an editor command and execute it. A restricted set of editing functions is available in the -mini-buffer. An interrupt signal, as defined by the stty setting, will +mini-buffer. Keys are looked up in the special +tt(command) keymap, and if not found there in the main keymap. +An interrupt signal, as defined by the stty setting, will abort the function. The allowed functions are: tt(backward-delete-char), tt(vi-backward-delete-char), @@ -2087,6 +2095,9 @@ item(tt(where-is))( Read the name of an editor command and and print the listing of key sequences that invoke the specified command. +A restricted set of editing functions is available in the +mini-buffer. Keys are looked up in the special +tt(command) keymap, and if not found there in the main keymap. ) tindex(which-command) item(tt(which-command) (ESC-?) (unbound) (unbound))( Index: Src/Zle/zle_keymap.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_keymap.c,v retrieving revision 1.31 diff -u -r1.31 zle_keymap.c --- Src/Zle/zle_keymap.c 19 Jan 2009 17:57:43 -0000 1.31 +++ Src/Zle/zle_keymap.c 28 Jan 2009 04:26:28 -0000 @@ -1176,8 +1176,6 @@ 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 * @@ -1276,10 +1274,19 @@ else linkkeymap(emap, "main", 0); - linkkeymap(isearch_keymap, "isearch", 0); - /* the .safe map cannot be modified or deleted */ smap->flags |= KM_IMMUTABLE; + + /* isearch keymap: initially empty */ + isearch_keymap = newkeymap(NULL, "isearch"); + linkkeymap(isearch_keymap, "isearch", 0); + + /* command keymap: make sure accept-line and send-break are bound */ + command_keymap = newkeymap(NULL, "command"); + command_keymap->first['\n'] = refthingy(t_acceptline); + command_keymap->first['\r'] = refthingy(t_acceptline); + command_keymap->first['G'&0x1F] = refthingy(t_sendbreak); + linkkeymap(command_keymap, "command", 0); } /*************************/ Index: Src/Zle/zle_misc.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_misc.c,v retrieving revision 1.56 diff -u -r1.56 zle_misc.c --- Src/Zle/zle_misc.c 26 Sep 2008 09:11:30 -0000 1.56 +++ Src/Zle/zle_misc.c 28 Jan 2009 04:26:28 -0000 @@ -966,11 +966,19 @@ #define NAMLEN 60 +/* + * Local keymap used when reading a command name for the + * execute-named-command and where-is widgets. + */ + +/**/ +Keymap command_keymap; + /**/ Thingy executenamedcommand(char *prmt) { - Thingy cmd; + Thingy cmd, retval = NULL; int l, len, feep = 0, listed = 0, curlist = 0; int ols = (listshown && validlist), olll = lastlistlen; char *cmdbuf, *ptr; @@ -988,6 +996,7 @@ strcpy(cmdbuf, prmt); zsfree(prmt); statusline = cmdbuf; + selectlocalmap(command_keymap); selectkeymap("main", 1); ptr = cmdbuf += l; len = 0; @@ -1005,7 +1014,8 @@ } else if (listed) clearlist = listshown = 1; - return NULL; + retval = NULL; + goto done; } if(cmd == Th(z_clearscreen)) { clearscreen(zlenoargs); @@ -1090,7 +1100,9 @@ lastlistlen = olll; } else if (listed) clearlist = listshown = 1; - return r; + + retval = r; + goto done; } unrefthingy(r); } @@ -1180,6 +1192,10 @@ handlefeep(zlenoargs); feep = 0; } + + done: + selectlocalmap(NULL); + return retval; } /*****************/ --freuxDNnEp--