Ensure `CHECKLIST_INSERTED_P` will be inserted at original heading

When a checklist template contains headings on its own, the
`CHECKLIST_INSERTED_P` property until now would be inserted at the last heading
in this template, instead of at the heading where the template is supposed to be
inserted in the first place.  Fixed this.
This commit is contained in:
Daniel - 2023-05-06 15:30:16 +02:00
parent 7db9f8d56c
commit fa56dfdd4d
Signed by: dbo
GPG Key ID: 784AA8DF0CCDF625
1 changed files with 53 additions and 48 deletions

View File

@ -1090,6 +1090,11 @@ inserting the checklist."
(t ;; Default action: insert complete checklist.
;; Let's remember where we are, so that latter on CHECKLIST_INSERTED_P
;; will be inserted at the original heading (where we are now) and not
;; at possible new subtrees coming from the template.
(save-mark-and-excursion
;; Checklists are inserted directly before first child, if existent, or
;; at end of subtree
(org-show-entry)
@ -1144,7 +1149,7 @@ 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")
(db/org-goto-first-open-checkbox-in-subtree))))