zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: zsh-workers@sunsite.dk
Subject: Re: Bug#190948: Violation against The Single UNIX ? Specification, Version 2
Date: Wed, 14 May 2003 15:14:06 +0100	[thread overview]
Message-ID: <1787.1052921646@csr.com> (raw)
In-Reply-To: "Zefram"'s message of "Wed, 14 May 2003 13:57:35 BST." <20030514125734.GE29742@fysh.org>

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) <Z>)(
@@ -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 <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.
**********************************************************************


  reply	other threads:[~2003-05-14 14:14 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20030427130703.GB12714@verso.st.jyu.fi>
2003-05-14 11:07 ` Bug#190948: Violation against The Single UNIX ® " Oliver Kiddle
2003-05-14 11:46   ` Bug#190948: Violation against The Single UNIX R " Borzenkov Andrey
2003-05-14 12:40   ` Bug#190948: Violation against The Single UNIX ® " Peter Stephenson
2003-05-14 12:57     ` Bug#190948: Violation against The Single UNIX ? " Zefram
2003-05-14 14:14       ` Peter Stephenson [this message]
2003-05-14 14:20         ` Peter Stephenson
2003-05-15  9:17         ` Peter Stephenson
2003-05-15  9:37           ` Zefram
2003-05-15  9:49             ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1787.1052921646@csr.com \
    --to=pws@csr.com \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).