Xavier Maillard <[EMAIL PROTECTED]> writes: > >> I use something that I thought your users might find handy. It causes > >> 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 more > 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 > idea.
Quite a nice idea. In fact... DONE. John (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 () (interactive) (save-excursion (goto-char (point-min)) (let ((done-regexp (concat "\\* \\(" (regexp-opt org-done-keywords) "\\) ")) (state-regexp (concat "- State \"\\(" (regexp-opt org-done-keywords) "\\)\"\\s-*\\[\\([^]\n]+\\)\\]"))) (while (re-search-forward done-regexp nil t) (let ((end (save-excursion (outline-next-heading) (point))) begin) (goto-char (line-beginning-position)) (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 (time-subtract (current-time) (apply #'encode-time when-closed))) org-my-archive-expiry-days) (org-archive-subtree))))))))) (defalias 'archive-done-tasks 'org-my-archive-done-tasks) _______________________________________________ Emacs-orgmode mailing list Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode