From 25b18752e7b0e1a5e666416d6cf4b9436a7a173f Mon Sep 17 00:00:00 2001 From: Random936 Date: Fri, 24 Nov 2023 17:20:40 -0800 Subject: [PATCH] Revised template functions to include org ID links --- .emacs.d/functions.org | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/.emacs.d/functions.org b/.emacs.d/functions.org index 4977a0c..8682c24 100644 --- a/.emacs.d/functions.org +++ b/.emacs.d/functions.org @@ -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