I'd like to insert a node into a specific place.

Each day, I log in, expand the following nodes: "Engineering worklog" > "2019" > "Q2" > "week 20" > "05/20/15".

I'd love to have a single command to insert all of that at the correct place in my org file, but I can find precious little about inserting nodes into a large org-mode file.

Anyone have something like this or pointers for me?

1 Answer 1


You can try the datetree package I wrote for the purpose of answering your question. With datetree.el in your load-path add the following lines to your .emacs/init.el file:

(require 'datetree)
(setq datetree-root "Engineering worklog"
      datetree-format-string '("%Y" "Q%q" "week %W" "%D"))

Now open the Org file and call datetree-find, which should either jump the current entry or create a new one at the appropriate location. By default entries are placed chronologically with the newest entry at the bottom. If that's not the case for you, you'll have to change datetree-order-reversed-p to t.

What datetree does is it jumps to the first node and moves down sequentially until a subchild matching the current date is found. If a subchild is not found, jump to the matching child and insert a new sibling. Likewise, if a child is not found, jump to the parent node and so on.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.