From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24439 invoked by alias); 23 Dec 2014 04:40:37 -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: 34049 Received: (qmail 20736 invoked from network); 23 Dec 2014 04:40:26 -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=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-CMAE-Score: 0 X-CMAE-Analysis: v=2.1 cv=CoYIqc8G c=1 sm=1 tr=0 a=FT8er97JFeGWzr5TCOCO5w==:117 a=kj9zAlcOel0A:10 a=q2GGsy2AAAAA:8 a=oR5dmqMzAAAA:8 a=-9mUelKeXuEA:10 a=A92cGCtB03wA:10 a=8y0FyRw0GEMm6tlb8WIA:9 a=CjuIK1q_8ugA:10 From: Bart Schaefer Message-id: <141222204028.ZM9033@torch.brasslantern.com> Date: Mon, 22 Dec 2014 20:40:28 -0800 In-reply-to: <8569631419273880@web5h.yandex.ru> Comments: In reply to ZyX "Re: In Vi mode, show whether "insert" or "command" state is active" (Dec 22, 9:44pm) References: <141221175723.ZM5756@torch.brasslantern.com> <8569631419273880@web5h.yandex.ru> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: "zsh-workers@zsh.org" Subject: Re: In Vi mode, show whether "insert" or "command" state is active MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Dec 22, 9:44pm, ZyX wrote: } } [...] 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. Then perhaps there should be a prompt escape for the keymap? The letters 'z' and 'Z' are not yet taken. (I hate requiring PROMPT_SUBST.) Minimally: diff --git a/Src/prompt.c b/Src/prompt.c index 3552575..ef27699 100644 --- a/Src/prompt.c +++ b/Src/prompt.c @@ -404,6 +404,10 @@ putpromptchar(int doprint, int endchar, unsigned int *txtchangep) test = 1; } break; + case 'z': + if ((ss = getsparam("KEYMAP"))) + test = !!strcmp(ss, "main"); + break; case '_': test = (cmdsp >= arg); break; @@ -854,6 +858,14 @@ putpromptchar(int doprint, int endchar, unsigned int *txtchangep) promptpath(scriptfilename ? scriptfilename : argzero, arg, 0); break; + case 'z': + if ((ss = getsparam("KEYMAP"))) + stradd(ss); + break; + case 'Z': + if ((ss = getsparam("ZLE_STATE"))) + stradd(ss); + break; case '\0': return 0; case Meta: This still requires one to write zle-keymap-select() { zle reset-prompt } zle -N zle-keymap-select because the ZLE parameter set is only installed for user-defined widgets. There's probably something more clever that could be done, particualarly with ZLE_STATE and with the conditional. The above is just an example. Incidentally you have to "fix" the keymap name etc. in zle-line-init as well as in zle-keymap-select. Maybe zle-keymap-select should be called just before (after?) zle-line-init, since the keymap is initialized at that time.