diff --git a/Functions/Zle/zed-set-file-name b/Functions/Zle/zed-set-file-name index da3421e71..c77a9d26e 100644 --- a/Functions/Zle/zed-set-file-name +++ b/Functions/Zle/zed-set-file-name @@ -2,8 +2,25 @@ emulate -L zsh autoload -Uz read-from-minibuffer -zle -K zed-normal-keymap - -local REPLY -read-from-minibuffer "File name: " -zed_file_name=$REPLY +case $curcontext in + (zed:::) + local curcontext=zed-set-filename::: + # The call to vared from zed does the equivalent of + # bindkey -A zed main + # which confuses read-from-minibuffer. Fix it. + bindkey -A zed-normal-keymap main;; + (zed-set-filename:::) + zle -M "zed-set-file-name: may not be called recursively" + return 1;; + (*) + zle -M "zed-set-file-name: not called from within zed" + return 1;; +esac +{ + local REPLY + read-from-minibuffer "File name: " + zed_file_name=$REPLY +} always { + # Re-install the zed keymap in the way vared should have all along + zle -K zed +}