Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Too greedy regex in org-alert-time-match-string #29

Closed
hai5 opened this issue Dec 8, 2022 · 4 comments
Closed

Too greedy regex in org-alert-time-match-string #29

hai5 opened this issue Dec 8, 2022 · 4 comments

Comments

@hai5
Copy link

hai5 commented Dec 8, 2022

Given an agenda tree such as

  • task 1
    SCHEDULED: <2022-12-08 Thu 07:00>
    Do something
    ** task 1a
    SCHEDULED: <2022-12-08 Thu 15:30>

org-alert-check will detect "15:30" for the task's time instead of "07:00". This is due to the regex in org-alert-time-match-string being too greedy.

This could be fix by using non-greedy match regex like "\(?:SCHEDULED\|DEADLINE\):.?<.?\([0-9]\{2\}:[0-9]\{2\}\).*>" instead.

@ntBre
Copy link
Collaborator

ntBre commented Dec 8, 2022

Thanks for the suggestion! org-alert-time-match-string is exposed as a variable though, so you should be able to set it to whatever you want in your config. I think I'll leave the default alone for now, but I'll include this as an example in the readme when I get back to my computer since it might be a common case. I might even add it to the doc string itself.

@hai5
Copy link
Author

hai5 commented Dec 8, 2022

Sorry for the typo. I mean the fix should be "\\(?:SCHEDULED\\|DEADLINE\\):.*?<.*?\\([0-9]\\{2\\}:[0-9]\\{2\\}\\).*>"

@hai5 hai5 closed this as completed Dec 8, 2022
ntBre added a commit that referenced this issue Dec 8, 2022
@wwhiffle
Copy link

Sorry for the typo. I mean the fix should be "\(?:SCHEDULED\|DEADLINE\):.?<.?\([0-9]\{2\}:[0-9]\{2\}\).*>"

This is also effective for recurring tasks that require clocking in.

SCHEDULED: <2024-06-28 Fri 21:00 +1d>
:LOGBOOK:
CLOCK: [2024-06-28 Fri 15:05]--[2024-06-28 Fri 15:07] =>  0:02
:END:

Since => contains >, any "HH:MM" time format like "15:05" between SCHEDULED: < and => will be matched.

The regex \\(?:SCHEDULED\\|DEADLINE\\):.*?<.*?\\([0-9]\\{2\\}:[0-9]\\{2\\}\\).*> resolves this issue.

@iftheshoefritz
Copy link

This is also good for time ranges in scheduled items: SCHEDULED: <2024-07-12 Fri 09:30-09:45> where I want to receive a notification about the start of the time range and don't care about the end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants