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 support. #225

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 @@ -191,7 +191,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.
+ =: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, inculded relative dates, like ~mon~ (closest monday in future), ~-1~ (yesterday), ~+1m~ for the next month, ~+2w~ two weeks and so on.
+ =: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 @@ -206,7 +206,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, inculded relative dates, like ~mon~ (closest monday in future), ~-1~ (yesterday), ~+1m~ for the next month, ~+2w~ two weeks and so on.
+ =: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
9 changes: 2 additions & 7 deletions examples.org
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,8 @@ Of course, you could also write that as a standard agenda command with the [[ht
What if you wanted to group tasks that are due before the end of the current month? You could use something like this:

#+BEGIN_SRC elisp
(-let* (((sec minute hour day month year dow dst utcoff) (decode-time))
(last-day-of-month (calendar-last-day-of-month month year))
(target-date
;; A hack that seems to work fine. Yay, Postel!
(format "%d-%02d-%02d" year month (1+ last-day-of-month)))
(org-super-agenda-groups
`((:deadline (before ,target-date))
(let ((org-super-agenda-groups
'((:deadline (before "1 +1m")) ; first day of the next month
(:discard (:anything t)))))
(org-todo-list))
#+END_SRC
Expand Down
14 changes: 10 additions & 4 deletions org-super-agenda.el
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,12 @@ marker."
(buffer-substring (org-entry-beginning-position)
(org-entry-end-position))))

(defun org-super-agenda--translate-org-date (s)
"Return absolute time from various org supported date format,
included relative: +1, +mon and so on..."
(org-time-string-to-absolute (org-read-date nil nil s))
)

;;;; Minor mode

;;;###autoload
Expand Down Expand Up @@ -481,15 +487,15 @@ 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-super-agenda--translate-org-date (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)
('t entry-time) ; Has any deadline info
('nil (not entry-time)) ; Has no deadline info
(comparison
(when entry-time
(let ((entry-time (org-time-string-to-absolute entry-time))
(let ((entry-time (org-super-agenda--translate-org-date entry-time))
(compare-date (pcase comparison
((or 'past 'today 'future) today)
((or 'before 'on 'after) target-date))))
Expand Down Expand Up @@ -518,15 +524,15 @@ 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-super-agenda--translate-org-date (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)
('t entry-time) ; Has any scheduled info
('nil (not entry-time)) ; Has no scheduled info
(comparison
(when entry-time
(let ((entry-time (org-time-string-to-absolute entry-time))
(let ((entry-time (org-super-agenda--translate-org-date entry-time))
(compare-date (pcase comparison
((or 'past 'today 'future) today)
((or 'before 'on 'after) target-date))))
Expand Down
Loading