[xmonad] silly behavior of killWord in XMonad.Prompt
Brent Yorgey
byorgey at seas.upenn.edu
Thu May 10 19:46:27 CEST 2012
OK, I just pushed this patch:
Thu May 10 13:43:17 EDT 2012 Brent Yorgey <byorgey at cis.upenn.edu>
* updates to XMonad.Prompt re: word-oriented commands
+ change killWord and moveWord to have emacs-like behavior: first
move past/kill consecutive whitespace, then move past/kill
consecutive non-whitespace.
+ create variants killWord' and moveWord' which take a predicate
specifying non-word characters.
+ create variants defaultXPKeymap' and emacsLikeXPKeymap' which
take the same sort of predicate, which is applied to all
keybindings with word-oriented commands.
My config now looks something like
myXPConfig = defaultXPConfig
{ fgColor = "#a8a3f7"
, bgColor = "#3f3c6d"
, promptKeymap = emacsLikeXPKeymap' myWordSep
}
myWordSep :: Char -> Bool
myWordSep c = isSpace c || c == '/'
Enjoy!
-Brent
On Tue, Apr 24, 2012 at 10:07:57AM -0400, Brent Yorgey wrote:
> 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
>
> _______________________________________________
> xmonad mailing list
> xmonad at haskell.org
> http://www.haskell.org/mailman/listinfo/xmonad
More information about the xmonad
mailing list