Insert checklists at end of subtrees, before possible children
This commit is contained in:
parent
a01bbe28e7
commit
d4043f8dd9
@ -878,6 +878,9 @@ determined."
|
||||
(defun db/org-insert-checklist (arg)
|
||||
"Insert checklist for Org Mode item at point.
|
||||
|
||||
Checklists are inserted before the first child, if existent, or
|
||||
at the end of the subtree.
|
||||
|
||||
The checklist consists of a listing of relevant backlinks of the
|
||||
current item and its parents (without archives) as well as a
|
||||
template.
|
||||
@ -931,9 +934,22 @@ inserting the checklist."
|
||||
;; point.
|
||||
(db/org-goto-checklist-item-of-point))
|
||||
|
||||
(t
|
||||
;; Default action: insert complete checklist. Start with inserting
|
||||
;; relevant backlinks, when available.
|
||||
(t ;; Default action: insert complete checklist.
|
||||
|
||||
;; Checklists are inserted directly before first child, if existent, or
|
||||
;; at end of subtree
|
||||
(org-show-subtree)
|
||||
(if (org-goto-first-child)
|
||||
;; Move back from heading; code taken from `org-end-of-subtree'
|
||||
(when (memq (preceding-char) '(?\n ?\^M))
|
||||
;; Go to end of line before heading
|
||||
(forward-char -1)
|
||||
(when (memq (preceding-char) '(?\n ?\^M))
|
||||
;; leave blank line before heading
|
||||
(forward-char -1)))
|
||||
(org-end-of-subtree 'invisible-ok))
|
||||
|
||||
;; Insert relevant backlinks, when available.
|
||||
(let ((parent-depth (--when-let (org-entry-get (point) "CHECKLIST_BACKLINK_DEPTH" nil)
|
||||
(string-to-number it)))
|
||||
number-of-backlinks
|
||||
|
||||
Loading…
Reference in New Issue
Block a user