summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2021-05-24 18:16:24 +0100
committerjao <jao@gnu.org>2021-05-24 18:16:24 +0100
commit8e98908ba9b238861f71008857443aea1423edda (patch)
treed4073ad44538969d45a06f072e98813d1774c63b
parent9af7e4149a9b986ce127f809ef830a7c8e0318ec (diff)
parent8d0841012bd6745f2bfd951053c48cb1ecec62cf (diff)
downloadxmobar-8e98908ba9b238861f71008857443aea1423edda.tar.gz
xmobar-8e98908ba9b238861f71008857443aea1423edda.tar.bz2
Merge branch 'notmuchmail-fix' [#548]
-rw-r--r--doc/plugins.org12
-rw-r--r--src/Xmobar/Plugins/NotmuchMail.hs17
-rw-r--r--src/Xmobar/Run/Types.hs3
3 files changed, 17 insertions, 15 deletions
diff --git a/doc/plugins.org b/doc/plugins.org
index 76b4796..2510cb5 100644
--- a/doc/plugins.org
+++ b/doc/plugins.org
@@ -911,18 +911,6 @@ something like:
]
#+end_src
- or, using explicit record syntax:
-
- #+begin_src haskell
- [ MailItem
- { name = "name"
- , address = "address"
- , query = "query"
- }
- ...
- ]
- #+end_src
-
where
- =name= is what gets printed in the status bar before the number of
diff --git a/src/Xmobar/Plugins/NotmuchMail.hs b/src/Xmobar/Plugins/NotmuchMail.hs
index 3da170c..3604a11 100644
--- a/src/Xmobar/Plugins/NotmuchMail.hs
+++ b/src/Xmobar/Plugins/NotmuchMail.hs
@@ -39,6 +39,7 @@ import Control.Concurrent.Async (mapConcurrently)
import Data.Maybe (catMaybes)
import System.Exit (ExitCode(ExitSuccess))
import System.Process (readProcessWithExitCode)
+import Text.Read (Lexeme(Ident), ReadPrec, lexP, parens, prec, readPrec, reset)
-- | A 'MailItem' is a name, an address, and a query to give to @notmuch@.
@@ -48,7 +49,13 @@ data MailItem = MailItem
-- the empty string to query all indexed mail instead
, query :: String -- ^ Query to give to @notmuch search@
}
- deriving (Read, Show)
+ deriving (Show)
+
+instance Read MailItem where
+ readPrec :: ReadPrec MailItem
+ readPrec = parens . prec 11 $ do
+ Ident "MailItem" <- lexP
+ MailItem <$> reset readPrec <*> reset readPrec <*> reset readPrec
-- | A full mail configuration.
data NotmuchMail = NotmuchMail
@@ -56,7 +63,13 @@ data NotmuchMail = NotmuchMail
, mailItems :: [MailItem] -- ^ 'MailItem's to check
, nmRate :: Int -- ^ Update frequency (in deciseconds)
}
- deriving (Read, Show)
+ deriving (Show)
+
+instance Read NotmuchMail where
+ readPrec :: ReadPrec NotmuchMail
+ readPrec = parens . prec 11 $ do
+ Ident "NotmuchMail" <- lexP
+ NotmuchMail <$> reset readPrec <*> reset readPrec <*> reset readPrec
-- | How to execute this plugin.
instance Exec NotmuchMail where
diff --git a/src/Xmobar/Run/Types.hs b/src/Xmobar/Run/Types.hs
index f4a7252..deec8ba 100644
--- a/src/Xmobar/Run/Types.hs
+++ b/src/Xmobar/Run/Types.hs
@@ -30,6 +30,7 @@ import Xmobar.Plugins.XMonadLog
import Xmobar.Plugins.EWMH
import Xmobar.Plugins.Kbd
import Xmobar.Plugins.Locks
+import Xmobar.Plugins.NotmuchMail
#ifdef INOTIFY
import Xmobar.Plugins.Mail
@@ -54,7 +55,7 @@ infixr :*:
-- this function's type signature.
runnableTypes :: Command :*: Monitors :*: Date :*: PipeReader :*:
BufferedPipeReader :*: CommandReader :*: StdinReader :*:
- XMonadLog :*: EWMH :*: Kbd :*: Locks :*:
+ XMonadLog :*: EWMH :*: Kbd :*: Locks :*: NotmuchMail :*:
#ifdef INOTIFY
Mail :*: MBox :*:
#endif