zsh-users
 help / color / mirror / code / Atom feed
* Why can't the 'main' keymap be an alias from 'vicmd'
@ 2010-12-08 22:45 first name
  2010-12-09 10:00 ` Peter Stephenson
  0 siblings, 1 reply; 5+ messages in thread
From: first name @ 2010-12-08 22:45 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 706 bytes --]

 <zsh-users-sc.1291846382.mkdokibkckoflkocimkl-33facebook><http://gmail.com/>

The following is from the zshzle page:

		  "Note  that  while `bindkey -A newmap main' will work when newmap
		  is emacs or viins, it will not work for vicmd, as switching from
		  vi insert to command mode becomes impossible."

Well, trying it by aliasing main to vicmd, i.e. `bindkey -A vicmd
main', i was "able" to to switch to vicmd mode, but the actual thing
that was impossible, is switching to insert mode.

now why?

I mean, why is it possible to have 'main' linked to viins and have
<esc> bound to the 'vi-cmd' widget, and not have the main linked to
vicmd while `i' and `a' bound to the 'vi-insert' widget?

cheers

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Why can't the 'main' keymap be an alias from 'vicmd'
  2010-12-08 22:45 Why can't the 'main' keymap be an alias from 'vicmd' first name
@ 2010-12-09 10:00 ` Peter Stephenson
  2010-12-09 15:18   ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: Peter Stephenson @ 2010-12-09 10:00 UTC (permalink / raw)
  To: zsh-users

On Thu, 9 Dec 2010 09:15:41 +1030
first name <33facebook@gmail.com> wrote:
> I mean, why is it possible to have 'main' linked to viins and have
> <esc> bound to the 'vi-cmd' widget, and not have the main linked to
> vicmd while `i' and `a' bound to the 'vi-insert' widget?

<esc> doesn't map to vi-cmd, it means 'leave insert mode and return to
the main keymap'.

Are you trying to start the line in command mode?  If you have a recent
enough version of the shell, see the example under zle-line-init in the
zshzle manual page.

-- 
Peter Stephenson <pws@csr.com>            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, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Why can't the 'main' keymap be an alias from 'vicmd'
  2010-12-09 10:00 ` Peter Stephenson
@ 2010-12-09 15:18   ` Bart Schaefer
  2010-12-09 15:38     ` Peter Stephenson
  0 siblings, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2010-12-09 15:18 UTC (permalink / raw)
  To: zsh-users

On Dec 9, 10:00am, Peter Stephenson wrote:
} Subject: Re: Why can't the 'main' keymap be an alias from 'vicmd'
}
} On Thu, 9 Dec 2010 09:15:41 +1030
} first name <33facebook@gmail.com> wrote:
} > I mean, why is it possible to have 'main' linked to viins and have
} > <esc> bound to the 'vi-cmd' widget, and not have the main linked to
} > vicmd while `i' and `a' bound to the 'vi-insert' widget?
} 
} <esc> doesn't map to vi-cmd, it means 'leave insert mode and return to
} the main keymap'.

I think you have that backwards, Peter:

schaefer<505> (bindkey -v; bindkey -lL)
bindkey -N command
bindkey -N emacs
bindkey -N isearch
bindkey -N listscroll
bindkey -A viins main
bindkey -N menuselect
bindkey -N vicmd
bindkey -N viins

What you really mean is that vi-insert and all its friends don't mean
"select the viins keymap", they mean "position the cursor as needed
and switch back to the main keymap".

Doc says:

vi-cmd-mode (^X^V) (unbound) (^[)
     Enter command mode; that is, select the `vicmd' keymap.  Yes, this
     is bound by default in emacs mode.

This is the real hidden reason that "bindkey -A vicmd main" doesn't
work; it's because vicmd is not the alternate to viins, it's the
alternate to *anything else you might want to use as main*.

It didn't even used to have a name.  Originally it was just "the
alternate keymap" and the only way you could put things into it was
with "bindkey -a" for "alternate".  It happens that the default set
of bindings for the alternate keymap are those corresponding to the
vi command mode, is all.

If we had thought about it hard enough, when we introduced the magic
name "main" for the primary keymap we should also have introduced a
magic name "alt" for the bindkey -a keymap, and let you have any two
keymaps as main/alt.  Then bindkey -v would select viins/vicmd, and
bindkey -e would select emacs/vicmd, and we could have documented
that vi-cmd-mode really means alt-keymap-mode.

Maybe it's not too late to do this anyway, as it won't change any of
the old behavior.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Why can't the 'main' keymap be an alias from 'vicmd'
  2010-12-09 15:18   ` Bart Schaefer
@ 2010-12-09 15:38     ` Peter Stephenson
  2010-12-09 17:08       ` Aaron Davies
  0 siblings, 1 reply; 5+ messages in thread
From: Peter Stephenson @ 2010-12-09 15:38 UTC (permalink / raw)
  To: zsh-users

On Thu, 09 Dec 2010 07:18:52 -0800
Bart Schaefer <schaefer@brasslantern.com> wrote:
> What you really mean is that vi-insert and all its friends don't mean
> "select the viins keymap", they mean "position the cursor as needed
> and switch back to the main keymap".

Yes, you're right.

> If we had thought about it hard enough, when we introduced the magic
> name "main" for the primary keymap we should also have introduced a
> magic name "alt" for the bindkey -a keymap, and let you have any two
> keymaps as main/alt.  Then bindkey -v would select viins/vicmd, and
> bindkey -e would select emacs/vicmd, and we could have documented
> that vi-cmd-mode really means alt-keymap-mode.
> 
> Maybe it's not too late to do this anyway, as it won't change any of
> the old behavior.

Doesn't sound impossible to without screwing anything up.

-- 
Peter Stephenson <pws@csr.com>            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, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Why can't the 'main' keymap be an alias from 'vicmd'
  2010-12-09 15:38     ` Peter Stephenson
@ 2010-12-09 17:08       ` Aaron Davies
  0 siblings, 0 replies; 5+ messages in thread
From: Aaron Davies @ 2010-12-09 17:08 UTC (permalink / raw)
  To: zsh-users

On Thursday, December 9, 2010, Peter Stephenson  wrote:

> Doesn't sound impossible to [do] without screwing anything up.

Words for the ages. I must use that in my next project meeting at work....

-- 
Aaron Davies
aaron.davies@gmail.com


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-12-09 17:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-08 22:45 Why can't the 'main' keymap be an alias from 'vicmd' first name
2010-12-09 10:00 ` Peter Stephenson
2010-12-09 15:18   ` Bart Schaefer
2010-12-09 15:38     ` Peter Stephenson
2010-12-09 17:08       ` Aaron Davies

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).