zsh-users
 help / color / mirror / code / Atom feed
* Delete everything to the left until next whitespace?
@ 2011-02-10 20:25 Richard Hartmann
  2011-02-10 20:52 ` Peter Stephenson
  0 siblings, 1 reply; 7+ messages in thread
From: Richard Hartmann @ 2011-02-10 20:25 UTC (permalink / raw)
  To: zsh-users

Hi all,

I am after something that _should_ be do-able, but somehow, the
solution eludes me.

I want to delete to the next whitespace on the left. If I am directly
to the right of one or more whitespaces, they should all be deleted.
With | being the cursor and ^ew being the keybinding for the function
I am after, examples would look like this:


% foo bar baz \!;\'a!a:          |^ew
% foo bar baz \!;\'a!a:|^ew
% foo bar baz |^ew
% foo bar baz|^ew
% foo bar |^ew
% foo bar|

% foo bar |^ew baz
% foo bar|^ew baz
% foo | baz

None of this should be affected by $WORDCHARS, only by whitespace.


Thanks for any and all suggestions,
Richard


PS: Other blank/non-printable characters should probably be deleted by
this, as well.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Delete everything to the left until next whitespace?
  2011-02-10 20:25 Delete everything to the left until next whitespace? Richard Hartmann
@ 2011-02-10 20:52 ` Peter Stephenson
  2011-02-10 21:43   ` René 'Necoro' Neumann
  2011-02-10 22:14   ` Richard Hartmann
  0 siblings, 2 replies; 7+ messages in thread
From: Peter Stephenson @ 2011-02-10 20:52 UTC (permalink / raw)
  To: zsh-users

On Thu, 10 Feb 2011 21:25:54 +0100
Richard Hartmann <richih.mailinglist@gmail.com> wrote:
> I want to delete to the next whitespace on the left.

autoload -U backward-kill-word-match
zle -N backward-kill-word-space backward-kill-word-match 
zstyle ':zle:backward-kill-word-space' word-style space
bindkey '^ew' backward-kill-word-space

See zshcontrib.

-- 
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Delete everything to the left until next whitespace?
  2011-02-10 20:52 ` Peter Stephenson
@ 2011-02-10 21:43   ` René 'Necoro' Neumann
  2011-02-10 22:14     ` Richard Hartmann
  2011-02-10 22:14   ` Richard Hartmann
  1 sibling, 1 reply; 7+ messages in thread
From: René 'Necoro' Neumann @ 2011-02-10 21:43 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 555 bytes --]

Am 10.02.2011 21:52, schrieb Peter Stephenson:
> On Thu, 10 Feb 2011 21:25:54 +0100
> Richard Hartmann <richih.mailinglist@gmail.com> wrote:
>> I want to delete to the next whitespace on the left.
> 
> autoload -U backward-kill-word-match
> zle -N backward-kill-word-space backward-kill-word-match 
> zstyle ':zle:backward-kill-word-space' word-style space
> bindkey '^ew' backward-kill-word-space
> 
> See zshcontrib.
> 

