From e1974ad58db5efbc85e65c638703d54847540c79 Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Thu, 9 Jan 2014 19:58:14 -0500 Subject: [PATCH] [Fix #516] Define ZLE functions separately --- modules/editor/init.zsh | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/modules/editor/init.zsh b/modules/editor/init.zsh index 0fe98858..9a347a09 100644 --- a/modules/editor/init.zsh +++ b/modules/editor/init.zsh @@ -107,31 +107,40 @@ function editor-info { } zle -N editor-info -# Ensures that $terminfo values are valid and updates editor information when -# the keymap changes. -function zle-keymap-select zle-line-init zle-line-finish { +# Updates editor information when the keymap changes. +function zle-keymap-select { + zle editor-info +} +zle -N zle-keymap-select + +# Enables terminal application mode and updates editor information. +function zle-line-init { # The terminal must be in application mode when ZLE is active for $terminfo # values to be valid. - if (( $+terminfo[smkx] && $+terminfo[rmkx] )); then - case "$0" in - (zle-line-init) - # Enable terminal application mode. - echoti smkx - ;; - (zle-line-finish) - # Disable terminal application mode. - echoti rmkx - ;; - esac + if (( $+terminfo[smkx] )); then + # Enable terminal application mode. + echoti smkx fi # Update editor information. zle editor-info } -zle -N zle-keymap-select -zle -N zle-line-finish zle -N zle-line-init +# Disables terminal application mode and updates editor information. +function zle-line-finish { + # The terminal must be in application mode when ZLE is active for $terminfo + # values to be valid. + if (( $+terminfo[rmkx] )); then + # Disable terminal application mode. + echoti rmkx + fi + + # Update editor information. + zle editor-info +} +zle -N zle-line-finish + # Toggles emacs overwrite mode and updates editor information. function overwrite-mode { zle .overwrite-mode