Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: This widget implementation feels a bit clunky (edit-quoted-word)
- X-seq: zsh-workers 35559
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- Subject: Re: This widget implementation feels a bit clunky (edit-quoted-word)
- Date: Mon, 22 Jun 2015 04:26:07 +0200
- Cc: zsh workers <zsh-workers@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=OCcb0FzOcfVXL+1c2A+mUNwTU73kdtusT28zPEMvtHE=; b=sa0pysKIXMqkRZEFuLOcfvq1bsvnlGQwT/AoIykoZo6JV4HJ1lqPM+gPHW/+KFAo8E W5J7xzuOtW8RT8PLh1p3peuSdePtr+7PpUH4DMRO79hoeLHN2eo9WypK38VQ8wibdbtI YI/EB3LqieN+VGHcGoM9QXj04Gi7rRO7j3pFYYJCsw7X+VHabAjNtolq/oBhBFUZ6skE bf1NkSbddX5YKETtehufWHb3skjGY+ABlztSuEchWBpS0Syi65xr+0UuRC3GuYG06845 WLHJ8Rg4PGGPdakOS9YZ53s5ou7DXpTCrpdBPnYUBcwziLcvkOWs6iVtxUXTVWb+Hcb6 0K9w==
- In-reply-to: <20150621181740.522742c8@ntlworld.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CAHYJk3RYUhLuQEvGWLF5sdAK-g=MpiJwV0x-UrfQ35e3r4dHAg@mail.gmail.com> <20150620180659.735a6cc6@ntlworld.com> <CAHYJk3T3VmT3gAEkzpUJ=WPcqVDNWT8OCD9WqD=ddUFTbPigyA@mail.gmail.com> <20150621181740.522742c8@ntlworld.com>
On Sun, Jun 21, 2015 at 7:17 PM, Peter Stephenson
<p.w.stephenson@xxxxxxxxxxxx> wrote:
> On Sun, 21 Jun 2015 09:09:29 +0200
> Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
>> On Sat, Jun 20, 2015 at 7:06 PM, Peter Stephenson
>> <p.w.stephenson@xxxxxxxxxxxx> wrote:
>> > On Sat, 20 Jun 2015 11:16:20 +0200
>> > Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
>> >> I feel like it's unnecessarily hard to get the resulting text from a
>> >> narrow-to-region session.
>> >
>> > Would you want something like this?
>>
>> That does look very promising, yeah. :)
>> I suppose I should volunteer for writing the doc patch for this.
>
> I've remembered to commit it on the master branch.
This feels more reasonable now (some of the improvements might be
applied to the previous version too, so not an entirely fair
comparison), (the business with the :+ is because if you delete the
whole string, ${(q-)lbuf} when lbuf is empty results in '', and so
does rbuf, thus concatenated to '''' which with rc_quotes enabled
leaves a single ' that should not be there).
function _edit_quoted_word()
{
local -a reply
local REPLY REPLY2 len left right lbuf rbuf
_split_shell_arguments_intuitive
left=${(j::)reply[1,REPLY-1]}
right=${(j::)reply[REPLY+1,-1]}
(( CURSOR-=$#left ))
BUFFER=${(Q)reply[REPLY]}
REGION_ACTIVE=0
narrow-to-region -l lbuf -r rbuf -p "$left>>|" -P "|<<$right" 0 $#BUFFER
LBUFFER=$left${lbuf:+${(q-)lbuf}}
RBUFFER=${rbuf:+${(q-)rbuf}}$right
}
zle -N _edit_quoted_word
bindkey '^_q' _edit_quoted_word
autoload -U split-shell-arguments
function _split_shell_arguments_intuitive()
{
split-shell-arguments
# borrowed logic from modify-current-argument to get word under cursor
(( REPLY > 1 && REPLY & 1 )) && (( REPLY-- ))
}
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author