summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--emacs-config.org28
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)