From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12233 invoked from network); 14 May 2003 14:14:17 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 14 May 2003 14:14:17 -0000 Received: (qmail 8984 invoked by alias); 14 May 2003 14:14:08 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 18536 Received: (qmail 8976 invoked from network); 14 May 2003 14:14:08 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 14 May 2003 14:14:08 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [62.189.183.235] by sunsite.dk (MessageWall 1.0.8) with SMTP; 14 May 2003 14:14:8 -0000 Received: from exchange01.csr.com (unverified) by (Content Technologies SMTPRS 4.2.1) with ESMTP id for ; Wed, 14 May 2003 15:23:59 +0100 Received: from csr.com (tinky-winky.csr.com [192.168.144.127]) by exchange01.csr.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2650.21) id JWCPZTVG; Wed, 14 May 2003 15:11:57 +0100 To: zsh-workers@sunsite.dk Subject: Re: Bug#190948: Violation against The Single UNIX ? Specification, Version 2 In-reply-to: "Zefram"'s message of "Wed, 14 May 2003 13:57:35 BST." <20030514125734.GE29742@fysh.org> Date: Wed, 14 May 2003 15:14:06 +0100 Message-ID: <1787.1052921646@csr.com> From: Peter Stephenson Zefram wrote: > I suggest having a hook to execute on "set -o vi"; Zle would hook this > when it is loaded, just like the other things it already hooks. To be > nice to everyone that knows that, despite POSIX, interactive shells do > actually have an Emacs mode too, it would be good to hook "set -o emacs" > as well. Only these two are required. > > -zefram Gives us something to spit at. Index: Doc/Zsh/options.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/options.yo,v retrieving revision 1.27 diff -u -r1.27 options.yo --- Doc/Zsh/options.yo 4 Dec 2002 13:57:52 -0000 1.27 +++ Doc/Zsh/options.yo 14 May 2003 14:10:42 -0000 @@ -367,6 +367,14 @@ for examining spelling mistakes for the tt(CORRECT) and tt(CORRECT_ALL) options and the tt(spell-word) editor command. ) +pindex(EMACS) +item(tt(EMACS))( +If ZLE is loaded, turning on this option has the equivalent effect +of `tt(bindkey -e)'. In addition, the VI option is unset. +Turning it off has no effect. The option setting is +not guaranteed to reflect the current keymap. This option is +provided for compatibility; tt(bindkey) is the recommended interface. +) pindex(EQUALS) cindex(filename expansion, =) item(tt(EQUALS) )( @@ -1192,6 +1200,14 @@ cindex(input, tracing) item(tt(VERBOSE) (tt(-v), ksh: tt(-v)))( Print shell input lines as they are read. +) +pindex(VI) +item(tt(VI))( +If ZLE is loaded, turning on this option has the equivalent effect +of `tt(bindkey -v)'. In addition, the EMACS option is unset. +Turning it off has no effect. The option setting is +not guaranteed to reflect the current keymap. This option is +provided for compatibility; tt(bindkey) is the recommended interface. ) pindex(XTRACE) cindex(tracing, of commands) Index: Src/init.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/init.c,v retrieving revision 1.32 diff -u -r1.32 init.c --- Src/init.c 23 Apr 2003 18:04:48 -0000 1.32 +++ Src/init.c 14 May 2003 14:10:42 -0000 @@ -1112,6 +1112,8 @@ mod_export ZleVoidIntFn spaceinlineptr = noop_function_int; /**/ mod_export ZleReadFn zlereadptr = autoload_zleread; +/**/ +mod_export ZleVoidIntFn zlesetkeymapptr = noop_function_int; #else /* !LINKED_XMOD_zshQszle */ @@ -1124,6 +1126,7 @@ mod_export ZleReadFn zlereadptr = fallback_zleread; # endif /* !UNLINKED_XMOD_zshQszle */ +mod_export ZleVoidIntFn zlesetkeymapptr = noop_function_int; #endif /* !LINKED_XMOD_zshQszle */ /**/ Index: Src/options.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/options.c,v retrieving revision 1.14 diff -u -r1.14 options.c --- Src/options.c 4 Dec 2002 13:57:51 -0000 1.14 +++ Src/options.c 14 May 2003 14:10:42 -0000 @@ -107,6 +107,7 @@ {NULL, "cshjunkiequotes", OPT_EMULATE|OPT_CSH, CSHJUNKIEQUOTES}, {NULL, "cshnullcmd", OPT_EMULATE|OPT_CSH, CSHNULLCMD}, {NULL, "cshnullglob", OPT_EMULATE|OPT_CSH, CSHNULLGLOB}, +{NULL, "emacs", 0, EMACSMODE}, {NULL, "equals", OPT_EMULATE|OPT_ZSH, EQUALS}, {NULL, "errexit", OPT_EMULATE, ERREXIT}, {NULL, "errreturn", OPT_EMULATE, ERRRETURN}, @@ -204,6 +205,7 @@ {NULL, "typesetsilent", OPT_EMULATE|OPT_BOURNE, TYPESETSILENT}, {NULL, "unset", OPT_EMULATE|OPT_BSHELL, UNSET}, {NULL, "verbose", 0, VERBOSE}, +{NULL, "vi", 0, VIMODE}, {NULL, "xtrace", 0, XTRACE}, {NULL, "zle", OPT_SPECIAL, USEZLE}, {NULL, "braceexpand", OPT_ALIAS, /* ksh/bash */ -IGNOREBRACES}, @@ -679,6 +681,9 @@ } else if(optno == CDABLEVARS && value) { return -1; #endif /* GETPWNAM_FAKED */ + } else if ((optno == EMACSMODE || optno == VIMODE) && value) { + (*zlesetkeymapptr)(optno); + opts[(optno == EMACSMODE) ? VIMODE : EMACSMODE] = 0; } opts[optno] = value; if (optno == BANGHIST || optno == SHINSTDIN) Index: Src/zsh.h =================================================================== RCS file: /cvsroot/zsh/zsh/Src/zsh.h,v retrieving revision 1.46 diff -u -r1.46 zsh.h --- Src/zsh.h 2 May 2003 10:25:33 -0000 1.46 +++ Src/zsh.h 14 May 2003 14:10:42 -0000 @@ -1418,6 +1418,7 @@ CSHJUNKIEQUOTES, CSHNULLCMD, CSHNULLGLOB, + EMACSMODE, EQUALS, ERREXIT, ERRRETURN, @@ -1515,6 +1516,7 @@ TYPESETSILENT, UNSET, VERBOSE, + VIMODE, XTRACE, USEZLE, DVORAK, Index: Src/Zle/zle_keymap.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_keymap.c,v retrieving revision 1.9 diff -u -r1.9 zle_keymap.c --- Src/Zle/zle_keymap.c 27 Aug 2002 21:10:34 -0000 1.9 +++ Src/Zle/zle_keymap.c 14 May 2003 14:10:43 -0000 @@ -1370,3 +1370,13 @@ func = lastnamed; return func; } + +/**/ +mod_export void +zlesetkeymap(int mode) +{ + Keymap km = openkeymap((mode == VIMODE) ? "viins" : "emacs"); + if (!km) + return; + linkkeymap(km, "main", 0); +} Index: Src/Zle/zle_main.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_main.c,v retrieving revision 1.31 diff -u -r1.31 zle_main.c --- Src/Zle/zle_main.c 17 Feb 2003 14:07:12 -0000 1.31 +++ Src/Zle/zle_main.c 14 May 2003 14:10:43 -0000 @@ -1363,6 +1363,7 @@ refreshptr = zrefresh; spaceinlineptr = spaceinline; zlereadptr = zleread; + zlesetkeymapptr = zlesetkeymap; getkeyptr = getkey; @@ -1446,6 +1447,7 @@ refreshptr = noop_function; spaceinlineptr = noop_function_int; zlereadptr = fallback_zleread; + zlesetkeymapptr= noop_function_int; getkeyptr = NULL; 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 14 May 2003 14:10:43 -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; } -- Peter Stephenson 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. **********************************************************************