Subject: Re: backward-kill-shell-word widget
From: Daniel Shahaf <[email-masked]>
To: Bart Schaefer <[email-masked]>
Cc: [email-masked]
Date: Sun, 10 Jan 2016 19:53:23 +0000
List-Id: Zsh Workers List <zsh-workers.zsh.org>

Bart Schaefer wrote on Sun, Jan 10, 2016 at 09:17:44 -0800:
> On Jan 1, 12:37am, Daniel Shahaf wrote:
> }
> } This widget is like ^W but for "shell words" rather than
> } whitespace-separated words, so
> } 
> }     % echo foo "bar baz" <CURSOR>^W
> }     becomes
> }     % echo foo <CURSOR>
> 
> As of 5.0.8 you can do this with:
> 
>     backward-kill-shell-word() {
>       zle select-in-shell-word
>       ((++CURSOR))  # adjust for vi vs. emacs region
>       zle kill-region

I'd add:
        LBUFFER+=" "

Without that, LBUFFER[-1] after the widget is the last character of the
preceding word.

>     }
> 
> I'm not sure if that CURSOR adjustment is a a bug or just a necessary
> evil because of using vi binding in the emacs keymap.

Thanks for the additional solution!