summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--Doc/Zsh/options.yo16
-rw-r--r--Src/Zle/zle_keymap.c10
-rw-r--r--Src/Zle/zle_main.c2
-rw-r--r--Src/init.c3
-rw-r--r--Src/zsh.h2
5 files changed, 33 insertions, 0 deletions
diff --git a/Doc/Zsh/options.yo b/Doc/Zsh/options.yo
index 3616ae50c..8ae442cb2 100644
--- a/Doc/Zsh/options.yo
+++ b/Doc/Zsh/options.yo
@@ -367,6 +367,14 @@ Use the Dvorak keyboard instead of the standard qwerty keyboard as a basis
 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>)(
@@ -1193,6 +1201,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)
 cindex(commands, tracing)
diff --git a/Src/Zle/zle_keymap.c b/Src/Zle/zle_keymap.c
index c36657697..3a06bb632 100644
--- a/Src/Zle/zle_keymap.c
+++ b/Src/Zle/zle_keymap.c
@@ -1370,3 +1370,13 @@ getkeycmd(void)
 	func = lastnamed;
     return func;
 }
+
+/**/
+mod_export void
+zlesetkeymap(int mode)
+{
+    Keymap km = openkeymap((mode == VIMODE) ? "viins" : "emacs");
+    if (!km)
+	return;
+    linkkeymap(km, "main", 0);
+}
diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c
index a8c97ba1b..1f2f07a09 100644
--- a/Src/Zle/zle_main.c
+++ b/Src/Zle/zle_main.c
@@ -1363,6 +1363,7 @@ setup_(Module m)
     refreshptr = zrefresh;
     spaceinlineptr = spaceinline;
     zlereadptr = zleread;
+    zlesetkeymapptr = zlesetkeymap;
 
     getkeyptr = getkey;
 
@@ -1446,6 +1447,7 @@ finish_(Module m)
     refreshptr = noop_function;
     spaceinlineptr = noop_function_int;
     zlereadptr = fallback_zleread;
+    zlesetkeymapptr= noop_function_int;
 
     getkeyptr = NULL;
 
diff --git a/Src/init.c b/Src/init.c
index e3a6bda3a..06558e918 100644
--- a/Src/init.c
+++ b/Src/init.c
@@ -1112,6 +1112,8 @@ mod_export ZleVoidFn refreshptr = noop_function;
 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 = autoload_zleread;
 mod_export ZleReadFn zlereadptr = fallback_zleread;
 # endif /* !UNLINKED_XMOD_zshQszle */
 
+mod_export ZleVoidIntFn zlesetkeymapptr = noop_function_int;
 #endif /* !LINKED_XMOD_zshQszle */
 
 /**/
diff --git a/Src/zsh.h b/Src/zsh.h
index 033005dfc..1733ce9bc 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -1418,6 +1418,7 @@ enum {
     CSHJUNKIEQUOTES,
     CSHNULLCMD,
     CSHNULLGLOB,
+    EMACSMODE,
     EQUALS,
     ERREXIT,
     ERRRETURN,
@@ -1515,6 +1516,7 @@ enum {
     TYPESETSILENT,
     UNSET,
     VERBOSE,
+    VIMODE,
     XTRACE,
     USEZLE,
     DVORAK,