Thanks for the feedback. I attach a squashed updated patch for part 2. You can also see the unsquashed changes at https://github.com/jackkamm/org-mode/tree/2024-grouped-weektree-rebase >> +(defun org-datetree-find-create-entry > Please also document how `org-datetree-add-timestamp' affects this function. Done. On reviewing this I also found a bug (datestamp added again if entry already existed) -- I fixed it and added a unit test. >> + ;; Support the old way of tree placement, using a property >> + (cond >> + ((seq-set-equal-p time-grouping '(year month day)) >> + "DATE_TREE") >> + ((seq-set-equal-p time-grouping '(year month)) >> + "DATE_TREE") >> + ((seq-set-equal-p time-grouping '(year week day)) >> + "WEEK_TREE"))) > > It would be a good idea to add a few tests for this scenario. > To make sure that refactoring did not break things. There was already a couple tests for DATE_TREE and WEEK_TREE, but I've added a few more now, mainly around finding existing headings (the previous tests only created new headings under the DATE_TREE or WEEK_TREE). > Why do you need object granularity by default (second call to > `org-element-parse-buffer')? > Also, more importantly, do you have to run the full parsing here? Maybe > utilize `org-element-cache-map' instead? Full parsing is going to be > much slower. I've switched to `org-element-cache-map' now -- thanks for the info about it. > It is undocumented in the `org-datetree--find-create-subheading' > docstring that it returns something. I changed the return behavior and documented it. It now returns non-nil if the subheading already exists -- this is needed to prevent adding a datestamp twice when `org-datetree-add-timestamp'. Finally, I made one more substantial change -- I now allow :tree-type to be a function in the org-capture template. This allows using new types of datetrees from `org-datetree-find-create-hierarchy' with org-capture. Relatedly, I made `org-datetree-comparefun-from-regex' public to help with building new types of datetrees.