Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: In Vi mode, show whether "insert" or "command" state is active
- X-seq: zsh-workers 34039
- From: ZyX <kp-pav@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>, "zsh-workers@xxxxxxx" <zsh-workers@xxxxxxx>
- Subject: Re: In Vi mode, show whether "insert" or "command" state is active
- Date: Mon, 22 Dec 2014 21:44:40 +0300
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1419273881; bh=wp7sJB75CjUHfKACvSf+65+Ra6Qc844oMEwzNptigcE=; h=From:To:In-Reply-To:References:Subject:Date; b=HMdJVc9vYBleHtBXyon/qjDfncHMlIHpq1JqMM+/7JrOrkuojAwPWVDu1JqAbqyqF MyMD/hTeGGOZT+qZKmOeXAqkKRxTTqTEFiu+h6XPYElJPDPvdoeKPceAQhQc005xOJ wGhrCue5oZfyBF5bimKwgs8zP/rwm9FoYkbx22Ok=
- In-reply-to: <141221175723.ZM5756@torch.brasslantern.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CAN2X26=uQEj=1gB9UQqySDzB-O=zLE9FgHX2k+zTLpx_+3Pjug@mail.gmail.com> <141221175723.ZM5756@torch.brasslantern.com>
22.12.2014, 04:58, "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxx>:
> On Dec 21, 7:07pm, Jason Spiro wrote:
> }
> } I know that it's already possible. The feature request was not asking
> } you to make mode indication _possible_: it was asking you to make it
> } please happen _by default_. :)
>
> And my point was that *even vim* doesn't make it happen *by default*.
> You have to configure it, and it functions in a terminal-specific
> manner. Attempting to build it in to the shell is just going to
> result in frustration when it only works a fraction of the time.
Vim does this if you happen to launch it with an empty ~/.vimrc, -N argument or whatever other method you can use to turn off Vi compatibility. Bram recognizes that this behaviour is rather frustrating, but due to backwards compatibility cannot use new behaviour by default, so it is only on by default when nocompatible is set. I think it may be adding as a question issued by zsh-newuser-install when user selects Vi keymap, but behaviour when `zsh -f` is run or when .zshrc exists because I am pretty sure that in the first case some tests rely on it and in the second case chances that user has already configured what he needs is higher then chances that he has failed to find the solution.
And this should be changed prompt/rprompt, not changing cursor because changing cursor shape is less likely to work. If zsh-newuser-install will ask for creating prompts changing depending on the mode then this should be done with a zsh script, not coded with C. The following shold work:
1. Add `[$ZLE_KEYMAP]` string to prompt:
setopt promptsubst
PS1='%m[$ZLE_KEYMAP]%# '
2. Define the helper functions:
_set_true_keymap_name() {
typeset -g ZLE_KEYMAP="${1:-main}"
local plm_bk="$(bindkey -lL ${ZLE_KEYMAP})"
if [[ $plm_bk = 'bindkey -A'* ]] ; then
_set_true_keymap_name ${(Q)${${(z)plm_bk}[3]}}
fi
}
_zle_keymap_select() {
_set_true_keymap_name $KEYMAP
zle reset-prompt
}
3. Define conditions under which they are called:
precmd_functions+=( _set_true_keymap_name )
zle -N zle-keymap-select _zle_keymap_select
Messages sorted by:
Reverse Date,
Date,
Thread,
Author