zsh-users
 help / color / mirror / code / Atom feed
* is there way to use vicmd (not viins) layout initially?
@ 2003-04-03 12:00 Ilya Kuznecov
  2003-04-03 13:20 ` Peter Stephenson
  0 siblings, 1 reply; 4+ messages in thread
From: Ilya Kuznecov @ 2003-04-03 12:00 UTC (permalink / raw)
  To: zsh-users

As far as I know, this is only viins mode by default. Do I fail? 

-- 
chumpa, Cybernetic Humanoid Used for Mathematics and Potential Assassination
kuznecov@blok-caf.ru       http://chumpa.izhnet.ru     icq 122393064


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

* Re: is there way to use vicmd (not viins) layout initially?
  2003-04-03 12:00 is there way to use vicmd (not viins) layout initially? Ilya Kuznecov
@ 2003-04-03 13:20 ` Peter Stephenson
  2003-04-03 14:49   ` Zefram
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Stephenson @ 2003-04-03 13:20 UTC (permalink / raw)
  To: zsh-users

Ilya Kuznecov wrote:
> As far as I know, this is only viins mode by default. Do I fail? 

You probably *should* be able to do this:

zle -A vicmd main

Unfortunately, if you do that, although the shell starts in vicmd mode,
you can't get into viins mode, because the code which implements
`vi-insert' switches to the main keymap, i.e. in this case straight back
to vicmd.  This is actually documented, but I'm not sure if it's
necessary.

You can get round it with:

  vi-insert() { zle -K viins; }
  zle -N vi-insert

but unfortunately you need to rewrite every widget that switches to
insert mode (those bound to I, a, A, c, etc. etc.) in a similar fashion.

What does everyone think about tying vi-insert to switching to viins,
rather than `main' (and other logically related changes)?  This would
need changes in the documentation, too.

Note there's nothing to stop you copying another keymap onto viins, so I
don't think this stops you doing anything you might want to.

I think the problem comes with the vi-cmd-mode binding in Emacs mode.
In this case, `i' or whatever will put you into vi insert mode, not back
to Emacs mode.  But that seems to me to be exactly what is documented:

     vi-insert (unbound) (i) (unbound)
          Enter insert mode.

--- nothing about returning to the main keymap.

You can write a widget to switch the keymap.

  main-map() { zle -K main; }
  zle -N main-map
  bindkey -M vicmd 'M' main-map

then i etc. still do what are documented, but 'M' returns you to the
main keymap.

This seems to me more useful and predictable than the current
arrangement.

If there's deathly silence I won't dare change this.

Index: Src/Zle/zle_vi.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_vi.c,v
retrieving revision 1.1.1.9
diff -u -r1.1.1.9 zle_vi.c
--- Src/Zle/zle_vi.c	3 Jul 1999 13:18:04 -0000	1.1.1.9
+++ Src/Zle/zle_vi.c	3 Apr 2003 12:57:32 -0000
@@ -89,7 +89,7 @@
 startvitext(int im)
 {
     startvichange(im);
-    selectkeymap("main", 1);
+    selectkeymap("viins", 1);
     undoing = 0;
     viinsbegin = cs;
 }
@@ -98,7 +98,7 @@
 int
 vigetkey(void)
 {
-    Keymap mn = openkeymap("main");
+    Keymap mn = openkeymap("viins");
     char m[3], *str;
     Thingy cmd;
 
@@ -351,7 +351,7 @@
     if ((c2 = getvirange(1)) != -1) {
 	ret = 0;
 	forekill(c2 - cs, 0);
-	selectkeymap("main", 1);
+	selectkeymap("viins", 1);
 	viinsbegin = cs;
 	undoing = 0;
     }


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************


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

* Re: is there way to use vicmd (not viins) layout initially?
  2003-04-03 13:20 ` Peter Stephenson
@ 2003-04-03 14:49   ` Zefram
  2003-04-03 15:30     ` Peter Stephenson
  0 siblings, 1 reply; 4+ messages in thread
From: Zefram @ 2003-04-03 14:49 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: zsh-users

Peter Stephenson wrote:
>Unfortunately, if you do that, although the shell starts in vicmd mode,
>you can't get into viins mode, because the code which implements
>`vi-insert' switches to the main keymap, i.e. in this case straight back
>to vicmd.  This is actually documented, but I'm not sure if it's
>necessary.

I believe the intent was that in Emacs mode one could switch to
vi command mode and then switch back to Emacs mode by invoking an
insert command from the vicmd keymap.  That is, one can have vi-style
modal editing with the insert mode keymap actually being Emacs mode.
Changing the vi insert commands to switch to the "viins" keymap would
make this impossible in the current keymap arrangement.  It would still
be possible to get a similar effect by making "viins" an alias for the
"emacs" keymap, but this is an extra setup step and comes at the expense
of the real vi insert mode keymap.

I suggest that to achieve starting editing in vi command mode what one
wants to do is select the "vicmd" keymap instead of "main" when the editor
is invoked.  Perhaps there could be a specially-named widget that, if it
exists, gets invoked as soon as ZLE has started up to start editing a new
command line; this would be the in-ZLE equivalent of the precmd function.

-zefram


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

* Re: is there way to use vicmd (not viins) layout initially?
  2003-04-03 14:49   ` Zefram
@ 2003-04-03 15:30     ` Peter Stephenson
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Stephenson @ 2003-04-03 15:30 UTC (permalink / raw)
  To: zsh-users

Zefram wrote:
> I believe the intent was that in Emacs mode one could switch to
> vi command mode and then switch back to Emacs mode by invoking an
> insert command from the vicmd keymap.

I'm sure that's correct, but it's undocumented and to mind confusing.
Further, I suspect few people use vicmd from Emacs at all.  So I thought
the new way would be more useful.

> I suggest that to achieve starting editing in vi command mode what one
> wants to do is select the "vicmd" keymap instead of "main" when the editor
> is invoked.  Perhaps there could be a specially-named widget that, if it
> exists, gets invoked as soon as ZLE has started up to start editing a new
> command line; this would be the in-ZLE equivalent of the precmd function.

That would be useful anyway.  We could have zle-init-hook (at
initialisation) and zle-start-hook (each time the editor is started).

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************


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

end of thread, other threads:[~2003-04-03 15:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-03 12:00 is there way to use vicmd (not viins) layout initially? Ilya Kuznecov
2003-04-03 13:20 ` Peter Stephenson
2003-04-03 14:49   ` Zefram
2003-04-03 15:30     ` Peter Stephenson

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).