There isn't a difference in behavior to normal
backward-kill-word, is there? (At least I can't see one)

- René


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Delete everything to the left until next whitespace?
  2011-02-10 20:52 ` Peter Stephenson
  2011-02-10 21:43   ` René 'Necoro' Neumann
@ 2011-02-10 22:14   ` Richard Hartmann
  1 sibling, 0 replies; 7+ messages in thread
From: Richard Hartmann @ 2011-02-10 22:14 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: zsh-users

On Thu, Feb 10, 2011 at 21:52, Peter Stephenson
<p.w.stephenson@ntlworld.com> wrote:

> autoload -U backward-kill-word-match
> zle -N backward-kill-word-space backward-kill-word-match
> zstyle ':zle:backward-kill-word-space' word-style space
> bindkey '^ew' backward-kill-word-space

Thanks for that, I am not sure how I could miss it as it's in plain sight...

That does not handle deletion as I'd like, i.e. this does not work:

% foo bar baz |^ew
% foo bar baz|^ew

but results in

% foo bar baz |^ew
% foo bar |^ew

but this is more than adequate. Thanks :)


Richard


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Delete everything to the left until next whitespace?
  2011-02-10 21:43   ` René 'Necoro' Neumann
@ 2011-02-10 22:14     ` Richard Hartmann
  2011-02-10 22:26       ` René 'Necoro' Neumann
  0 siblings, 1 reply; 7+ messages in thread
From: Richard Hartmann @ 2011-02-10 22:14 UTC (permalink / raw)
  To: René 'Necoro' Neumann; +Cc: zsh-users

On Thu, Feb 10, 2011 at 22:43, René 'Necoro' Neumann <lists@necoro.eu> wrote:

> There isn't a difference in behavior to normal
> backward-kill-word, is there? (At least I can't see one)

It hangs on

foo bar baz \!;\'a!a:          |^ew

at least for me.


Richard


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Delete everything to the left until next whitespace?
  2011-02-10 22:14     ` Richard Hartmann
@ 2011-02-10 22:26       ` René 'Necoro' Neumann
  2011-02-11 19:51         ` Peter Stephenson
  0 siblings, 1 reply; 7+ messages in thread
From: René 'Necoro' Neumann @ 2011-02-10 22:26 UTC (permalink / raw)
  To: Richard Hartmann, Zsh Users

[-- Attachment #1: Type: text/plain, Size: 482 bytes --]

Am 10.02.2011 23:14, schrieb Richard Hartmann:
> On Thu, Feb 10, 2011 at 22:43, René 'Necoro' Neumann <lists@necoro.eu> wrote:
> 
>> There isn't a difference in behavior to normal
>> backward-kill-word, is there? (At least I can't see one)
> 
> It hangs on
> 
> foo bar baz \!;\'a!a:          |^ew
> 
> at least for me.

Ah - thanks for the hint. An even easier case is already:

foo bar 'baz'  |^W
--> foo bar '|

foo bar 'baz'  |^ew
--> foo bar |

- René


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Delete everything to the left until next whitespace?
  2011-02-10 22:26       ` René 'Necoro' Neumann
@ 2011-02-11 19:51         ` Peter Stephenson
  0 siblings, 0 replies; 7+ messages in thread
From: Peter Stephenson @ 2011-02-11 19:51 UTC (permalink / raw)
  To: Zsh Users

On Thu, 10 Feb 2011 23:26:56 +0100
René 'Necoro' Neumann <lists@necoro.eu> wrote:

> Am 10.02.2011 23:14, schrieb Richard Hartmann:
> > On Thu, Feb 10, 2011 at 22:43, René 'Necoro' Neumann <lists@necoro.eu> wrote:
> > 
> >> There isn't a difference in behavior to normal
> >> backward-kill-word, is there? (At least I can't see one)
> > 
> > It hangs on
> > 
> > foo bar baz \!;\'a!a:          |^ew
> > 
> > at least for me.
> 
> Ah - thanks for the hint. An even easier case is already:
> 
> foo bar 'baz'  |^W
> --> foo bar '|
> 
> foo bar 'baz'  |^ew
> --> foo bar |

I'm not quite sure what you're claiming, but if enter the following
after zsh -f it seems to be working fine here with the latest source
code and the command lines above.  I don't think you've got the style
set in those last examples, but I tried again without that and, though
obviously the behaviour is different, it didn't seem wrong.

autoload -U backward-kill-word-match
zle -N backward-kill-word-space backward-kill-word-match 
zstyle ':zle:backward-kill-word-space' word-style space
bindkey '^ew' backward-kill-word-space

By the way, if you're using the word context feature (I bet not many
people are), you'll need the pattern

zstyle ':zle:backward-kill-word-space*' word-style space

That's my fault for not adding the colon and telling people to use ':*'
from the outset.

-- 
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-02-11 19:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-10 20:25 Delete everything to the left until next whitespace? Richard Hartmann
2011-02-10 20:52 ` Peter Stephenson
2011-02-10 21:43   ` René 'Necoro' Neumann
2011-02-10 22:14     ` Richard Hartmann
2011-02-10 22:26       ` René 'Necoro' Neumann
2011-02-11 19:51         ` Peter Stephenson
2011-02-10 22:14   ` Richard Hartmann

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).