[xmonad] silly behavior of killWord in XMonad.Prompt

Aleksandar Dimitrov aleks.dimitrov at googlemail.com
Wed Apr 25 09:21:51 CEST 2012


> I realized today that the behavior of killWord from XMonad.Prompt is
> surprising to me.  In particular, when you iterate killWord, it
> deletes first a word, then a space, then the next word, then the next
> space, and so on.  I (an emacs user) expect killWord to delete a word
> AND any whitespace that happens to come before it.  (Hmm... I tested
> with vim and it seems that 'dw' deletes a word along with any TRAILING
> whitespace.  So emacs and vim differ here... but the point is that
> killWord emulates neither.)

Vim in insert mode acts like Emacs if you hit ^W, which, I think is more
relevant here, since you're in "insert mode" when using XPrompt (just like when
you use ex-mode in Vim after hitting ':') and there's no "command mode."

> diff -rN old-XMonadContrib/XMonad/Prompt.hs
> new-XMonadContrib/XMonad/Prompt.hs
> 525,528c525
> <       delNextWord w =
> <           case w of
> <             ' ':x -> x
> <             word  -> snd . break isSpace $ word
> ---
> >       delNextWord   = snd . break isSpace . dropWhile isSpace
> 
> 
> Thoughts?  

As others have said, dropping in a parameter for isSpace would be nice, or at
least making it something like:

> liftM2 (||) isSpace (=='/')

One of my reasons for switching to zsh was that when I had punched in a long
path and made a mistake in the last segment of it, I might hit ^W, but then bash
deletes the entire path with no possibility of undo! zsh only deletes up to the
'/', which I prefer greatly.

Cheers,
Aleks



More information about the xmonad mailing list