Updated daily todos functions

This commit is contained in:
Random936 2023-12-23 10:19:50 -08:00
parent 9d87338b02
commit 5808aa4054

View File

@ -7,39 +7,35 @@ As of now, I haven't added anything here, though I do expect to start adding som
These functions are for my org roam daily capture template.
#+begin_src emacs-lisp
(defun jm/daily-todos-filter-tasks (helper query files)
(let ((entries (org-map-entries helper query files)))
(defun jm/dt-filter-tasks (helper query)
(let ((entries (org-map-entries helper query 'agenda)))
(mapconcat #'identity (delq nil entries) "\n")))
(defun jm/daily-todos-format-link ()
(defun jm/dt-format-link (prefix)
(let ((item-name (org-entry-get nil "ITEM"))
(item-id (or (org-entry-get nil "ID")
(car (org-property-values "ID")))))
(when (stringp item-id)
(format "- [ ] [[id:%s][%s]]" item-id item-name))))
(format "%s [[id:%s][%s]]" prefix item-id item-name))))
(defun jm/dt-get-priority (priority)
(jm/dt-filter-tasks
(lambda () (when (equal priority (org-entry-get nil "PRIORITY"))
(jm/dt-format-link "-")))
"TODO=\"TODO\"|TODO=\"IN PROGRESS\""))
(defun jm/daily-todos-get-priority (priority)
(jm/daily-todos-filter-tasks
(lambda ()
(when (equal priority (org-entry-get nil "PRIORITY"))
(jm/daily-todos-format-link)))
"TODO=\"IN PROGRESS\""
(org-agenda-files)))
(defun jm/dt-get-due-today ()
(jm/dt-filter-tasks
(lambda () (when (member (org-get-todo-state) '("TODO" "IN PROGRESS"))
(jm/dt-format-link "- [ ]")))
(format-time-string "DEADLINE<=\"<%Y-%m-%d>\""
(or (org-capture-get :default-time) (current-time)))))
(defun jm/dt-get-status (status)
(jm/dt-filter-tasks (lambda () (jm/dt-format-link "- [ ]"))
(concat "TODO=\"" status "\"")))
(defun jm/daily-todos-get-due-today ()
(jm/daily-todos-filter-tasks
(lambda ()
(when (member (org-get-todo-state) '("TODO" "IN PROGRESS"))
(jm/daily-todos-format-link)))
(format-time-string
"DEADLINE<=\"<%Y-%m-%d>\""
(or (org-capture-get :default-time) (current-time)))
(org-agenda-files)))
(defun jm/daily-todos-dynamic-habits (habit week-days)
(defun jm/dt-dynamic-habits (habit week-days)
(let* ((org-date (or (org-capture-get :default-time) (current-time)))
(today (downcase (format-time-string "%a" org-date))))
(when (seq-contains-p week-days today) habit)))