From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8481 invoked by alias); 21 Jun 2016 23:17:07 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 21689 Received: (qmail 5738 invoked from network); 21 Jun 2016 23:17:06 -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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1466550648; bh=otXEfvkMBl9h+A1F3AmWvPXnbTbJEqn6Da566+lqeso=; h=cc:In-reply-to:From:References:To:Subject:Date:From:Subject; b=OD7jB3iYVVOBpo4/6lnqd2YXaV7CWulC2ShDDJWWC8psg4iAtXCI2wYQmHe9IgFfmt+yLhoCZxUyb/2iaIUo0Ed9fujbsbcpvZmRxFfaoLbfBIicteF1wXoFKiU0O8VlPqyKLgq2X472J91OHtfAA/bdazmbFSCjBvrmx9wDEk9eibtTKN0xcSccih7esmo6AToo3WCjbVFlUohKduNCRDTwMSfser4x4GLhAaRH5fpgo2saCF5CxR2HD2b7HKW4YuC3YzmM3lFJzkl5/zB0xPAkoBrHV9wedOmYImxDqecbpl+nKvmpj0EA6qyoY2RC8RzNXv6FHJHL5HUroFd8bg== X-Yahoo-Newman-Id: 731312.15329.bm@smtp132.mail.ir2.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: oAmYhC8VM1lrYdGOEeE7AqWuOJZIzbva6zU0d81fXDkgMle 6Vt4pIzI7x9fX.y6DkRqN2OFUMCJc16n6j0qq3yH4s4ATdc.YUqC1gjNT6jW l_oYbD8fs1uv9nIL_bMKafKGEmwT19uUnJieH3TaTVteEHo42tSi0UxKOFHu 92oXGnlUSWkdLOgAxjuLPRqVxdfjSRCe4W6B9.L5lK3CvG6lxiywKff2OGv7 6ZGdpzEtPx8AXwivV6kZYLo2Tn5OyD0QBJ7nypUnXkMayxzvMUtiAcwghpwe U27L6Cjd9afdUQsctyajIM.ggXGXsBKbbvmBOXUdFUIFn5ZZi1naIdnCXzZD aeATTOzsn2XFEXszK7NCVbL5f_inESuQsqjtRtE85IJ3vlh9IVSzOdCmDsOm 1m6iXvZnNdjlgU0X7xkjqXopQHPSYVTmk.USBEJWbWfvAAPJUUh9FmXpVtJz u4aVgP3.9KB__B7c9hWACqnikeFpA2jzcUkcOWzykzE5RAaXepL1lPWPrtmc 9tu_WSTuCf.zJhdA6L_Y.uqqve24pJA-- X-Yahoo-SMTP: opAkk_CswBAce_kJ3nIPlH80cJI- cc: zsh-users@zsh.org In-reply-to: From: Oliver Kiddle References: To: Filipe Silva Subject: Re: [vi-mode] widgets for case manipulation: `gU` and `U` in visual mode MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <21996.1466550647.1@thecus.kiddle.eu> Date: Wed, 22 Jun 2016 01:10:47 +0200 Message-ID: <21997.1466550647@thecus.kiddle.eu> Filipe Silva wrote: > > I reckon there's already a widget for the `g~` action in zle. Yes, vi-oper-swap-case > I read the zshzle manual and did not find a widget that would give me the > behaviour of `gU` (capitalize action) I use the following custom widgets. Perhaps these should be included somehow - any thoughts? It might be easiest in C because with included widgets you still need zle -N and bindkeys in your .zshrc. > Is this a matter of writing a custom widget, or would one have to submit a > patch upstream with c code changes? I'm asking this because 5.0.8 > introduced text objects and that was done via c code changes and not via > widgets. And writing custom widgets seems to be less difficult. Some of the text objects were done via shell widgets - select-quoted and select-bracketed which select text between delimiters. This does mean you have to enable them yourself. At first, I had hoped they would serve as examples of how to do text object widgets but they ended up being quite complex once vim compatibility for odd cases was considered. So maybe they should be converted to C? Oliver vi-lowercase() { local save_cut="$CUTBUFFER" save_cur="$CURSOR" zle .vi-change || return zle .vi-cmd-mode CUTBUFFER="${CUTBUFFER:l}" zle .vi-put-after -n 1 CUTBUFFER="$save_cut" CURSOR="$save_cur" } vi-uppercase() { local save_cut="$CUTBUFFER" save_cur="$CURSOR" zle .vi-change || return zle .vi-cmd-mode CUTBUFFER="${CUTBUFFER:u}" zle .vi-put-after -n 1 CUTBUFFER="$save_cut" CURSOR="$save_cur" } zle -N vi-lowercase zle -N vi-uppercase bindkey -a 'gU' vi-uppercase bindkey -a 'gu' vi-lowercase bindkey -M visual 'u' vi-lowercase bindkey -M visual 'U' vi-uppercase