35 Commits

Author SHA1 Message Date
Tony Zorman
ebe1b9b036 X.P.OrgMode: Add ability to specify time spans 2024-03-29 20:47:52 +01:00
Tony Zorman
d691d25d1c X.P.OrgMode: Fallback to "today" if no day is given 2024-03-29 13:57:27 +01:00
Tony Zorman
105e529826 Fix partial uses of head
Fixes: https://github.com/xmonad/xmonad-contrib/issues/830
Related: https://github.com/xmonad/xmonad-contrib/pull/836
2023-10-28 11:41:24 +02:00
Tony Zorman
6063855a3e X.P.OrgMode: Simplify refile 2023-02-18 13:23:15 +01:00
Tony Zorman
502f6a0e75 X.P.OrgMode: Fix deprecation warning
Starting with time-1.10, the iso8601DateFormat function was deprecated
in favour of more sophisticated methods for showing ISO 8601 date
formats—as such, follow the libraries lead.

Sadly, the new functionality was only introduced in time-1.9, meaning
GHC 8.8 and up.  Since we still support 8.6, the introduction of some
CPP is necessary.
2022-11-20 16:53:36 +01:00
Tony Zorman
1c6ae39fc9 X.P.OrgMode: Also parse time in HHMM format 2022-11-10 11:50:28 +01:00
Tony Zorman
b627306772 X.P.OrgMode: Include 00:xx and xx:00 in the date range 2022-11-10 11:49:46 +01:00
Tony Zorman
8b4560dc1e X.P.OrgMode: Parse dates case-insensitively 2022-11-10 11:49:46 +01:00
Tony Zorman
a97a1acf87 X.P.OrgMode: Remove the need for todoKeywords argument
This is (i) much simpler to use and (ii) helps us with refiling.  Emacs
will ignore todo keywords _that it knows_ when refiling, but when
started in batch-mode it doesn't know a whole lot.  One would need to
thread the `todoKeywords' through to `refile' and then set
`org-todo-keywords' or a similar variable, which does not sound like a
good experience.  Hence, falling back to showing the todo keyword to the
user when deciding upon a headline sounds acceptable.
2022-10-31 14:29:43 +01:00
Tony Zorman
bdb13e2551 X.P.OrgMode: Add orgPromptRefile[To]
Add orgPromptRefile and orgPromptRefileTo in order to refile entries
after insertion.
2022-10-31 14:29:43 +01:00
Tony Zorman
cd95bf9c28 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.
2022-10-26 20:25:53 +02:00
Tony Zorman
b9c8294045 X.P.OrgMode: Add mkOrgCfg
This ensures that we always immediately expand the file path upon
constructing an `OrgMode' record.  We thus do not have to do this in
`mkOrgPrompt' anymore.
2022-10-26 20:25:53 +02:00
Tony Zorman
2b1a15c9e5 X.P.OrgMode: Remove pLast
Use the more aptly named `option` instead.
2022-10-17 14:04:43 +02:00
Tony Zorman
c701a75002 X.P.OrgMode: Require whitespace before priority
By being a bit less greedy with consuming whitespace in the date/time
parsers, we can make the `prop_{encode,decode}Preservation` properties
well-defined again.
2022-08-28 07:41:08 +02:00
Tony Zorman
f77fb802eb X.P.OrgMode: Mention more resources
Specifically, a blog post by yours truly featuring some animated GIFs,
which might be more digestible than a wall of text.
2022-08-27 12:43:28 +02:00
Tony Zorman
68b5a12f96 X.P.OrgMode: Add ability to specify priorities
Add the ability to specify alphabetic (`#A`, `#B`, and `#C`) org-mode
priorities[1] at the end of the input note.

[1]: https://orgmode.org/manual/Priorities.html
2022-08-23 18:47:03 +02:00
Tony Zorman
e466d9b1dc X.Prelude: Add mkAbsolutePath 2022-05-23 20:12:57 +02:00
Tony Zorman
6c787204aa Update my name 2022-05-05 21:07:27 +02:00
slotThe
4f048fb563 X.P.OrgMode: Check num validity while parsing
There are a lot of times when we could already check for "valid" input
during parsing instead of relaying possibly incorrect dates and times to
`org-mode`.  This seems like a sensible thing to do—I don't think anyone
would ever want to schedule anything for 35:90 :)
2021-12-31 09:55:49 +01:00
Sibi Prabakaran
91f1a0de1e
Fix date parsing issue for org mode plugin
This patch fixes the date parsing issue currently when an entry like
`todo +d 22 01 2022` is used. I have added tests too which demonstrate
the current issue so that we can prevent future regression.
2021-12-29 14:58:46 +05:30
slotThe
b1532e666f X.P.OrgMode: Use X.U.Parser
Since we now have an "internal" parser library in xmonad, use it.  This
allows us to get rid of some hacks in this module that were needed
because of ReadP's parsing behaviour.
2021-12-13 16:11:57 +01:00
slotThe
38c11c1e3c Add "Description" field to module headers
Fixes: https://github.com/xmonad/xmonad-contrib/issues/592
2021-09-26 14:15:54 +02:00
slotThe
ee40542cb8 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.
2021-08-15 17:04:21 +02:00
slotThe
5417969522 X.P.OrgMode: Update documentation
Fix spelling mistakes, as well as make the existing documentation a
little bit more accurate in places.
2021-08-15 16:34:41 +02:00
slotThe
b42303aa6f X.P.OrgMode: Fix behaviour of getLast
So far, while parsing strings like "<ptn><more-letters>", the `getLast`
function immediately stopped on strings of the form "<ptn><whitespace>".
This may be a bit confusing given the functions name.  Strings of
the—perhaps artificial—form

    "a +d f 1 +d f 2"

