From cd95bf9c28e1fdfa43b2940377690d90deb56e74 Mon Sep 17 00:00:00 2001 From: Tony Zorman Date: Mon, 3 Oct 2022 21:22:03 +0200 Subject: [PATCH] X.P.OrgMode: Return "exitCode" mkOrgPrompt More formally, return whether the user cancelled the prompt or not. This is useful in case we want to do things only after a "successful" input. --- XMonad/Prompt/OrgMode.hs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/XMonad/Prompt/OrgMode.hs b/XMonad/Prompt/OrgMode.hs index c91d47a8..d83eb979 100644 --- a/XMonad/Prompt/OrgMode.hs +++ b/XMonad/Prompt/OrgMode.hs @@ -202,7 +202,7 @@ orgPrompt -- a single @*@ -> FilePath -- ^ Path to @.org@ file, e.g. @home\/me\/todos.org@ -> X () -orgPrompt xpc = (mkOrgPrompt xpc =<<) .: mkOrgCfg NoClpSupport +orgPrompt xpc = (void . mkOrgPrompt xpc =<<) .: mkOrgCfg NoClpSupport -- | Like 'orgPrompt', but additionally make use of the primary -- selection. If it is a URL, then use an org-style link @@ -212,12 +212,14 @@ orgPrompt xpc = (mkOrgPrompt xpc =<<) .: mkOrgCfg NoClpSupport -- The prompt will display a little @+ PS@ in the window -- after the type of note. orgPromptPrimary :: XPConfig -> String -> FilePath -> X () -orgPromptPrimary xpc = (mkOrgPrompt xpc =<<) .: mkOrgCfg PrimarySelection +orgPromptPrimary xpc = (void . mkOrgPrompt xpc =<<) .: mkOrgCfg PrimarySelection --- | Create the actual prompt. -mkOrgPrompt :: XPConfig -> OrgMode -> X () +-- | Create the actual prompt. Returns 'False' when the input was +-- cancelled by the user (by, for example, pressing @Esc@ or @C-g@) and +-- 'True' otherwise. +mkOrgPrompt :: XPConfig -> OrgMode -> X Bool mkOrgPrompt xpc oc@OrgMode{ todoHeader, orgFile, clpSupport } = - mkXPrompt oc xpc (const (pure [])) appendNote + isJust <$> mkXPromptWithReturn oc xpc (const (pure [])) appendNote where -- | Parse the user input, create an @org-mode@ note out of that and -- try to append it to the given file.