Xavier Maillard writes:
> >> I use something that I thought your users might find handy. It
> >> all completed todo items to be automatically flushed to the archive
> >> whenever I save my todo file.
> How about having it auto-archive completed TODOs that were finished
> than a configurable number of days ago? I'd find that pretty useful.
> Sounds like the expiration mechanism one can find into gnus. I like the
Quite a nice idea. In fact... DONE.
(defvar org-my-archive-expiry-days 2
"The number of days after which a completed task should be auto-archived.
This can be 0 for immediate, or a floating point value.")
(defun org-my-archive-done-tasks ()
(concat "\\* \\(" (regexp-opt org-done-keywords) "\\) "))
(concat "- State \"\\(" (regexp-opt org-done-keywords)
(while (re-search-forward done-regexp nil t)
(let ((end (save-excursion
(setq begin (point))
(when (re-search-forward state-regexp end t)
(let* ((time-string (match-string 2))
(when-closed (org-parse-time-string time-string)))
(if (>= (time-to-number-of-days
(apply #'encode-time when-closed)))
(defalias 'archive-done-tasks 'org-my-archive-done-tasks)