diff options
| author | Blake Romero <blake@developercraft.com> | 2025-10-19 02:18:14 +0100 |
|---|---|---|
| committer | Blake Romero <blake@developercraft.com> | 2025-10-19 02:18:14 +0100 |
| commit | 768abdb2b3316fd07628a5e65d7343077ba89e95 (patch) | |
| tree | 46565bdb78c6f0baae7c6657a01befcf9423d403 | |
| parent | d6a25b1689082d4762cdf20a33bd3838e31d6c4d (diff) | |
Add dynamic datetree capture for planner
| -rw-r--r-- | emacs-config.org | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/emacs-config.org b/emacs-config.org index 5f36861..f424eee 100644 --- a/emacs-config.org +++ b/emacs-config.org @@ -1320,16 +1320,34 @@ Personal capture templates. :empty-lines-after 1) org-capture-templates) + (defun +find-or-create-datetree-heading (heading) + "Find HEADING within datetree structure and create it if it doesn't exist. + This prevents duplicate headings when inserting under a datetree via the + file+function target in `org-capture-templates'." + (org-datetree-find-date-create + (org-date-to-gregorian (org-today)) t) + (unless (re-search-forward (concat "^\\*.+ " heading) nil t) + (end-of-buffer) + (delete-blank-lines) + (insert (format "**** %s" heading)))) + (cl-pushnew '("pp" "Plan Today" checkitem - (file+olp+datetree "agenda/planner.org") - nil - :empty-lines-after 1 - :jump-to-captured t) + (file+function "agenda/planner.org" + (lambda () (+find-or-create-datetree-heading "Plan"))) + nil :empty-lines-after 1) + org-capture-templates) + + (cl-pushnew + '("pn" "Planner Note" plain + (file+function "agenda/planner.org" + (lambda () (+find-or-create-datetree-heading "Note"))) + nil :empty-lines-after 1) org-capture-templates) (cl-pushnew - '("pn" "Note" entry (file "notes/notes.org") + '("pN" "Note" entry + (file "notes/notes.org") <<capture-note-template>> :empty-lines-after 1) org-capture-templates) |
