-
-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathorg-gtd-review.el
218 lines (194 loc) · 9.37 KB
/
org-gtd-review.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
;;; org-gtd-review.el --- GTD review logic for org-gtd -*- lexical-binding: t; coding: utf-8 -*-
;;
;; Copyright © 2019-2023 Aldric Giacomoni
;; Author: Aldric Giacomoni <[email protected]>
;; This file is not part of GNU Emacs.
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this file. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;;
;; Reviews are a crucial part of GTD. This code determines how to use
;; the agenda views for review purposes.
;;
;;; Code:
;;;; Requirements
(require 'org)
(require 'org-gtd-core)
(require 'org-gtd-areas-of-focus)
(require 'org-gtd-skip)
(require 'org-gtd-agenda)
(require 'org-gtd-projects)
;;;; Commands
;;;###autoload
(defun org-gtd-review-area-of-focus (&optional area start-date)
"Generate an overview agenda for a given area of focus.
You can pass an optional AREA (must be a member of `org-gtd-areas-of-focus') to
skip the menu to choose one.
START-DATE tells the code what to use as the first day for the agenda. It is
mostly of value for testing purposes."
(interactive (list (completing-read
"Which area of focus would you like to review? "
org-gtd-areas-of-focus
nil
t)))
(when (not (member area org-gtd-areas-of-focus))
(signal 'org-gtd-invalid-area-of-focus `(,area ,org-gtd-areas-of-focus)))
(let ((start-date (or start-date (format-time-string "%Y-%m-%d"))))
(org-gtd-core-prepare-agenda-buffers)
(with-org-gtd-context
(let ((org-agenda-custom-commands
`(("a" ,(format "Area of Focus: %s" area)
((tags ,org-gtd-project-headings
((org-agenda-overriding-header "Active projects")))
(todo ,org-gtd-next
((org-agenda-overriding-header "Next actions")))
(agenda ""
((org-agenda-overriding-header "Reminders")
(org-agenda-start-day ,start-date)
(org-agenda-show-all-dates nil)
(org-agenda-show-future-repeats nil)
(org-agenda-span 90)
(org-agenda-include-diary nil)
(org-agenda-skip-additional-timestamps-same-entry t)
(org-agenda-skip-function
'(org-gtd-skip-AND '(org-gtd-skip-unless-calendar
,(org-gtd-skip-unless-area-of-focus-func area))))))
(agenda ""
((org-agenda-overriding-header "Routines")
(org-agenda-time-grid '((require-timed) () "" ""))
(org-agenda-entry-types '(:scheduled))
(org-agenda-start-day ,start-date)
(org-agenda-span 'day)
(org-habit-show-habits-only-for-today nil)
(org-agenda-skip-function
'(org-gtd-skip-AND '(org-gtd-skip-unless-habit
,(org-gtd-skip-unless-area-of-focus-func area))))))
(tags ,(format "+ORG_GTD=\"%s\"+%s>\"<%s>\""
org-gtd-incubate
org-gtd-timestamp
start-date)
((org-agenda-overriding-header "Incubated items"))))
((org-agenda-skip-function '(org-gtd-skip-unless-area-of-focus ,area))
(org-agenda-buffer-name ,(format "*Org Agenda: %s*" area)))))))
(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)
(with-org-gtd-context
(let ((org-agenda-custom-commands
'(("g" "foobar"
((tags "+ORG_GTD=\"Calendar\"+LEVEL=2"
((org-agenda-include-diary nil)
(org-agenda-skip-function
'org-gtd-skip-unless-timestamp-empty-or-invalid)
(org-agenda-skip-additional-timestamps-same-entry t))))))))
(org-agenda nil "g"))))
(defun org-gtd-review-stuck-delegated-items ()
"Agenda view with all invalid delegated actions."
(interactive)
(with-org-gtd-context
(let ((org-agenda-custom-commands
`(("g" "foobar"
((tags (format "+TODO=\"%s\"" org-gtd-wait)
((org-agenda-skip-function
'(org-gtd-skip-AND
'(org-gtd-skip-unless-timestamp-empty-or-invalid
org-gtd-skip-unless-delegated-to-empty)))
(org-agenda-skip-additional-timestamps-same-entry t))))))))
(org-agenda nil "g"))))
(defun org-gtd-review-stuck-habit-items ()
"Agenda view with all invalid habit actions."
(interactive)
(with-org-gtd-context
(let ((org-agenda-custom-commands
'(("g" "foobar"
((tags "ORG_GTD=\"Habits\""
((org-agenda-skip-function
'org-gtd-skip-unless-timestamp-empty-or-invalid)
(org-agenda-skip-additional-timestamps-same-entry t))))))))
(org-agenda nil "g"))))
(defun org-gtd-review-stuck-incubated-items ()
"Agenda view with all invalid incubated actions."
(interactive)
(with-org-gtd-context
(let ((org-agenda-custom-commands
'(("g" "foobar"
((tags "ORG_GTD=\"Incubated\""
((org-agenda-skip-function
'org-gtd-skip-unless-timestamp-empty-or-invalid)
(org-agenda-skip-additional-timestamps-same-entry t))))))))
(org-agenda nil "g"))))
;;;###autoload
(defun org-gtd-review-stuck-projects ()
"Show all projects that do not have a next action."
(interactive)
(with-org-gtd-context
(org-agenda-list-stuck-projects)))
(defun org-gtd-review-stuck-single-action-items ()
"Agenda view with all invalid Calendar actions."
(interactive)
(with-org-gtd-context
(let ((org-agenda-custom-commands
`(("g" "foobar"
((tags (format "+ORG_GTD=\"%s\"" org-gtd-action)
((org-agenda-skip-function
'org-gtd-skip-unless-timestamp-empty-or-invalid)
(org-agenda-skip-additional-timestamps-same-entry t))))))))
(org-agenda nil "g"))))
;;;; Functions
;;;;; Private
(define-error
'org-gtd-invalid-area-of-focus
"`%s' is not a member of `%s'"
'org-gtd-error)
;;;; Footer
(provide 'org-gtd-review)
;;; org-gtd-review.el ends here