[xmonad] silly behavior of killWord in XMonad.Prompt
Brent Yorgey
byorgey at seas.upenn.edu
Tue Apr 24 16:07:57 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.)
I looked into it and it turns out that the behavior of killWord is
even sillier than I thought. It deletes an entire word of
non-whitespace characters *or a single space*. (So if there are
multiple spaces you have to call killWord once for each space before
you finally get to delete the word that comes after.) And if the next
character is a tab it doesn't delete anything at all!
For concreteness, here's the change I made:
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? If anyone really likes the old behavior then I can make two
versions. Or if there is consensus that the old behavior is silly and
the new behavior is better, then I'll just push the above change. I
could also be talked into swapping the order of the break and
dropWhile in order to emulate vim; I don't really care as long as it's
one of the two.
-Brent
More information about the xmonad
mailing list