1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-01 21:51:40 +02:00

48707: fix keymap handling when zed invokes read-from-minibuffer; update doc

This commit is contained in:
Bart Schaefer 2021-05-15 13:23:31 -07:00
parent 9e38ab8178
commit 231c049c02
3 changed files with 37 additions and 14 deletions

View file

@ -1,3 +1,8 @@
2021-05-15 Bart Schaefer <schaefer@zsh.org>
* 48707: Doc/Zsh/contrib.yo, Functions/Zle/zed-set-file-name:
fix keymap handling when zed invokes read-from-minibuffer
2021-05-06 Peter Stephenson <p.stephenson@samsung.com>
* 48787: Src/loop.c, Test/A01grammar.ztst: status was incorrect

View file

@ -4534,16 +4534,17 @@ suitable for putting into a startup file. Note that, if rerun,
this will overwrite the existing tt(zed) and tt(zed-vicmd) keymaps.
Completion is available, and styles may be set with the context prefix
`tt(:completion:zed)'.
`tt(:completion:zed:)'.
A zle widget tt(zed-set-file-name) is available. This can be called by
name from within zed using `tt(\ex zed-set-file-name)' (note, however, that
because of zed's rebindings you will have to type tt(^j) at the end instead
of the return key), or can be bound to a key in either of the tt(zed) or
tt(zed-vicmd) keymaps after `tt(zed -b)' has been run. When the widget is
called, it prompts for a new name for the file being edited. When zed
exits the file will be written under that name and the original file will
be left alone. The widget has no effect with `tt(zed -f)'.
findex(zed-set-file-name)
A zle widget tt(zed-set-file-name) is available. This can be called
by name from within zed using `tt(\ex zed-set-file-name)' or can be
bound to a key in either of the tt(zed) or tt(zed-vicmd) keymaps after
`tt(zed -b)' has been run. When the widget is called, it prompts for
a new name for the file being edited. When zed exits the file will be
written under that name and the original file will be left alone. The
widget has no effect when invoked from `tt(zed -f)'. The completion
context is changed to `tt(:completion:zed-set-file-name:)'.
While tt(zed-set-file-name) is running, zed uses the keymap
tt(zed-normal-keymap), which is linked from the main keymap in effect

View file

@ -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-file-name:::
# 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-file-name:::)
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
}