aboutsummaryrefslogtreecommitdiffstats
path: root/XMonad
diff options
context:
space:
mode:
authorAdam Vogt <vogt.adam@gmail.com>2010-04-21 20:30:06 +0200
committerAdam Vogt <vogt.adam@gmail.com>2010-04-21 20:30:06 +0200
commit8012d2fccf769261e047b34b4d3e60c155462b14 (patch)
treec1425de62ef0565579979c6afef62ac3dbe1a216 /XMonad
parent1f2f6239a5d942d2cd0f06aeec2d96ab05980600 (diff)
downloadXMonadContrib-8012d2fccf769261e047b34b4d3e60c155462b14.tar.gz
XMonadContrib-8012d2fccf769261e047b34b4d3e60c155462b14.tar.xz
XMonadContrib-8012d2fccf769261e047b34b4d3e60c155462b14.zip
Prompt: handle case of historySize
Ignore-this: e4a74e905677649ddde36385a9ed47a2 darcs-hash:20100421183006-1499c-b6fb3d6eea1e1c519173bf07346c100b2b5557cb.gz
Diffstat (limited to 'XMonad')
-rw-r--r--XMonad/Prompt.hs11
1 files changed, 7 insertions, 4 deletions
diff --git a/XMonad/Prompt.hs b/XMonad/Prompt.hs
index 951f9ad..53ec2e5 100644
--- a/XMonad/Prompt.hs
+++ b/XMonad/Prompt.hs
@@ -293,10 +293,11 @@ mkXPromptWithReturn t conf compl action = do
io $ freeGC d gc
if successful st'
then do
+ let prune = take (historySize conf)
io $ writeHistory $ M.insertWith
- (\xs ys -> take (historySize conf)
- . historyFilter conf $ xs ++ ys)
- (showXPrompt t) (historyFilter conf [command st'])
+ (\xs ys -> prune . historyFilter conf $ xs ++ ys)
+ (showXPrompt t)
+ (prune $ historyFilter conf [command st'])
hist
-- we need to apply historyFilter before as well, since
-- otherwise the filter would not be applied if
@@ -768,7 +769,9 @@ readHistory = readHist `catch` \(SomeException _) -> return emptyHistory
writeHistory :: History -> IO ()
writeHistory hist = do
path <- getHistoryFile
- writeFile path (show hist) `catch` \(SomeException _) -> hPutStrLn stderr "error in writing"
+ let filtered = M.filter (not . null) hist
+ writeFile path (show filtered) `catch` \(SomeException e) ->
+ hPutStrLn stderr ("error writing history: "++show e)
setFileMode path mode
where mode = ownerReadMode .|. ownerWriteMode