would be cut short and parsed as

    Deadline "a" (Time { date = Next Friday, tod = Just 01:00 })

instead of the more intuitive

    Deadline "a +d f 1" (Time { date = Next Friday, tod = Just 02:00 }).

This is readily fixed by applying the `go` parser as often as possible,
only returning the longest list, and then pruning eventual leftovers at
the end of the string.  Since we were already invoking `dropWhileEnd` to
trim whitespace before, the added `reverse`s should not impact
performance at all.

Fixes: https://github.com/xmonad/xmonad-contrib/issues/584
2021-08-11 07:11:54 +02:00
slotThe
cfc793e94f tests: Add OrgMode
Adds a pretty-printer, as well as property tests that this is in fact
an proper inverse for the parser.
2021-06-13 19:52:48 +02:00
slotThe
dea8d9dced X.P.OrgMode: Appropriately pad output time
The standard formatting for org is to left-pad single digits with a
zero; do that.
2021-06-13 19:33:08 +02:00
slotThe
1c6e6c808d X.P.OrgMode: Start counting years at 25
This is for disambiguation purposes.  Otherwise, there is no way to
decide whether

    message +s 17 jul 12

wants to schedule the note for the 17th of july at 12:00, or for
the 17th of july in the year 12.  The easiest way around this is to
stipulate that people want to make these notes for the future more
often than not and to simply prohibit note before the year 25 (as that
is where the valid times end).
2021-06-13 19:08:09 +02:00
slotThe
4b15ea2ecc X.P.OrgMode: Parse empty message
Empty messages seem quite useless, but it's an easy fix for the parser
to be able to deal with them, so do it.
2021-06-13 19:02:01 +02:00
slotThe
c1cb3aaa24 X.P.OrgMode: Only parse actual words
Instead of trying to find a prefix and then killing the rest of the
word, actually see whether it at least fits the pattern.  This means
that

    message +s saturated

will no longer parse as a scheduled item for saturday, while

    message +s satur

still will.
2021-06-13 19:01:59 +02:00
slotThe
c9ca4ce026 X.P.OrgMode: Linkify URLs in orgPromptPrimary
If we have a URL in the clipboard and we use `orgPromptPrimary`, it
would be nice if

    message +s 11 jan 2013

would result in

    * TODO [[_URL_][message]]
      SCHEDULED: <2013-01-11 Fri>

instead of the current

    * TODO message
      SCHEDULED: <2013-01-11 Fri>
      _URL_

This has the advantage that if one shows scheduled or deadlines items in
the org-agenda, it is possible to immediately follow this link with
`C-c C-o` or similar functionality.

The URL detection is very rudimentary right now.  One use `parseURI`
from `network-uri`, but that would be an additional dependency that I
didn't think was worth it.
2021-06-10 15:46:48 +02:00
slotThe
5da9b26142 X.P.OrgMode: Prune extra whitespace
This implements whitespace pruning at the end of a sheduled item or
deadline.  If we have a message like

    This is a message                +s today

it is expected that we created a heading of just "This is a message",
without the extra whitespace.
2021-06-10 15:43:27 +02:00
slotThe
2469269119 New module: XMonad.Prelude
This is a convenience module in order to have less import noise.  It
re-exports the following:

  a) Commonly used modules in full (Data.Foldable, Data.Applicative, and
     so on); though only those that play nicely with each other, so that
     XMonad.Prelude can be imported unqualified without any problems.
     This prevents things like `Prelude.(.)` and `Control.Category.(.)`
     fighting with each other.

  b) Helper functions that don't necessarily fit in any other module;
     e.g., the often used abbreviation `fi = fromIntegral`.
2021-05-13 17:44:47 +02:00
slotThe
fd20202c23 X.P.OrgMode: Add ability to schedule hours/minutes 2021-04-02 08:15:28 +02:00
slotThe
e2eee301e0 New module: XMonad.Prompt.OrgMode 2021-04-01 18:36:31 +02:00