From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28432 invoked by alias); 23 Aug 2010 09:36:50 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 15322 Received: (qmail 26392 invoked from network); 23 Aug 2010 09:36:45 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at csr.com does not designate permitted sender hosts) Date: Mon, 23 Aug 2010 10:36:38 +0100 From: Peter Stephenson To: zsh-users@zsh.org Subject: Re: $KEYMAP in command, isearch and menuselect Message-ID: <20100823103638.2fb7e695@csr.com> In-Reply-To: References: Organization: Cambridge Silicon Radio X-Mailer: Claws Mail 3.7.6 (GTK+ 2.18.9; i686-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-OriginalArrivalTime: 23 Aug 2010 09:36:38.0827 (UTC) FILETIME=[AF9987B0:01CB42A6] X-Scanned-By: MailControl A-06-00-00 (www.mailcontrol.com) on 10.71.0.124 On Mon, 09 Aug 2010 19:25:41 +0200 Ole J=C3=B8rgen Br=C3=B8nner wrote: > I was trying to make a zle widget to display the currently active > bindings when I noticed that KEYMAP is set to 'main' in widgets run > from command, isearch and menuselect. >=20 > show-keymap() { > { print "$KEYMAP:\n"; bindkey -M $KEYMAP } | less > } > zle -N show-keymap > bindkey -M vicmd "^Ki" show-keymap > bindkey -M main "^Ki" show-keymap > bindkey -M command "^Ki" show-keymap > bindkey -M menuselect "^Ki" show-keymap > bindkey -M isearch "^Ki" show-keymap >=20 > In 'command' the binding doesn't work. (since you only can bind a few > widgets in 'command') >=20 > In vicmd and main it works as expected >=20 > In isearch and menuselect the 'main' keymap is displayed and the > search/completion is aborted on the current entry. >=20 > Poking in the code for 'executenamedcommand', it seems there is > something called a 'localkeymap' and this is not exposed to zle > widgets. Unfortunately you can't do what you're trying to here, and probably not what you really want to. Not just the command but also the menuselect and isearch environments (I deliberately didn't say keymaps) only have a limited number of commands they can execute. What's more, even if you rebind the command in question the shell will still run the same code from its limited repertoire of things it can do in those special modes. Basically, the only thing you can do is bind one of the names listed in the documentation to a different key. The documentation should probably be clearer the behaviour isn't extensible. Internally, this is because those modes are each implemented within a single function, not by looking up function behaviour like standard editing behaviour. What you're seeing with menuselect and isearch is if they encounter a command they don't understand, they put you back in the normal editing mode which runs that. There is indeed the issue that there's no way of getting the local keymap from shell code. It would be straightforward to add a variable that shows it, so you could decide if there was a binding that took precedence over the principal keymap. However, because of the way the code that uses it is implemented I can't think of a case where you would ever get to shell code that could use it. --=20 Peter Stephenson Software Engineer Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, = UK Member of the CSR plc group of companies. CSR plc registered in England and= Wales, registered number 4187346, registered office Churchill House, Cambr= idge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom