X.A.TopicSpace: remove the allTopics lists from the configuration.

This commit is contained in:
Nicolas Pouillard 2009-04-23 17:29:39 +00:00
parent cc7d2140b7
commit b60cdb60f0

View File

@ -10,30 +10,38 @@
-- --
-- Turns your workspaces into a more topic oriented system. -- Turns your workspaces into a more topic oriented system.
-- --
-- This module allow to organize your workspaces on a precise topic basis. So -- This module allows to organize your workspaces on a precise topic basis. So
-- instead of having a workspace called `work' you can setup one workspace per -- instead of having a workspace called `work' you can setup one workspace per
-- task. Here we will call these workspaces, topics. The great thing with -- task. Here we call these workspaces, topics. The great thing with
-- topics is that one can attach a directory that makes sense to each -- topics is that one can attach a directory that makes sense to each
-- particular topic. One can also attach an action that will be triggered -- particular topic. One can also attach an action which will be triggered
-- when switching to a topic that does not have any windows in it. So one can -- when switching to a topic that does not have any windows in it. So you can
-- attach our mail client to the mail topic, some terminals in the right -- attach your mail client to the mail topic, some terminals in the right
-- directory for the xmonad topic... This package also provides a nice way to -- directory to the xmonad topic... This package also provides a nice way to
-- display your topics in a historical way using a custom `pprWindowSet' -- display your topics in an historical way using a custom `pprWindowSet'
-- function. You can also easily switch to recents topics using this history -- function. You can also easily switch to recents topics using this history
-- of last focused topics. -- of last focused topics.
-- --
-- Here is an example of configuration using TopicSpace: -- Here is an example of configuration using TopicSpace:
-- --
-- @ -- @
-- -- The list of all topics/workspaces of your xmonad configuration.
-- -- The order is important, new topics must be inserted
-- -- at the end of the list if you want hot-restarting
-- -- to work.
-- myTopics :: [Topic]
-- myTopics =
-- [ \"dashboard\" -- the first one
-- , \"admin\", \"build\", \"cleaning\", \"conf\", \"darcs\", \"haskell\", \"irc\"
-- , \"mail\", \"movie\", \"music\", \"talk\", \"text\", \"tools\", \"web\", \"xmonad\"
-- , \"yi\", \"documents\", \"twitter\", \"pdf\"
-- ]
-- @
--
-- @
-- myTopicConfig :: TopicConfig -- myTopicConfig :: TopicConfig
-- myTopicConfig = TopicConfig -- myTopicConfig = TopicConfig
-- { allTopics = -- { topicDirs = M.fromList $
-- [ \"dashboard\" -- the first one
-- , \"admin\", \"build\", \"cleaning\", \"conf\", \"darcs\", \"haskell\", \"irc\"
-- , \"mail\", \"movie\", \"music\", \"talk\", \"text\", \"tools\", \"web\", \"xmonad\"
-- , \"yi\", \"documents\", \"twitter\", \"pdf\"
-- ]
-- , topicDirs = M.fromList $
-- [ (\"conf\", \"w\/conf\") -- [ (\"conf\", \"w\/conf\")
-- , (\"dashboard\", \"Desktop\") -- , (\"dashboard\", \"Desktop\")
-- , (\"yi\", \"w\/dev-haskell\/yi\") -- , (\"yi\", \"w\/dev-haskell\/yi\")
@ -117,11 +125,11 @@
-- --
-- @ -- @
-- myConfig = do -- myConfig = do
-- checkTopicConfig myTopicConfig -- checkTopicConfig myTopics myTopicConfig
-- myLogHook <- makeMyLogHook -- myLogHook <- makeMyLogHook
-- return $ defaultConfig -- return $ defaultConfig
-- { borderWidth = 1 -- Width of the window border in pixels. -- { borderWidth = 1 -- Width of the window border in pixels.
-- , workspaces = allTopics myTopicConfig -- , workspaces = myTopics
-- , layoutHook = myModifiers myLayouts -- , layoutHook = myModifiers myLayouts
-- , manageHook = myManageHook -- , manageHook = myManageHook
-- , logHook = myLogHook -- , logHook = myLogHook
@ -193,14 +201,7 @@ type Topic = WorkspaceId
type Dir = FilePath type Dir = FilePath
-- | Here is the topic space configuration area. -- | Here is the topic space configuration area.
data TopicConfig = TopicConfig { allTopics :: [Topic] data TopicConfig = TopicConfig { topicDirs :: M.Map Topic Dir
-- ^ You have to give a list of topics,
-- this must the be same list than the workspaces field of
-- your xmonad configuration.
-- The order is important, new topics must be inserted
-- at the end of the list if you want hot-restarting
-- to work.
, topicDirs :: M.Map Topic Dir
-- ^ This mapping associate a directory to each topic. -- ^ This mapping associate a directory to each topic.
, topicActions :: M.Map Topic (X ()) , topicActions :: M.Map Topic (X ())
-- ^ This mapping associate an action to trigger when -- ^ This mapping associate an action to trigger when
@ -280,15 +281,18 @@ currentTopicDir tg = do
return . fromMaybe "" . M.lookup topic $ topicDirs tg return . fromMaybe "" . M.lookup topic $ topicDirs tg
-- | Check the given topic configuration for duplicates topics or undefined topics. -- | Check the given topic configuration for duplicates topics or undefined topics.
checkTopicConfig :: TopicConfig -> IO () checkTopicConfig :: [Topic] -> TopicConfig -> IO ()
checkTopicConfig tg = do checkTopicConfig tags tg = do
unless (null diffTopic) $ xmessage $ "Seen but missing workspaces (tags): " ++ show diffTopic -- tags <- gets $ map W.tag . workspaces . windowset
unless (null dups) $ xmessage $ "Duplicate workspaces (tags): " ++ show dups
where let
seenTopics = nub $ sort $ M.keys (topicDirs tg) ++ M.keys (topicActions tg) seenTopics = nub $ sort $ M.keys (topicDirs tg) ++ M.keys (topicActions tg)
dups = tags \\ nub tags dups = tags \\ nub tags
diffTopic = seenTopics \\ sort tags diffTopic = seenTopics \\ sort tags
tags = allTopics tg check lst msg = unless (null lst) $ xmessage $ msg ++ " (tags): " ++ show lst
check diffTopic "Seen but missing topics/workspaces"
check dups "Duplicate topics/workspaces"
type StringProp = String type StringProp = String