X.P.OrgMode: Allow specifying home dir starting with ~

It is already possible to "start" from $HOME by specifying a relative
directory (one starting without a starting slash).  However, it is often
nice to be explicit about this by writing `~/' directly—support this.
This commit is contained in:
slotThe
2021-08-15 16:37:10 +02:00
parent 5417969522
commit ee40542cb8

View File

@@ -80,6 +80,7 @@ prepended with @$HOME@ or an equivalent directory. I.e. instead of the
above you can write above you can write
> , ("M-C-o", orgPrompt def "TODO" "org/todos.org") > , ("M-C-o", orgPrompt def "TODO" "org/todos.org")
> -- also possible: "~/org/todos.org"
There is also some scheduling and deadline functionality present. This There is also some scheduling and deadline functionality present. This
may be initiated by entering @+s@ or @+d@—separated by at least one may be initiated by entering @+s@ or @+d@—separated by at least one
@@ -214,9 +215,10 @@ mkOrgPrompt xpc oc@OrgMode{ todoHeader, orgFile, clpSupport } =
then Header sel then Header sel
else Body $ "\n " <> sel else Body $ "\n " <> sel
-- Expand relative path with $HOME -- Expand path if applicable
fp <- case orgFile of fp <- case orgFile of
'/' : _ -> pure orgFile '/' : _ -> pure orgFile
'~' : '/' : _ -> getHomeDirectory <&> (<> drop 1 orgFile)
_ -> getHomeDirectory <&> (<> ('/' : orgFile)) _ -> getHomeDirectory <&> (<> ('/' : orgFile))
withFile fp AppendMode . flip hPutStrLn withFile fp AppendMode . flip hPutStrLn