From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4865 invoked by alias); 22 Dec 2014 18:52:45 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 34039 Received: (qmail 29069 invoked from network); 22 Dec 2014 18:52:41 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,T_FSL_HELO_BARE_IP_2 autolearn=ham version=3.3.2 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= From: ZyX To: Bart Schaefer , "zsh-workers@zsh.org" In-Reply-To: <141221175723.ZM5756@torch.brasslantern.com> References: <141221175723.ZM5756@torch.brasslantern.com> Subject: Re: In Vi mode, show whether "insert" or "command" state is active MIME-Version: 1.0 Message-Id: <8569631419273880@web5h.yandex.ru> X-Mailer: Yamail [ http://yandex.ru ] 5.0 Date: Mon, 22 Dec 2014 21:44:40 +0300 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=koi8-r 22.12.2014, 04:58, "Bart Schaefer" : > 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