Revised template functions to include org ID links

This commit is contained in:
Random936 2023-11-24 17:20:40 -08:00
parent b911096899
commit 25b18752e7

View File

@ -1,3 +1,6 @@
:PROPERTIES:
:ID: D6E04450-9FB0-47BD-BE2A-A8BEE3EED201
:END:
#+TITLE: Custom Elisp Functions
As of now, I haven't added anything here, though I do expect to start adding some custom functions as I learn more about Elisp.
@ -7,19 +10,20 @@ 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/get-todos-with-priority (priority files)
(let ((items '()))
(org-map-entries
(lambda ()
(when (equal priority (cdr (assoc "PRIORITY" (org-entry-properties))))
(push (cdr (assoc "ITEM" (org-entry-properties))) items)))
"TODO=\"TODO\""
files)
items))
(defun jm/get-todos-with-priority-helper ()
(let ((item-priority (org-entry-get nil "PRIORITY"))
(item-name (org-entry-get nil "ITEM"))
(item-id (car (org-property-values "ID"))))
(when (and item-id (equal priority item-priority))
(format "- [ ] [[id:%s][%s]]" item-id item-name))))
(defun jm/format-org-todo-items (items)
(mapconcat (lambda (item) (concat "- [ ] " item))
items
"\n"))
(defun jm/get-todos-with-priority (priority files)
(mapconcat #'identity
(delq nil (org-map-entries
#'jm/get-todos-with-priority-helper
"TODO=\"TODO\""
files)) "\n"))
(jm/get-todos-with-priority "A" (org-agenda-files))
#+end_src