In my org file, I have the following lines:

#+STARTUP: logdone logrepeat logreschedule logredeadline logrefile logdrawer
#+ARCHIVE: ::datetree/

When I mark a repeat task done, I want to:

  1. Continue doing everything that is happening now (the task gets a new scheduled date, an entry is added in the :LOGBOOK: drawer, etc.) and additionally,

  2. Make an entry in the datetree with DONE as the state for the task

How do I achieve this?

1 Answer 1


Does this do what you want?

(require 'org-datetree)
(defun my/log-to-datetree ()
  "Log the done item to the datetree."
  (when (equal org-state "DONE")
     (format "* DONE %s" (nth 4 (org-heading-components)))

(add-hook 'org-after-todo-state-change-hook #'my/log-to-datetree t)
  • No. It does nothing for me.
    – deshmukh
    Aug 26, 2019 at 9:46
  • Turns out a nil snuck into the call to add-hook. I edited the code above to fix it, and also made sure that org-datetree is loaded. Seems to work with both Org 8 and Org 9 on my system.
    – Win
    Sep 1, 2019 at 20:44

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.