summaryrefslogtreecommitdiff
path: root/elchemy-functions.el
diff options
context:
space:
mode:
authorChristian Cunningham <cc@localhost>2024-06-13 16:28:55 -0700
committerChristian Cunningham <cc@localhost>2024-06-13 16:28:55 -0700
commita9e5f06b03ffb9cc28ac2537ce98dc17bf08f66a (patch)
tree65f4c4e05f9631bdef746b50aaec8c01cf5b63c9 /elchemy-functions.el
parent6780fd6b56e943e0b3476a35d8fd28cb5d511c0d (diff)
Agenda in Dashboard
Display the agenda in the dashboard: 1. Breakdown of tasks in their categories 2. Overdue Tasks 3. Upcoming Tasks
Diffstat (limited to 'elchemy-functions.el')
-rw-r--r--elchemy-functions.el38
1 files changed, 38 insertions, 0 deletions
diff --git a/elchemy-functions.el b/elchemy-functions.el
index a5919d7..0c36ad8 100644
--- a/elchemy-functions.el
+++ b/elchemy-functions.el
@@ -56,4 +56,42 @@
(other-window 1)
(term TERM))
+(defun elchemy/replace-nil (STRING &optional REPLACEMENT)
+ "Replace a nil value with an empty string"
+ (unless REPLACEMENT
+ (setq REPLACEMENT " "))
+ (if STRING
+ STRING
+ REPLACEMENT))
+
+(defun elchemy/get-agenda-items (TODO LEVEL)
+ "Get Agenda Items"
+ (let* ((agenda-items-raw (org-ql-select
+ (org-agenda-files)
+ `(todo ,TODO)
+ :sort '(date todo priority)))
+ (agenda-items-plist (mapcar #'(lambda (x) (cl--plist-to-alist (car (cdr x)))) agenda-items-raw))
+ (agenda-items-filtered (seq-filter (lambda (x) (eq (cdr (assoc :level x)) LEVEL)) agenda-items-plist)))
+ (mapcar #'(lambda (x) (cdr (assoc :raw-value x))) agenda-items-filtered)))
+
+(defun elchemy/process-agenda-heading (heading)
+ "Process agenda headings
+
+Returns '((:raw-value . <Heading Text>) (:level <Org Heading Level>) (:priority . <Org Priority>) (:todo-keyword . <Org Todo Keyword>) (:scheduled . <Date Scheduled as Text>))"
+ (let ((heading-alist (cl--plist-to-alist (car (cdr heading)))))
+ `(,(assoc :raw-value heading-alist) ,(assoc :level heading-alist) ,(assoc :priority heading-alist) (:todo-keyword . ,(substring-no-properties (cdr (assoc :todo-keyword heading-alist)))) (:scheduled . ,(cdr (assoc :raw-value (cl--plist-to-alist (nth 2 (assoc :scheduled heading-alist)))))))))
+
+(defun elchemy/format-priority (priority)
+ "Format a priority to the letter or '-' if no priority"
+ (if priority
+ priority
+ 45))
+
+(defun elchemy/format-processed-agenda (agenda-list)
+ "Format a processed agenda to a string:
+[PRIORITY] TODO-KEYWORD: HEADING ~ SCHEDULED"
+ (apply #'concat (mapcar #'(lambda (x)
+ (concat (format "[%c] " (elchemy/format-priority (cdr (assoc :priority x)))) (cdr (assoc :todo-keyword x)) ": " (cdr (assoc :raw-value x)) " ~ " (cdr (assoc :scheduled x)) "\n"))
+ agenda-list)))
+
(provide 'elchemy-functions)