Automatically set property to avoid double checklist insertions

This commit is contained in:
Daniel Borchmann 2023-03-19 13:21:18 +01:00
parent efa55cb75d
commit 10ee65f55a
No known key found for this signature in database
GPG Key ID: 784AA8DF0CCDF625

View File

@ -881,6 +881,11 @@ determined."
Checklists are inserted before the first child, if existent, or Checklists are inserted before the first child, if existent, or
at the end of the subtree. 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 The checklist consists of a listing of relevant backlinks of the
current item and its parents (without archives) as well as a current item and its parents (without archives) as well as a
template. template.
@ -934,6 +939,10 @@ inserting the checklist."
;; point. ;; point.
(db/org-goto-checklist-item-of-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. (t ;; Default action: insert complete checklist.
;; Checklists are inserted directly before first child, if existent, or ;; Checklists are inserted directly before first child, if existent, or
@ -990,7 +999,9 @@ inserting the checklist."
(insert "\n\nTemplate:") (insert "\n\nTemplate:")
(if (not template-marker) (if (not template-marker)
(insert " none.\n") (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 (define-obsolete-function-alias 'db/org-copy-template
'db/org-insert-checklist 'db/org-insert-checklist