mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-09-02 04:03:47 -07:00
XPrompt.hs: use a single blank
Excessive blanks in prompts originate from here. Eliminate. :) Rewrite `getLastWord' and `skipLastWord' in pointfree style.
This commit is contained in:
@@ -120,7 +120,7 @@ instance XPrompt XPType where
|
|||||||
-- This is an example of a XPrompt instance definition:
|
-- This is an example of a XPrompt instance definition:
|
||||||
--
|
--
|
||||||
-- > instance XPrompt Shell where
|
-- > instance XPrompt Shell where
|
||||||
-- > showXPrompt Shell = "Run: "
|
-- > showXPrompt Shell = "Run: "
|
||||||
class XPrompt t where
|
class XPrompt t where
|
||||||
showXPrompt :: t -> String
|
showXPrompt :: t -> String
|
||||||
|
|
||||||
@@ -667,14 +667,12 @@ splitInSubListsAt i x = f : splitInSubListsAt i rest
|
|||||||
-- | Gets the last word of a string or the whole string if formed by
|
-- | Gets the last word of a string or the whole string if formed by
|
||||||
-- only one word
|
-- only one word
|
||||||
getLastWord :: String -> String
|
getLastWord :: String -> String
|
||||||
getLastWord str =
|
getLastWord = reverse . fst . breakAtSpace . reverse
|
||||||
reverse . fst . breakAtSpace . reverse $ str
|
|
||||||
|
|
||||||
-- | Skips the last word of the string, if the string is composed by
|
-- | Skips the last word of the string, if the string is composed by
|
||||||
-- more then one word. Otherwise returns the string.
|
-- more then one word. Otherwise returns the string.
|
||||||
skipLastWord :: String -> String
|
skipLastWord :: String -> String
|
||||||
skipLastWord str =
|
skipLastWord = reverse . snd . breakAtSpace . reverse
|
||||||
reverse . snd . breakAtSpace . reverse $ str
|
|
||||||
|
|
||||||
breakAtSpace :: String -> (String, String)
|
breakAtSpace :: String -> (String, String)
|
||||||
breakAtSpace s
|
breakAtSpace s
|
||||||
|
Reference in New Issue
Block a user