Just for the record, here's the whole thing from my .emacs file:
(defun gp-archive-when-done ()
"Archive current entry if it is marked as DONE, is level 2, & has no
repeater (see `org-done-keywords')."
(when (and (org-entry-is-done-p) (= 2 (org-reduced-level
(org-outline-level)) ) (not (org-get-repeat)))
(org-archive-subtree)))
(add-hook 'org-after-todo-state-change-hook
#'gp-archive-when-done)
On 2/7/26 1:37 PM, George Pearson wrote:
Yep, that did it. Thanks!
In case someone else tries this, I should mention that it doesn't
handle the complex case of when I terminate the repetition for good
with C-u -1, but I almost never do that, and can easily archive that
one manually with C-c $.
Thanks again,
- George
On 2/7/26 9:46 AM, Christian Moe wrote:
George Pearson<[email protected]> writes:
To keep my master org file tidy, I want to automatically archive each
level 2 headline when I mark it done.
This works great using org-after-todo-state-change-hook, EXCEPT when
the headline has a repeater. Then org-entry-is-done-p returns TRUE
even though the headline will be resurrected.
You can use `org-get-repeat' to check if the timestamp of the current
entry contains a repeater. So the function you add to
`org-after-todo-state-change-hook' could contain an additional check
along these lines:
(unless (org-get-repeat)
(org-archive-subtree))
Does this help?
Regards,
Christian