From bc1a96e5a90c2bff5cb3ff16add9731fedebdc68 Mon Sep 17 00:00:00 2001 From: Daniele Pizzolli Date: Fri, 24 Apr 2020 11:00:00 +0200 Subject: [PATCH] Relative dates in dedalines and scheluded for before and after Backward compatible improvement, org-read-date support a super-set of the previous function org-time-string-to-absolute. --- README.org | 4 ++-- org-super-agenda.el | 14 ++++++++------ org-super-agenda.info | 2 +- test/test.org | 7 +++++++ 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/README.org b/README.org index d27d1c1..d39d941 100644 --- a/README.org +++ b/README.org @@ -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. -+ =: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. @@ -206,7 +206,7 @@ These selectors take one argument alone, or multiple arguments in a list. + =:priority<= :: Group items that are lower than the given priority, e.g. ~A~. + =:priority<== :: Group items that are lower than or equal to the given priority, e.g. ~B~. + =: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. diff --git a/org-super-agenda.el b/org-super-agenda.el index 7878c40..33407c1 100644 --- a/org-super-agenda.el +++ b/org-super-agenda.el @@ -426,8 +426,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") @@ -442,7 +443,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) @@ -463,8 +464,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 ") @@ -479,7 +481,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) diff --git a/org-super-agenda.info b/org-super-agenda.info index e2d4d41..e02bc4d 100644 --- a/org-super-agenda.info +++ b/org-super-agenda.info @@ -412,7 +412,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 diff --git a/test/test.org b/test/test.org index 249d869..1c9cd96 100644 --- a/test/test.org +++ b/test/test.org @@ -282,6 +282,13 @@ I don't know when I'll get to this, so it's undated. (org-super-agenda-groups '((:scheduled (before "2017-07-06"))))) (org-agenda nil "a"))) + + (with-org-today-date "2017-07-05 00:00" + (let ((org-agenda-files (list "~/src/org-super-agenda/test/test.org")) + (org-agenda-span 'day) + (org-super-agenda-groups + '((:scheduled (before "+2d"))))) + (org-agenda nil "a"))) #+END_SRC #+BEGIN_SRC elisp