From 10ee65f55a7e64173d173999a026bdf6fb2c5bb3 Mon Sep 17 00:00:00 2001 From: Daniel Borchmann Date: Sun, 19 Mar 2023 13:21:18 +0100 Subject: [PATCH] Automatically set property to avoid double checklist insertions --- site-lisp/db-org.el | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/site-lisp/db-org.el b/site-lisp/db-org.el index 94798d4..33f8a62 100644 --- a/site-lisp/db-org.el +++ b/site-lisp/db-org.el @@ -881,6 +881,11 @@ determined." Checklists are inserted before the first child, if existent, or at the end of the subtree. +After inserting a checklist, add the property +CHECKLIST_INSERTED_P with value `t' to item at point. Checklists +are not inserted if this property with this value is already +present, to avoid double insertions of checklists. + The checklist consists of a listing of relevant backlinks of the current item and its parents (without archives) as well as a template. @@ -934,6 +939,10 @@ inserting the checklist." ;; point. (db/org-goto-checklist-item-of-point)) + ((string= (org-entry-get (point) "CHECKLIST_INSERTED_P") + "t") + (message "Checklist already inserted, not inserting again.")) + (t ;; Default action: insert complete checklist. ;; Checklists are inserted directly before first child, if existent, or @@ -990,7 +999,9 @@ inserting the checklist." (insert "\n\nTemplate:") (if (not template-marker) (insert " none.\n") - (db/org-copy-body-from-item-to-point template-marker)))))) + (db/org-copy-body-from-item-to-point template-marker))) + + (org-entry-put (point) "CHECKLIST_INSERTED_P" "t")))) (define-obsolete-function-alias 'db/org-copy-template 'db/org-insert-checklist