From 3289b8a2023ee5a47744c4eb09f4c6b87da18bdc Mon Sep 17 00:00:00 2001 From: KemoNine Date: Thu, 25 Aug 2022 15:18:07 -0400 Subject: [PATCH] add todo capture template that can have scheduled/deadline dates set via y/n/date prompts. see below for example template ** TODO [#%(oc/prmt `"Priority (A-F)`" 'td-priority)] %(oc/prmt `"Title`" 'td-title) %(oc/inc_date `"scheduled date`" `"SCHEDULED: `") %(oc/inc_date `"deadline date`" `"DEADLINE: `") %? --- org/config-org-capture.el | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/org/config-org-capture.el b/org/config-org-capture.el index 7437642..d161bf3 100644 --- a/org/config-org-capture.el +++ b/org/config-org-capture.el @@ -1,6 +1,35 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; inspiration for conditional capture template : https://storax.github.io/blog/2016/05/02/org-capture-tricks/ + +; helper functions +(defvar oc-capture-prmt-history nil + "History of prompt answers for org capture.") +(defun oc/prmt (prompt variable) + "PROMPT for string, save it to VARIABLE and insert it." + (make-local-variable variable) + (set variable (read-string (concat prompt ": ") nil oc-capture-prmt-history))) +(defun oc/inc (what text &rest fmtvars) + "Ask user to include WHAT. If user agrees return TEXT." + (when (y-or-n-p (concat "Include " what "?")) + (apply 'format text fmtvars))) +(defun oc/inc (what text &rest fmtvars) + "Ask user to include WHAT. If user agrees return TEXT." + (when (y-or-n-p (concat "Include " what "?")) + (apply 'format text fmtvars))) +(defun oc/inc_date (what prefix) + "Ask user to include a date. If user agrees prompt for date." + (when (y-or-n-p (concat "Include " what "?")) + (concat prefix (org-time-stamp nil)))) + ; orgmode capture templates (setq org-capture-templates '( + ("d" "TODO" entry + (file+headline "~/org/_todo.org" "Active") + (file "~/org/template_todo.org") + :prepend t + :immediate-finish "f" + :jump-to-captured "t" + ) ("b" "Blog Post" entry (file+headline "~/org/blog/_blog.org" "Drafts") (file "~/org/template_blog.org")