From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7497 invoked by alias); 30 Jan 2014 15:26:40 -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: 32324 Received: (qmail 19982 invoked from network); 30 Jan 2014 15:26:24 -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-Biglobe-Sender: Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 7.1 \(1827\)) Subject: Re: zle: vi mode: wrong undo handling on fresh lines From: "Jun T." In-Reply-To: <2700.1390950035@thecus.kiddle.eu> Date: Thu, 30 Jan 2014 23:51:10 +0900 Content-Transfer-Encoding: quoted-printable Message-Id: 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> To: zsh-workers@zsh.org X-Mailer: Apple Mail (2.1827) This is my "trial" to (somewhat) improve the behavior of 'undo' after = completion. The patch below is against (git-HEAD)+(patch in 32314 by Oliver Kiddle). The change in zle_tricky.c is to start a new undo-block when entering a completion. The change in zle_main.c is to make 'undo' no to bring back the suffix = added by completion but erased when going back to the command mode. (This will also change the behavior in emacs-mode.) Or these are just matter of preference and must not be hard-coded but configurable? diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c index f5aec84..72650a8 100644 --- a/Src/Zle/zle_main.c +++ b/Src/Zle/zle_main.c @@ -1332,8 +1332,10 @@ execzlefunc(Thingy func, char **args, int = set_bindk) eofsent =3D 1; ret =3D 1; } else { - if(!(wflags & ZLE_KEEPSUFFIX)) + if(!(wflags & ZLE_KEEPSUFFIX)) { removesuffix(); + handleundo(); + } if(!(wflags & ZLE_MENUCMP)) { fixsuffix(); invalidatelist(); diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c index 2689d0f..49dae8a 100644 --- a/Src/Zle/zle_tricky.c +++ b/Src/Zle/zle_tricky.c @@ -673,6 +673,9 @@ docomplete(int lst) * an emulation. = */ if (viinsbegin > ztrsub(zlemetaline + wb, zlemetaline)) viinsbegin =3D ztrsub(zlemetaline + wb, zlemetaline); + /* finish the current undo block and start a new one */ + vimergeundo(); + vistartchange =3D (curchange && curchange->prev) ? = curchange->prev->changeno : 0; /* If we added chline to the line buffer, reset the original = contents. */ if (ol) { zlemetacs -=3D chl; diff --git a/Src/Zle/zle_vi.c b/Src/Zle/zle_vi.c index 9e9cc2f..e6c10a1 100644 --- a/Src/Zle/zle_vi.c +++ b/Src/Zle/zle_vi.c @@ -112,6 +112,19 @@ startvitext(int im) } =20 /**/ +void +vimergeundo(void) +{ + struct change *current =3D curchange->prev; + while (current && current->changeno > vistartchange+1) { + current->flags |=3D CH_PREV; + current =3D current->prev; + if (!current) break; + current->flags |=3D CH_NEXT; + } +} + +/**/ ZLE_INT_T vigetkey(void) { @@ -584,13 +597,7 @@ vicmdmode(UNUSED(char **args)) { if (invicmdmode() || selectkeymap("vicmd", 0)) return 1; - struct change *current =3D curchange->prev; - while (current && current->changeno > vistartchange+1) { - current->flags |=3D CH_PREV; - current =3D current->prev; - if (!current) break; - current->flags |=3D CH_NEXT; - } + vimergeundo(); vichgflag =3D 0; if (zlecs !=3D findbol()) DECCS();