Skip to content

Commit

Permalink
Merge branch 'mbeutelspacher-feat/review_missed_incubated_items'
Browse files Browse the repository at this point in the history
* mbeutelspacher-feat/review_missed_incubated_items:
  add tests and round out review-missed-items
  Add tests for autoloading
  Change to requiring org-gtd instead of individual modules
  Add missing require
  Fix autoload bug
  feat: add org-gtd-review-missed-items
  • Loading branch information
Trevoke committed Dec 22, 2023
2 parents 2e5b635 + c08a33a commit 7303383
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 6 deletions.
1 change: 1 addition & 0 deletions doc/org-gtd.org
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,7 @@ Sometimes things break. The following functions will help you find these items:
- ~org-gtd-review-stuck-delegated-items~
- ~org-gtd-review-stuck-single-action-items~
- ~org-gtd-review-stuck-projects~
- ~org-gtd-review-missed-items~

** Projects without a NEXT item

Expand Down
4 changes: 3 additions & 1 deletion doc/org-gtd.texi
Original file line number Diff line number Diff line change
Expand Up @@ -1328,6 +1328,8 @@ Sometimes things break. The following functions will help you find these items:
@code{org-gtd-review-stuck-single-action-items}
@item
@code{org-gtd-review-stuck-projects}
@item
@code{org-gtd-review-missed-items}
@end itemize

@node Projects without a NEXT item
Expand All @@ -1342,4 +1344,4 @@ To fix such a stuck project, put the point on the project heading and call @code

See @ref{data shape requirements}. If this does not help you, please open an issue and show exactly what you have done before asking @samp{org-gtd} to create a project.

@bye
@bye
2 changes: 2 additions & 0 deletions org-gtd-core.el
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ See `org-todo-keywords' for definition."
"|"
,(string-join `(,org-gtd-done ,org-gtd-done-suffix))
,(string-join `(,org-gtd-canceled ,org-gtd-canceled-suffix)))))
(org-done-keywords '(,org-gtd-done ,org-gtd-canceled))
(org-not-done-keywords '(,org-gtd-next ,org-gtd-todo ,org-gtd-wait))
;; (org-log-done 'time)
;; (org-log-done-with-time t)
;; (org-log-refile 'time)
Expand Down
47 changes: 44 additions & 3 deletions org-gtd-review.el
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,47 @@ mostly of value for testing purposes."
(org-agenda nil "a")
(goto-char (point-min))))))

(defun org-gtd-review-missed-items (&optional start-date)
"Agenda view with all incubated, delegated, or calendar items whose dates
are in the past.
You can pass an optional START-DATE to tell the code what to use as the first
day for the agenda. It is mostly of value for testing purposes."
(interactive)
(org-gtd-core-prepare-agenda-buffers)
(with-org-gtd-context
(let* ((start-date (or start-date (format-time-string "%Y-%m-%d")))
(org-agenda-custom-commands
`(("g" "foobar"
(
(tags ,(format "+ORG_GTD=\"%s\"+LEVEL=2" org-gtd-calendar)
((org-agenda-overriding-header "Missed calendar events")
(org-agenda-skip-function '(org-gtd-skip-AND
'(org-gtd-skip-unless-timestamp-in-the-past
org-gtd-skip-unless-in-progress
)))))
(tags ,(format "+ORG_GTD=\"%s\"+LEVEL=2" org-gtd-incubate)
((org-agenda-overriding-header "Incubated events to review")
(org-agenda-start-day ,start-date)
(org-agenda-skip-function
'(org-gtd-skip-AND
'(org-gtd-skip-unless-timestamp-in-the-past
org-gtd-skip-unless-in-progress
)))
(org-agenda-skip-additional-timestamp-same-entry t)
(org-agenda-show-all-dates nil)
(org-agenda-show-future-repeats nil)))
(tags (format "+TODO=\"%s\"" org-gtd-wait)
((org-agenda-overriding-header "Missed delegated events")
(org-agenda-start-day ,start-date)
(org-agenda-skip-function
'org-gtd-skip-unless-timestamp-in-the-past)
(org-agenda-skip-additional-timestamps-same-entry t)
(org-agenda-show-all-dates nil)
(org-agenda-show-future-repeats nil)))
)))))
(org-agenda nil "g"))))

(defun org-gtd-review-stuck-calendar-items ()
"Agenda view with all invalid Calendar actions."
(interactive)
Expand All @@ -105,7 +146,7 @@ mostly of value for testing purposes."
(org-agenda nil "g"))))

