From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Wiegley Subject: Re: Autoarchiving done entries Date: Mon, 03 Sep 2007 22:17:44 -0400 Message-ID: References: <87lkbomqjd.fsf@skiddlydee.com> <200709040100.l8410JUE004132@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1ISNzo-0004Sh-Ho for emacs-orgmode@gnu.org; Mon, 03 Sep 2007 22:18:28 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1ISNzl-0004R6-Ra for emacs-orgmode@gnu.org; Mon, 03 Sep 2007 22:18:28 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ISNzl-0004R3-Li for emacs-orgmode@gnu.org; Mon, 03 Sep 2007 22:18:25 -0400 Received: from fyodor.hcoop.net ([64.20.38.170]) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1ISNzl-0003P9-EE for emacs-orgmode@gnu.org; Mon, 03 Sep 2007 22:18:25 -0400 Received: from [72.22.155.27] (helo=Hermes.local) by fyodor.hcoop.net with esmtpsa (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1ISO12-0008Ts-MX for emacs-orgmode@gnu.org; Mon, 03 Sep 2007 22:19:45 -0400 In-Reply-To: <200709040100.l8410JUE004132@localhost.localdomain> (Xavier Maillard's message of "Tue\, 4 Sep 2007 03\:00\:19 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Xavier Maillard 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)