Hello, Nikolai Weibull <n...@disu.se> writes:
> * org-agenda.el (org-agenda-insert-diary-strategy): Add new value > 'date-tree-last. > (org-agenda-insert-diary-make-new-entry): Handle > `org-agenda-insert-diary-strategy' set to 'date-tree-last. > > To allow for diary entries to be entered in time order in the date tree, > add a new value to `org-agenda-insert-diary-strategy' that allows for > this. The code for handling this value, 'date-tree-last, is a bit > tricky, as we need to keep track of whether the date-tree already had > one or more entries for the given date. Thank you. > + (let ((last (eq org-agenda-insert-diary-strategy 'date-tree-last)) > + (has-children (save-excursion (org-goto-first-child)))) > + (if (not (and last has-children)) > + (outline-next-heading) > + (org-goto-first-child) > + (while (org-get-next-sibling))) > + (org-back-over-empty-lines) > + (unless (looking-at "[ \t]*$") (save-excursion (insert "\n"))) > + (org-insert-heading nil t) > + (unless has-children > + (org-do-demote))) This part is incorrect, when tree is ill-formed, and slightly inefficient when there are many children. Assuming point is on the parent headline, I think a faster way to do this would be (org-end-of-subtree t t) (org-insert-heading nil t) (org-do-demote) You don't need `has-children' binding at all. Regards, -- Nicolas Goaziou