about summary refs log tree commit diff
path: root/emacs/.emacs.d/wpc/todo.el
blob: 236912c086fd26ce29d34d35f1b522affc8eb2cb (plain) (blame)
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
;;; todo.el --- Bespoke task management system -*- lexical-binding: t -*-
;; Author: William Carroll <wpcarro@gmail.com>

;;; Commentary:
;; Marriage of my personal task-management system, which I've been using for 18
;; months and is a mixture of handwritten notes, iOS notes, and org-mode files,
;; with Emacs's famous `org-mode'.
;;
;; For me, I'd like a live, reactive state management system.  I'd like
;; `org-mode' to be a nice way of rendering my TODOs, but I think the
;; relationship with `org-mode' ends there.
;;
;; Intended to supplement my org-mode workflow.
;;
;; Wish-list:
;; - Daily emails for standups
;; - Templates for commonly occurring tasks

;; Dependencies
(require 'dash)
(require 'f)
(require 'macros)

;;; Code:

;; TODO: Classify habits as 'daily, 'weekly, 'monthly, 'yearly, 'event-driven

;; TODO: Consider serving these values up to a React webpage in Chrome.

;; TODO: Classify meetings as either 'recurrent or 'ad-hoc.

;; TODO: Support sorting by `type'.

;; TODO: Support work-queue idea for "Tomorrow's todos."

;; TODO: Support macro to generate all possible predicates for todo types.

;; TODO: Support export to org-mode file

;; TODO: Support generic way to quickly render a list

(defcustom todo/install-kbds? t
  "When t, install the keybindings.")

;; TODO: Add documentation.
(cl-defstruct todo type label)

;; TODO: Consider keeping this in Dropbox.
;; TODO: Support whether or not the todo is done.
(defconst todo/org-file-path "~/Dropbox/org/today.org")

;; TODO: Support remaining function for each type.
;; TODO: Support completed function for each type.

(defun todo/completed? (x)
  "Return t is `X' is marked complete."
  (todo-complete x))

;; TODO: Prefer `new-{task,habit,meeting}'.

(defun todo/completed (xs)
  "Return the todo items in `XS' that are marked complete."
  (->> xs
       (-filter #'todo/completed?)))

(defun todo/remaining (xs)
  "Return the todo items in `XS' that are not marked complete."
  (->> xs
       (-reject #'todo/completed?)))

(defun todo/task (label)
  "Convenience function for creating a task todo with `LABEL'."
  (make-todo
   :type 'task
   :label label))

(defun todo/meeting (label)
  "Convenience function for creating a meeting todo with `LABEL'."
  (make-todo
   :type 'meeting
   :label label))

(defun todo/habit (label)
  "Convenience function for creating a habit todo with `LABEL'."
  (make-todo
   :type 'habit
   :label label))

(defun todo/task? (x)
  "Return t if `X' is a task."
  (equal 'task (todo-type x)))

(defun todo/habit? (x)
  "Return t if `X' is a habit."
  (equal 'habit (todo-type x)))

(defun todo/meeting? (x)
  "Return t if `X' is a meeting."
  (equal 'meeting (todo-type x)))

(defun todo/label (x)
  "Return the label of `X'."
  (todo-label x))

;; TODO: Support moving todos between todo/{today,tomorrow}.
;; TODO: Consider modelling todo/{today,tomorrow} as queues instead of lists so that I can
;; append cheaply.

;; TODO: Find an Elisp date library.

;; TODO: type-driven development of this habit tree.
;; TODO: Create this tree on a whiteboard first.
;; (defconst todo/habits
;;   '(:beginning-of-month
;;     '("Create habit template for current month"
;;       "Post mortem of previous month")
;;     :monday    '("Jiu Jitsu")
;;     :tuesday   '("Jiu Jitsu")
;;     :wednesday '("Jiu Jitsu")
;;     :thursday  '("Salsa class")
;;     :friday    '("Jiu Jitsu")
;;     :saturday  '("Borough market")
;;     :sunday    '("Shave")
;;     :weekday '(:arrive-at-work
;;                '("Breakfast"
;;                  "Coffee"
;;                  "Placeholder")
;;                :before-lunch
;;                '("Lock laptop"
;;                  "Placeholder")
;;                :home->work
;;                '("Michel Thomas Italian lessons"))
;;     :daily '(:morning
;;              '("Meditate"
;;                "Stretch")
;;              :)))

;; overlay weekday with specific weekdays (e.g. BJJ is only on M,T,W)

;; TODO: Extend the record type to support duration estimations for AFK, K
;; calculations.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Habits
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; TODO: Should I be writing this in ReasonML and Haskell?

(defconst todo/monthly-habit-challenge
  "InterviewCake.com"
  "The monthly habit challenge I do for fifteen minutes each day.")

(defconst todo/daily-habits
  (->> (list "Meditate"
             todo/monthly-habit-challenge)
       (-map #'todo/habit)))

(defconst todo/first-of-the-month-stack
  '("Create habit template for current month"
    "Reserve two dinners in London for dates"
    "Post mortem of previous month"
    "Create monthly financial budget in Google Sheets")
  "A stack of habits that I do at the beginning of each month.")

(defconst todo/adhoc-habits
  (->> (list/concat
        todo/first-of-the-month-stack)
       (-map #'todo/habit))
  "Habits that I have no classification for at the moment.")

;; TODO: Model this as a function.
(defconst todo/habits
  (list/concat todo/daily-habits
               todo/adhoc-habits)
  "My habits for today.")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Meetings
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; TODO: Define "meeting".

(defconst todo/daily-meetings
  (->> '("Standup"
         "Lunch")
       (-map #'todo/meeting))
  "Daily, recurrent meetings.")


(defconst todo/day-of-week-meetings
  '(:Monday    '("Lunch")
    :Tuesday   '("Lunch")
    :Wednesday '("Team Lunch")
    :Thursday  '("Lunch")
    :Friday    '("Lunch")
    :Satuday   '()
    :Sunday    '())
  "Meetings that occur depending on the current day of the week.")

(parse-time-string "today")

;; TODO: Support recurrent, non-daily meetings.

(defconst todo/adhoc-meetings
  (->> '("WSE Weekly Standup"
         "Team Lunch"
         "Karisa Explains It All")
       (-map #'todo/meeting))
  "Non-recurrent meetings.")

(defconst todo/meetings
  (list/concat todo/daily-meetings
               todo/adhoc-meetings)
  "My meetings for today.")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Tasks
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defconst todo/tasks
  (->> '("GetEmailCase"
         "Async node workflow"
         "Support C-c in EXWM"
         "Post-its for bathroom mirror"
         "Visit AtomicHabit.com/scorecard"
         "Visit AtomicHabit.com/habitstacking"
         "Create GraphViz for Carpe Diem cirriculum"
         "Create CitC client for local browsing of CE codebase"
         "Respond to SRE emails")
       (-map #'todo/task)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Work queues (today, tomorrow, someday)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; TODO: Generate standup documents from DONE items in the state.

;; TODO: Learn how to create a gen-server style of live, reactive state.
;; TODO: This should probably be `defconst' and a reference to the live state.
(defconst todo/today
  (list/concat
   todo/habits
   todo/meetings
   todo/tasks))

(defconst todo/tomorrow
  '())

(defconst todo/someday
  '())

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; View functions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defun todo/to-org (xs)
  "Map `XS' into a string with `org-mode' syntax."
  ;; TODO: Create function to DRY this code up.
  (let ((meetings (->> xs
                       (-filter #'todo/meeting?)
                       (-map (lambda (x)
                               (s-concat "** TODO " (todo/label x))))
                       (s-join "\n")))
        (tasks (->> xs
                    (-filter #'todo/task?)
                    (-map (lambda (x)
                            (s-concat "** TODO " (todo/label x))))
                    (s-join "\n")))
        (habits (->> xs
                     (-filter #'todo/habit?)
                     (-map (lambda (x)
                             (s-concat "** TODO " (todo/label x))))
                     (s-join "\n"))))
    (s-join "\n" (list
                  (s-concat "* Meetings\n" meetings)
                  (s-concat "* Tasks\n" tasks)
                  (s-concat "* Habits\n" habits)))))

(defun todo/export-to-org (xs)
  "Export `XS' to `todo/org-file-path'."
  (f-write-text (->> xs
                     todo/to-org)
                'utf-8
                todo/org-file-path))

(defun todo/orgify-today ()
  "Exports today's todos to an org file."
  (interactive)
  (todo/export-to-org todo/today)
  (alert (string/concat  "Exported today's TODOs to: " todo/org-file-path)))

(provide 'todo)
;;; todo.el ends here