fix activation of application mode in ZLE #5

Closed
wants to merge 1 commit into
from

2 participants

@kljohann

I just noticed this because of the updated history-substring-search module. This commit dropped the default binding of \EOA thus for the Up-key binding to work we rely on the value of $terminfo[kcuu1]. When I'm running tmux using TERM=screen-256color, \E[A is sent in "raw" mode and \E[OA in "application" mode:

# I uncommented 'zle -N zle-line-finish/init' in editor/init.zsh for this example
 $ echoti rmkx
$ cat > /dev/null
^[[A^[[A^[[A
$ echoti smkx    
$ cat > /dev/null
^[OA^[OA^[OA

infocmp $TERM list the application mode key for kcuu1. Thus I would expect the 'Up' mapping to work in tmux. But it does not. Running this snippet from the ZSH FAQ by hand solves the problem:

function zle-line-init () { echoti smkx }
function zle-line-finish () { echoti rmkx }
zle -N zle-line-init
zle -N zle-line-finish

So my guess is that this functionality is not implemented correctly in editor/init.zsh. Indeed, the value of "$0" in function zle-keymap-select zle-line-init zle-line-finish { always seems to be zsh when called as a widget or via execute-named-cmd. When calling the function directly, "$0" returns the name of the function as expected.


I started typing this into the 'new issue' form but then created a patch after finishing the last paragraph so I'm doing a pull request instead. If you have a DRYer way of achieving the same thing feel free to implement that instead of this patch. :)

@kljohann kljohann fix activation of application mode in ZLE
The value of "$0" when called as a widget always seems to be "zsh"
instead of the name of the called function as usual.
28a3b88
@kljohann

I just pushed a nicer fix, apparently you can use the $WIDGET variable to access the name of the current widget. This is ready to merge now, I think.

@meh

So this is what it was, only noticed it recently under root since I use the vi mode otherwise.

Tested here and seems to work, merged by hand, thanks!

@meh meh closed this Jan 21, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment