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

Relative dates in deadlines and scheluded for before and after #149

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ These selectors take one argument alone, or multiple arguments in a list.
+ =:category= :: Group items that match any of the given categories. Argument may be a string or list of strings.
+ =:children= :: Select any item that has child entries. Argument may be ~t~ to match if it has any children, ~nil~ to match if it has no children, ~todo~ to match if it has children with any to-do keywords, or a string to match if it has children with certain to-do keywords. You might use this to select items that are project top-level headings. Be aware that this may be very slow in non-daily/weekly agenda views because of its recursive nature.
+ =:date= :: Group items that have a date associated. Argument can be =t= to match items with any date, =nil= to match items without a date, or =today= to match items with today’s date. The =ts-date= text-property is matched against.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should other selectors, like :date, also support this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your patience. I think this shouldn't need much more before it can be merged.

Thanks for the review!

Also, would you add tests for this, please? (i.e. in the test suite, not just that Org file)

Just added a quick test (not pushed yet). It fails, I guess that org-read-date is not aware of org-super-agenda-test-date so relative date specification can not be tested without further mocks. Do you have some suggestion on how to do that?

:date does not support arbitrary dates yet (only static: any, none, today), so relative ones are a double step!

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your patience. I think this shouldn't need much more before it can be merged.

Thanks for the review!

FYI, feel free to ping me more often in the future. I didn't intend to ignore this for a year; I just hadn't thought about working on org-super-agenda for a while, since I didn't need to change anything in it for my own sake, and I have a number of other projects that occupy my free time.

Also, would you add tests for this, please? (i.e. in the test suite, not just that Org file)

Just added a quick test (not pushed yet). It fails, I guess that org-read-date is not aware of org-super-agenda-test-date so relative date specification can not be tested without further mocks. Do you have some suggestion on how to do that?

I guess you'll have to look in the Org source code, find the appropriate function, and redefine it locally in the test using cl-letf.

:date does not support arbitrary dates yet (only static: any, none, today), so relative ones are a double step!

As you can tell, I haven't worked on this package for a while. :) We should probably fix that too, though maybe not in this PR.

+ =:deadline= :: Group items that have a deadline. Argument can be ~t~ (to match items with any deadline), ~nil~ (to match items that have no deadline), ~past~ (to match items with a deadline in the past), ~today~ (to match items whose deadline is today), or ~future~ (to match items with a deadline in the future). Argument may also be given like ~before DATE~ or ~after DATE~ where DATE is a date string that ~org-time-string-to-absolute~ can process.
+ =:deadline= :: Group items that have a deadline. Argument can be ~t~ (to match items with any deadline), ~nil~ (to match items that have no deadline), ~past~ (to match items with a deadline in the past), ~today~ (to match items whose deadline is today), or ~future~ (to match items with a deadline in the future). Argument may also be given like ~before DATE~ or ~after DATE~ where DATE is a date string that ~org-read-date~ can process.
+ =:effort<= :: Group items that are less than (or equal to) the given effort. Argument is a time-duration string, like ~5~ or ~0:05~ for 5 minutes.
+ =:effort>= :: Group items that are higher than (or equal to) the given effort. Argument is a time-duration string, like ~5~ or ~0:05~ for 5 minutes.
+ ~:file-path~ :: Group items whose buffers' filename paths match any of the given regular expressions.
Expand All @@ -207,7 +207,7 @@ These selectors take one argument alone, or multiple arguments in a list.
+ =:priority<== :: Group items that are lower than or equal to the given priority, e.g. ~B~.
+ =:property= :: Group items with a property, optionally matching a value. Argument may be a property name string, or a list of property name string and either value string or predicate with which to test the value.
+ =:regexp= :: Group items that match any of the given regular expressions.
+ =:scheduled= :: Group items that are scheduled. Argument can be ~t~ (to match items scheduled for any date), ~nil~ (to match items that are not schedule), ~past~ (to match items scheduled for the past), ~today~ (to match items scheduled for today), or ~future~ (to match items scheduled for the future). Argument may also be given like ~before DATE~ or ~after DATE~ where DATE is a date string that ~org-time-string-to-absolute~ can process.
+ =:scheduled= :: Group items that are scheduled. Argument can be ~t~ (to match items scheduled for any date), ~nil~ (to match items that are not schedule), ~past~ (to match items scheduled for the past), ~today~ (to match items scheduled for today), or ~future~ (to match items scheduled for the future). Argument may also be given like ~before DATE~ or ~after DATE~ where DATE is a date string that ~org-read-date~ can process.
+ =:tag= :: Group items that match any of the given tags. Argument may be a string or list of strings.
+ =:time-grid= :: Group items that appear on the time grid.
+ =:todo= :: Group items that match any of the given TODO keywords. Argument may be a string or list of strings, or ~t~ to match any keyword, or ~nil~ to match only non-todo items.
Expand Down
14 changes: 8 additions & 6 deletions org-super-agenda.el
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,9 @@ match items that have no deadline), `past` (to match items with a
deadline in the past), `today' (to match items whose deadline is
today), or `future' (to match items with a deadline in the
future). Argument may also be given like `before DATE' or `after
DATE', where DATE is a date string that
`org-time-string-to-absolute' can process."
DATE', where DATE is a date string that `org-read-date' can
process. Note that relative dates are supported, e.g. `before
\"+3d\"' means in the next two days."
:section-name (pcase (car args)
('t "Deadline items")
('nil "Items without deadlines")
Expand All @@ -481,7 +482,7 @@ DATE', where DATE is a date string that
(org-today))))
(target-date (pcase (car args)
((or 'before 'on 'after)
(org-time-string-to-absolute (cadr args))))))
(org-time-string-to-absolute (org-read-date nil nil (cadr args)))))))
:test (org-super-agenda--when-with-marker-buffer (org-super-agenda--get-marker item)
(let ((entry-time (org-entry-get (point) "DEADLINE")))
(pcase (car args)
Expand All @@ -502,8 +503,9 @@ Argument can be `t' (to match items scheduled for any date),
items scheduled for the past), `today' (to match items scheduled
for today), or `future' (to match items scheduled for the
future). Argument may also be given like `before DATE' or `after
DATE', where DATE is a date string that
`org-time-string-to-absolute' can process."
DATE', where DATE is a date string that `org-read-date' can
process. Note that relative dates are supported, e.g. `before
\"+3d\"' means in the next two days."
:section-name (pcase (car args)
('t "Scheduled items")
('nil "Unscheduled items ")
Expand All @@ -518,7 +520,7 @@ DATE', where DATE is a date string that
(org-today))))
(target-date (pcase (car args)
((or 'before 'on 'after)
(org-time-string-to-absolute (cadr args))))))
(org-time-string-to-absolute (org-read-date nil nil (cadr args)))))))
:test (org-super-agenda--when-with-marker-buffer (org-super-agenda--get-marker item)
(let ((entry-time (org-entry-get (point) "SCHEDULED")))
(pcase (car args)
Expand Down
4 changes: 2 additions & 2 deletions org-super-agenda.info
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ list.
‘today’ (to match items whose deadline is today), or ‘future’ (to
match items with a deadline in the future). Argument may also be
given like ‘before DATE’ or ‘after DATE’ where DATE is a date
string that ‘org-time-string-to-absolute’ can process.
string that ‘org-read-date’ can process.
‘:effort<’
Group items that are less than (or equal to) the given effort.
Argument is a time-duration string, like ‘5’ or ‘0:05’ for 5
Expand Down Expand Up @@ -478,7 +478,7 @@ list.
(to match items scheduled for today), or ‘future’ (to match items
scheduled for the future). Argument may also be given like ‘before
DATE’ or ‘after DATE’ where DATE is a date string that
‘org-time-string-to-absolute’ can process.
‘org-read-date’ can process.
‘:tag’
Group items that match any of the given tags. Argument may be a
string or list of strings.
Expand Down
124 changes: 124 additions & 0 deletions test/results.el
Original file line number Diff line number Diff line change
Expand Up @@ -2199,4 +2199,128 @@ Wednesday 5 July 2017
ambition: In 77 d.: TODO Visit Mars :universe:ambition::space:travel:planet:
test: Scheduled: TODO [#C] Get haircut :personal:@town:
ambition: TODO Practice leaping tall ! :universe:ambition::personal:
" "97d7f990a88637673184f908f779b5bd" "Day-agenda (W27):
Wednesday 5 July 2017

Due before +5d
ambition: In 2 d.: TODO [#A] Take over the world :universe:ambition::world:
test: Deadline: CHECK /r/emacs :website:Emacs:

Other items
test: 7:02...... Sunrise (12:04 of daylight)
8:00...... ----------------
10:00...... ----------------
12:00...... now - - - - - - - - - - - - - - - - - - - - - - - - -
12:00...... ----------------
14:00...... ----------------
16:00...... ----------------
test: 18:00...... Scheduled: TODO Order a pizza :food:dinner:
18:00...... ----------------
test: 19:07...... Sunset
20:00...... ----------------
ambition: Sched. 1x: TODO [#A] Skype with president of Antarctica :universe:ambition:world::meetings:
ambition: In 10 d.: TODO [#A] Take over the universe :universe:ambition:
test: In 27 d.: TODO [#A] Spaceship lease :bills:spaceship:
test: Scheduled: TODO [#B] Fix flux capacitor :spaceship:shopping:@computer:
test: Scheduled: TODO Shop for groceries :food:shopping:@town:
ideas: Scheduled: SOMEDAY Rewrite Emacs in Common Lisp :Emacs:elisp:computers:software:programming:
ambition: In 5 d.: TODO [#B] Renew membership in supervillain club :universe:ambition::
test: In 16 d.: TODO [#B] Internet :bills:
ambition: In 53 d.: WAITING Visit the moon :universe:ambition::space:travel:
ambition: In 77 d.: TODO Visit Mars :universe:ambition::space:travel:planet:
test: Scheduled: TODO [#C] Get haircut :personal:@town:
ambition: TODO Practice leaping tall ! :universe:ambition::personal:
" "9157548a5d1e109f50f36e8936e58577" "Day-agenda (W27):
Wednesday 5 July 2017

Due after +5d
ambition: In 10 d.: TODO [#A] Take over the universe :universe:ambition:
test: In 27 d.: TODO [#A] Spaceship lease :bills:spaceship:
test: In 16 d.: TODO [#B] Internet :bills:
ambition: In 53 d.: WAITING Visit the moon :universe:ambition::space:travel:
ambition: In 77 d.: TODO Visit Mars :universe:ambition::space:travel:planet:

Other items
test: 7:02...... Sunrise (12:04 of daylight)
8:00...... ----------------
10:00...... ----------------
12:00...... now - - - - - - - - - - - - - - - - - - - - - - - - -
12:00...... ----------------
14:00...... ----------------
16:00...... ----------------
test: 18:00...... Scheduled: TODO Order a pizza :food:dinner:
18:00...... ----------------
test: 19:07...... Sunset
20:00...... ----------------
ambition: Sched. 1x: TODO [#A] Skype with president of Antarctica :universe:ambition:world::meetings:
ambition: In 2 d.: TODO [#A] Take over the world :universe:ambition::world:
test: Scheduled: TODO [#B] Fix flux capacitor :spaceship:shopping:@computer:
test: Scheduled: TODO Shop for groceries :food:shopping:@town:
ideas: Scheduled: SOMEDAY Rewrite Emacs in Common Lisp :Emacs:elisp:computers:software:programming:
test: Deadline: CHECK /r/emacs :website:Emacs:
ambition: In 5 d.: TODO [#B] Renew membership in supervillain club :universe:ambition::
test: Scheduled: TODO [#C] Get haircut :personal:@town:
ambition: TODO Practice leaping tall ! :universe:ambition::personal:
" "e9bc8ca80596355bd3332b2db03ae553" "Day-agenda (W27):
Wednesday 5 July 2017

Scheduled before -0d
ambition: Sched. 1x: TODO [#A] Skype with president of Antarctica :universe:ambition:world::meetings:

Other items
test: 7:02...... Sunrise (12:04 of daylight)
8:00...... ----------------
10:00...... ----------------
12:00...... now - - - - - - - - - - - - - - - - - - - - - - - - -
12:00...... ----------------
14:00...... ----------------
16:00...... ----------------
test: 18:00...... Scheduled: TODO Order a pizza :food:dinner:
18:00...... ----------------
test: 19:07...... Sunset
20:00...... ----------------
ambition: In 2 d.: TODO [#A] Take over the world :universe:ambition::world:
ambition: In 10 d.: TODO [#A] Take over the universe :universe:ambition:
test: In 27 d.: TODO [#A] Spaceship lease :bills:spaceship:
test: Scheduled: TODO [#B] Fix flux capacitor :spaceship:shopping:@computer:
test: Scheduled: TODO Shop for groceries :food:shopping:@town:
ideas: Scheduled: SOMEDAY Rewrite Emacs in Common Lisp :Emacs:elisp:computers:software:programming:
test: Deadline: CHECK /r/emacs :website:Emacs:
ambition: In 5 d.: TODO [#B] Renew membership in supervillain club :universe:ambition::
test: In 16 d.: TODO [#B] Internet :bills:
ambition: In 53 d.: WAITING Visit the moon :universe:ambition::space:travel:
ambition: In 77 d.: TODO Visit Mars :universe:ambition::space:travel:planet:
test: Scheduled: TODO [#C] Get haircut :personal:@town:
ambition: TODO Practice leaping tall ! :universe:ambition::personal:
" "4b7dd608c770d16f0937273124cdf793" "Day-agenda (W27):
Wednesday 5 July 2017

Scheduled after -1d
test: 18:00...... Scheduled: TODO Order a pizza :food:dinner:
test: Scheduled: TODO [#B] Fix flux capacitor :spaceship:shopping:@computer:
test: Scheduled: TODO Shop for groceries :food:shopping:@town:
ideas: Scheduled: SOMEDAY Rewrite Emacs in Common Lisp :Emacs:elisp:computers:software:programming:
test: Scheduled: TODO [#C] Get haircut :personal:@town:
ambition: TODO Practice leaping tall ! :universe:ambition::personal:

Other items
test: 7:02...... Sunrise (12:04 of daylight)
8:00...... ----------------
10:00...... ----------------
12:00...... now - - - - - - - - - - - - - - - - - - - - - - - - -
12:00...... ----------------
14:00...... ----------------
16:00...... ----------------
18:00...... ----------------
test: 19:07...... Sunset
20:00...... ----------------
ambition: Sched. 1x: TODO [#A] Skype with president of Antarctica :universe:ambition:world::meetings:
ambition: In 2 d.: TODO [#A] Take over the world :universe:ambition::world:
ambition: In 10 d.: TODO [#A] Take over the universe :universe:ambition:
test: In 27 d.: TODO [#A] Spaceship lease :bills:spaceship:
test: Deadline: CHECK /r/emacs :website:Emacs:
ambition: In 5 d.: TODO [#B] Renew membership in supervillain club :universe:ambition::
test: In 16 d.: TODO [#B] Internet :bills:
ambition: In 53 d.: WAITING Visit the moon :universe:ambition::space:travel:
ambition: In 77 d.: TODO Visit Mars :universe:ambition::space:travel:planet:
"))
Loading