From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5455 invoked by alias); 29 Jan 2014 03:00:01 -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: 32315 Received: (qmail 3047 invoked from network); 29 Jan 2014 02:59:54 -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 From: Bart Schaefer Message-id: <140128185946.ZM21512@torch.brasslantern.com> Date: Tue, 28 Jan 2014 18:59:46 -0800 In-reply-to: <2700.1390950035@thecus.kiddle.eu> Comments: In reply to Oliver Kiddle "Re: zle: vi mode: wrong undo handling on fresh lines" (Jan 29, 12:00am) References: <20130923213014.15f97f9e@pws-pc.ntlworld.com> <3511.1390605547@thecus.kiddle.eu> <140125111530.ZM21792@torch.brasslantern.com> <20140127124301.4144f2d9@pwslap01u.europe.root.pri> <20140127161124.2aa16b37@pwslap01u.europe.root.pri> <2700.1390950035@thecus.kiddle.eu> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: Re: zle: vi mode: wrong undo handling on fresh lines MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Jan 29, 12:00am, Oliver Kiddle wrote: } Subject: Re: zle: vi mode: wrong undo handling on fresh lines } } A non-blank starting line is possible with at least } accept-line-and-down-history and vi-push-input. In such cases, it } depends on the cursor position. If the cursor starts at the } beginning of the line then 'i' makes more sense. } } > Is it OK to assume we're not in insert mode when vi-repeat is executed? } } Yes. Of course someone can bind a key to the widget but that currently } just beeps which is fine. Actually it does more than beep; with -- bindkey -M viins '#' vi-repeat-change bindkey -v -- type (whitespace added for clarity) xxx ESC a yyy # and you end up with xxxyyya because # has repeated the "a" keystroke. The yyy hasn't yet been added to the change buffer, so that doesn't get repeated. If you keep trying to use # from insert-mode (prior to the patch in 32308), eventually it'll insert a "#", repeat carriage-return and accept the buffer, probably resulting in a command-not-found. } How about the following approach to the undo problem: } The variable undoing was serving as a flag to indicate whether each } change should be added as an undo event. In vi-mode this would be } skipped so that the whole vi change became a single undo change. What } this does is remove that handling and instead merge all the undo events } corresponding to the vi change in the vi-cmd-mode widget. This sounds fine to me, and wouldn't have been possible prior to the numbering of undo events. Is there a well-defined place where a user defined widget could read $UNDO_CHANGE_NO and be sure it was the same as the internal vistartchange value? } Are there other ways to get into vi command mode besides vi-cmd-mode } that might get around this? One doc example for zle-line-init still implies you can get into vi command mode by "zle -K vicmd". (This even moves one character left when switching from viins to vicmd; I'm not sure how/where the code that does that is being called.)