summary refs log tree commit diff
path: root/Functions
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2004-04-06 09:16:57 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2004-04-06 09:16:57 +0000
commit4688564c0a891a2e3fa73255cf907dd269a62a2e (patch)
tree58b7565400d484cfeb1ffd30784ad98b6daf0f9a /Functions
parent294ce1cd6a605a96d92aa270c7bcb47a30fadc1f (diff)
downloadzsh-4688564c0a891a2e3fa73255cf907dd269a62a2e.tar.gz
zsh-4688564c0a891a2e3fa73255cf907dd269a62a2e.tar.xz
zsh-4688564c0a891a2e3fa73255cf907dd269a62a2e.zip
19733 with docs tweaked: keymaps for vared and zed
Diffstat (limited to 'Functions')
-rw-r--r--Functions/Misc/zed33
1 files changed, 20 insertions, 13 deletions
diff --git a/Functions/Misc/zed b/Functions/Misc/zed
index 3cee176a1..eef8ee218 100644
--- a/Functions/Misc/zed
+++ b/Functions/Misc/zed
@@ -10,7 +10,7 @@
 # compctl -f -x 'w[1,-f]' -F -- zed
 #
 
-local var fun cleanup
+local var fun
 # We do not want timeout while we are editing a file
 integer TMOUT=0
 
@@ -24,20 +24,27 @@ local curcontext=zed:::
 zstyle -m ":completion:zed:*" insert-tab '*' ||
     zstyle ":completion:zed:*" insert-tab yes
 
-# catch interrupts
-cleanup="$(bindkey -L "^M"; bindkey -L -M emacs "^X^W"; bindkey -aL "ZZ"
-    echo "trap - INT EXIT"; trap)"
-trap "return 130" INT
-trap "$cleanup" EXIT
+if ! bindkey -M zed >&/dev/null; then
+  # Make the zed keymap a copy of the current main.
+  bindkey -N zed main
+
+  # Assign some default keys.
+  # Depending on your stty's, you may be able to use ^J as accept-line, else:
+
+  # The following isn't useful if we are copying viins, but that's
+  # a nicety.
+  bindkey -M zed '^x^w' accept-line
+  bindkey -M zed '^M' self-insert-unmeta
+fi
+if ! bindkey -M zed-vicmd >&/dev/null; then
+  bindkey -N zed-vicmd vicmd
+
+  bindkey -M zed-vicmd "ZZ" accept-line
+fi
 
 # don't mangle !'s
 setopt localoptions nobanghist
 
-bindkey "^M" self-insert-unmeta
-# Depending on your stty's, you may be able to use ^J as accept-line, else:
-bindkey -M emacs "^X^W" accept-line
-bindkey -a "ZZ" accept-line
-
 if ((fun)) then
   var="$(functions $1)"
   # If function is undefined but autoloadable, load it
@@ -55,10 +62,10 @@ $(<$dir/$1)
     var="$1() {
 }"
   fi
-  vared var && eval "$cleanup ;" function "$var"
+  vared -M zed -m zed-vicmd var && eval function "$var"
 else
   [[ -f $1 ]] && var="$(<$1)"
-  while vared var
+  while vared -M zed -m zed-vicmd var
   do
     (print -r -- "$var" >| $1) && break
     echo -n -e '\a'