(defun org-gtd-review-stuck-delegated-items ()
"Agenda view with all invalid Calendar actions."
"Agenda view with all invalid delegated actions."
(interactive)
(with-org-gtd-context
(let ((org-agenda-custom-commands
Expand All @@ -119,7 +160,7 @@ mostly of value for testing purposes."
(org-agenda nil "g"))))

(defun org-gtd-review-stuck-habit-items ()
"Agenda view with all invalid Calendar actions."
"Agenda view with all invalid habit actions."
(interactive)
(with-org-gtd-context
(let ((org-agenda-custom-commands
Expand All @@ -131,7 +172,7 @@ mostly of value for testing purposes."
(org-agenda nil "g"))))

(defun org-gtd-review-stuck-incubated-items ()
"Agenda view with all invalid Calendar actions."
"Agenda view with all invalid incubated actions."
(interactive)
(with-org-gtd-context
(let ((org-agenda-custom-commands
Expand Down
4 changes: 4 additions & 0 deletions org-gtd-skip.el
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
(if non-nil-funcs
(funcall (car non-nil-funcs)))))

(defun org-gtd-skip-unless-in-progress ()
"Skip-function: only keep if it's not one of the DONE keywords"
(org-agenda-skip-entry-if 'todo org-done-keywords))

(defun org-gtd-skip-if-habit ()
"Skip-function: only keep this if it's a habit."
(let ((subtree-end (save-excursion (org-end-of-subtree t))))
Expand Down
1 change: 1 addition & 0 deletions org-gtd.info
Original file line number Diff line number Diff line change
Expand Up @@ -1465,6 +1465,7 @@ these items:
• ‘org-gtd-review-stuck-delegated-items’
• ‘org-gtd-review-stuck-single-action-items’
• ‘org-gtd-review-stuck-projects’
• ‘org-gtd-review-missed-items’


File: org-gtd.info, Node: Projects without a NEXT item, Next: I can't create a project when clarifying an inbox item!, Prev: Finding lost tasks, Up: Troubleshooting
Expand Down
12 changes: 11 additions & 1 deletion test/fixtures/gtd-file.org
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,13 @@ SCHEDULED: <2021-12-04 Sat .+1d>
:CATEGORY: Home
:END:

** WAIT Wait for someone
** WAIT Overdue delegated
:PROPERTIES:
:ORG_GTD_TIMESTAMP: <2021-11-18 Sun>
:DELEGATED_TO: future me
:END:

** WAIT Wait for someone
:PROPERTIES:
:ORG_GTD_TIMESTAMP: <2025-03-23 Sun>
:DELEGATED_TO: future me
Expand All @@ -92,6 +97,11 @@ SCHEDULED: <2021-12-04 Sat .+1d>
:PROPERTIES:
:ORG_GTD: Incubated
:END:
** Time to review this one
:PROPERTIES:
:ORG_GTD_TIMESTAMP: <2021-11-19 Thu>
:CATEGORY: Home
:END:
** For later
:PROPERTIES:
:ORG_GTD_TIMESTAMP: <2037-02-19 Thu>
Expand Down
53 changes: 52 additions & 1 deletion test/reviews-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,55 @@
(expect (ogt--current-buffer-raw-text) :to-match next-actions)
(expect (ogt--current-buffer-raw-text) :to-match reminders)
(expect (ogt--current-buffer-raw-text) :to-match routines)
(expect (ogt--current-buffer-raw-text) :to-match incubated-items)))))))
(expect (ogt--current-buffer-raw-text) :to-match incubated-items))))))
(describe
"Missed events"

(it "shows unfinished items that have a timestamp in the past"
(let ((task-buffer (ogt--create-org-file-in-org-gtd-dir
"foo"
(org-file-contents
"test/fixtures/gtd-file.org"))))
(org-gtd-review-missed-items "2021-11-20")
(let ((agenda-contents (ogt--buffer-string org-agenda-buffer)))
;; these are *DONE OR CANCELED*
(expect agenda-contents :not :to-match "not worth thinking about")
(expect agenda-contents :not :to-match "write a nice test")
;; these are *IN THE FUTURE*
(expect agenda-contents :not :to-match "repeating item")
(expect agenda-contents :not :to-match "For later")
;; these are *UNDONE IN THE PAST*
(expect agenda-contents :to-match "probably overdue by now")
(expect agenda-contents :to-match "Time to review this one")
;; this is *OVERDUE DELEGATED*
(expect agenda-contents :to-match "Overdue delegated")
)))))


;; (let* ((yesterday (format-org-date -1))
;; (tomorrow (format-org-date 1))
;; (mock-org-content (concat
;; "* Incubate
;; :PROPERTIES:
;; :ORG_GTD: Incubated
;; :END:
;; ** DONE write a test
;; :PROPERTIES:
;; :ORG_GTD_TIMESTAMP: " yesterday "
;; :END:

;; * Actions
;; :PROPERTIES:
;; :ORG_GTD: Actions
;; :END:
;; ** WAIT Wait for someone
;; :PROPERTIES:
;; :ORG_GTD_TIMESTAMP: " tomorrow "
;; :DELEGATED_TO: future me
;; :END:"
;; )))

;; (with-temp-buffer
;; (org-mode)
;; (insert mock-org-content)
;; (setq temp-org-buffer (current-buffer))))

0 comments on commit 7303383

Please sign in to comment.