From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2557 invoked by alias); 24 Jul 2016 06:42:07 -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: 38936 Received: (qmail 6924 invoked from network); 24 Jul 2016 06:42:07 -0000 X-Qmail-Scanner-Diagnostics: from nm23-vm1.bullet.mail.ir2.yahoo.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(212.82.97.16):SA:0(0.0/5.0):. Processed in 0.167957 secs); 24 Jul 2016 06:42:07 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM,SPF_PASS, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: okiddle@yahoo.co.uk X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.mail.yahoo.com designates 212.82.97.16 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1469342100; bh=CZxFJ3Lgzuj1pN0uDMayKRcYvB3HPfY2wSJOq7Xs8eE=; h=In-reply-to:From:References:To:Subject:Date:From:Subject; b=A9cbSNb51IipGnI9WkiDc8k4zKpCfThsv4xsTl+ztyfX+Yrv8IAI5uvRI+VEVO8mCKxPvvrDpKASYe3u4LpMGFP4/Ovop2itEzmAyJGq/dQrwnLAAEJ4U904fcs/mQjB1R2dSwC8d6Nt6IE+J+X1FYPGBnfX20yjgYoyr2i7Hbuz6DOFSzAmD3QYlYGLVenAWEHY04dd0nME39oFN0jWHCuAHLXbq/wHvCcBjMWYyRQ4qiVSHravT4gLMbQheBYWM+91mZcBpRHZZmuY+bu6xFW+1PqWKNvOoIQ9vA5piqvsZSKIPEsGnFWbxm6xl3EHXg4dmq3feo1aX996APBifg== X-Yahoo-Newman-Id: 425990.65212.bm@smtp115.mail.ir2.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: 9wu1AbAVM1lmphUeQV.amKIGTV4cbAxLMjsZe6QFUn.F6T_ VXLFXATNDUVo6PJcooxWJPleCwP48P.nHoCEDKVtKdWfg7KXeS0t338L6dU1 8.xCEGCefh6uMHf1ShfjS7qDpYX_UQ0Cr5q0TWEgha3nQ6IoaaDHxQkmI16Z cvbSolmaPjJjzDO2RWwLsrXDYqs1eJTzfNyYwvT6s.rzT68ZTBuaVkO6xWTJ LwYKVjB1YZGKyTo3.LNgXiIVNw2DHtW9qMqcyW_m2fMxwLA1w_YsQj6BBFUX IbaUtLALFaleeGddRUOTimqFO0Gj.sCEJ0RxCYXfxSEk6m4Jt0PvAl1GDw2q V.M1d_eqyhtcl5ltF7TIGVvqZinMUNq.hWFBgliNivSBLXN15eO9znm.kr_Q eYaGgiVfrMoA9BzSsE74IR9IylmJKFf.apHv.OIBPlMR.ALSKiWmIcTHDuDz 1QtVuQ7FAKqzpef7IKBbr9Lc7mlcq02doYnFGHCO07vidk1rZZKCVH2bRUwE L_76U1NHyNuE_h0iesewa3zdw0q_HZ6F.TLO0d2d4YkY- X-Yahoo-SMTP: opAkk_CswBAce_kJ3nIPlH80cJI- In-reply-to: <160629093320.ZM30674@torch.brasslantern.com> From: Oliver Kiddle References: <2679.1467125211@thecus.kiddle.eu> <160629093320.ZM30674@torch.brasslantern.com> To: Zsh workers Subject: PATCH: vi-pipe (Re: PATCH: vi-mode case-manipulation) MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <9286.1469342099.1@hydra.kiddle.eu> Date: Sun, 24 Jul 2016 08:34:59 +0200 Message-ID: <9287.1469342099@hydra.kiddle.eu> On 29 Jun, Bart wrote: > } I think there is some value in providing a shell widget example of how > } to read a vi movement. This includes vi-pipe which is like ! in vi. > > I think you've forgotten an "emulate zsh" or the like, since you're > referencing $REPLY and $CUTBUFFER un-quoted. (Sorry I didn't get to > this before you'd committed.) Is compatibility ok in the following? RHS of the CUTBUFFER assignment now has no outer quotes but I think that's ok as it is the rhs of an assignment. I also discovered the reason for having used vi-change followed by vi-cmd-mode in my original case conversion widgets instead of vi-delete - it has a subtle effect on cursor positioning. Though we've got a bug that vi-cmd-mode in the middle of a widget will act like a split-undo. Furthermore, ! in real vi forces the movement to act linewise. We can force this by ungetting a V before calling vi-change. I had thought ! a good example for a shell-based widget because I couldn't imagine anyone wanting mappings that make it a prefix so the lack if the VI_OPER flag wouldn't matter. It now occurs to me that noremap !o o!! and similarly for O is a useful shortcut. Zsh equivalent if you can type faster than KEYTIMEOUT is: bindkey -as '!o' $'o\e!!' Or maybe there's a better way to insert the output of a command in vim? Oliver diff --git a/Functions/Zle/vi-pipe b/Functions/Zle/vi-pipe index 2d2e295..028f1e1 100644 --- a/Functions/Zle/vi-pipe +++ b/Functions/Zle/vi-pipe @@ -7,16 +7,21 @@ # autoload -Uz vi-pipe # bindkey -a '!' vi-pipe +setopt localoptions noksharrays + autoload -Uz read-from-minibuffer local _save_cut="$CUTBUFFER" REPLY -# Use the standard vi-delete to accept a vi motion. -zle .vi-delete || return +# force movement to default to line mode +zle -U V +# Use the standard vi-change to accept a vi motion. +zle .vi-change || return read-from-minibuffer "!" +zle .vi-cmd-mode local _save_cur=$CURSOR # cut buffer contains the deleted text and can be modified -CUTBUFFER="$(eval $REPLY <<<$CUTBUFFER)" +CUTBUFFER=$(eval "$REPLY" <<<"$CUTBUFFER") # put the modified text back in position. if [[ CURSOR -eq 0 || $BUFFER[CURSOR] = $'\n' ]]; then