From 874dce0f7cbbc8492a159d3770ea88441778deef Mon Sep 17 00:00:00 2001 From: Pete Kazmier Date: Mon, 7 Dec 2020 18:24:04 -0600 Subject: [PATCH 1/2] Add relative dates to :deadline and :scheduled Use `org-read-date` to parse the DATE string passed as an argument to `before` and `after` in the `:deadline` and `:scheduled` selectors. --- README.org | 4 ++-- examples.org | 9 +++++++++ org-super-agenda.el | 4 ++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/README.org b/README.org index 272c7b9..f1f5087 100644 --- a/README.org +++ b/README.org @@ -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. + =: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. @@ -205,7 +205,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/examples.org b/examples.org index d05986b..63da616 100644 --- a/examples.org +++ b/examples.org @@ -237,6 +237,15 @@ Let's say it's approaching the start of a new school year, and you want to see a Of course, you could also write that as a standard agenda command with the [[http://orgmode.org/worg/org-tutorials/advanced-searching.html][advanced searching syntax]], and it would execute faster. +Perhaps you want to see all tasks due within the next two weeks? You can use relative date notation like this: + +#+BEGIN_SRC elisp :results none + (let ((org-super-agenda-groups + '((:deadline (before "+2w")) + (:discard (:anything t))))) + (org-todo-list)) +#+END_SRC + 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 diff --git a/org-super-agenda.el b/org-super-agenda.el index 7e4cecf..c725d12 100644 --- a/org-super-agenda.el +++ b/org-super-agenda.el @@ -450,7 +450,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) @@ -487,7 +487,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) From 2f026bbc39d89ead3b79f26eeb47f34dd3403a58 Mon Sep 17 00:00:00 2001 From: Pete Kazmier Date: Mon, 7 Dec 2020 19:35:02 -0600 Subject: [PATCH 2/2] Update docstrings to reflect org-read-date changes --- org-super-agenda.el | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/org-super-agenda.el b/org-super-agenda.el index c725d12..0c9e03a 100644 --- a/org-super-agenda.el +++ b/org-super-agenda.el @@ -434,8 +434,7 @@ 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." :section-name (pcase (car args) ('t "Deadline items") ('nil "Items without deadlines") @@ -471,8 +470,7 @@ 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." :section-name (pcase (car args) ('t "Scheduled items") ('nil "Unscheduled items ")