zsh-workers
 help / color / mirror / code / Atom feed
From: ZyX <kp-pav@yandex.ru>
To: Bart Schaefer <schaefer@brasslantern.com>,
	"zsh-workers@zsh.org" <zsh-workers@zsh.org>
Subject: Re: In Vi mode, show whether "insert" or "command" state is active
Date: Mon, 22 Dec 2014 21:44:40 +0300	[thread overview]
Message-ID: <8569631419273880@web5h.yandex.ru> (raw)
In-Reply-To: <141221175723.ZM5756@torch.brasslantern.com>

22.12.2014, 04:58, "Bart Schaefer" <schaefer@brasslantern.com>:
> 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


  parent reply	other threads:[~2014-12-22 18:52 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-22  0:07 Fwd: " Jason Spiro
2014-12-22  1:57 ` Bart Schaefer
2014-12-22 18:25   ` Peter Stephenson
2014-12-22 18:44     ` Ray Andrews
2014-12-22 18:44   ` ZyX [this message]
2014-12-23  4:40     ` Bart Schaefer
2014-12-25  4:15     ` Jason Spiro
2014-12-25 20:34       ` ZyX
2014-12-25 23:18         ` Bart Schaefer
2014-12-26 11:32           ` Oliver Kiddle
2014-12-26 19:21             ` Bart Schaefer
2014-12-26 21:58               ` Christian Neukirchen
2014-12-27  0:31                 ` Bart Schaefer
2014-12-29  3:43 Jason Spiro

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8569631419273880@web5h.yandex.ru \
    --to=kp-pav@yandex.ru \
    --cc=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).