Skip to content

Commit 8efff53

Browse files
committed
X.P.OrgMode: More strictly enfore +s and +d ending with a space
Fixes: https://github.com/xmonad/xmonad-contrib/actions/runs/8772077289/job/24070588575
1 parent cab938f commit 8efff53

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

Diff for: XMonad/Prompt/OrgMode.hs

+2-2
Original file line numberDiff line numberDiff line change
@@ -514,8 +514,8 @@ ppNote clp todo = \case
514514
-- | Parse the given string into a 'Note'.
515515
pInput :: String -> Maybe Note
516516
pInput inp = (`runParser` inp) . choice $
517-
[ Scheduled <$> getLast "+s" <*> (Time <$> pDate <*> pOrgTime) <*> pPriority
518-
, Deadline <$> getLast "+d" <*> (Time <$> pDate <*> pOrgTime) <*> pPriority
517+
[ Scheduled <$> (getLast "+s" <* " ") <*> (Time <$> pDate <*> pOrgTime) <*> pPriority
518+
, Deadline <$> (getLast "+d" <* " ") <*> (Time <$> pDate <*> pOrgTime) <*> pPriority
519519
, do s <- munch1 (pure True)
520520
let (s', p) = splitAt (length s - 3) s
521521
pure $ case tryPrio p of

Diff for: tests/OrgMode.hs

+7
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ spec = do
6161
`shouldBe` Just (Scheduled "todo" (Time {date = Today, tod = Just $ MomentInTime(HHMM 12 0)}) NoPriority)
6262
pInput "todo +d 14:05 #B"
6363
`shouldBe` Just (Deadline "todo" (Time {date = Today, tod = Just $ MomentInTime(HHMM 14 5)}) B)
64+
it "parses `blah+d` and `blah +d` as normal messages, but `blah +d ` as a deadline for today" $ do
65+
pInput "blah+d"
66+
`shouldBe` Just (NormalMsg "blah+d" NoPriority)
67+
pInput "blah +d"
68+
`shouldBe` Just (NormalMsg "blah +d" NoPriority)
69+
pInput "blah +d "
70+
`shouldBe` Just (Deadline "blah" (Time {date = Today, tod = Nothing}) NoPriority)
6471

6572
context "no priority#b" $ do
6673
it "parses to the correct thing" $

0 commit comments

Comments
 (0)