From mboxrd@z Thu Jan 1 00:00:00 1970 From: Richard KLINDA Subject: TIP: set up org-agenda-files automagically Date: Fri, 06 Feb 2009 12:50:47 +0100 Message-ID: <87zlgz942w.fsf@gmail.com> 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 1LVPGy-0003RL-Et for emacs-orgmode@gnu.org; Fri, 06 Feb 2009 06:53:28 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LVPGt-0003Q9-F5 for emacs-orgmode@gnu.org; Fri, 06 Feb 2009 06:53:26 -0500 Received: from [199.232.76.173] (port=42607 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LVPGr-0003Pv-US for emacs-orgmode@gnu.org; Fri, 06 Feb 2009 06:53:22 -0500 Received: from viefep13-int.chello.at ([62.179.121.33]:14001) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LVPGr-0002af-8j for emacs-orgmode@gnu.org; Fri, 06 Feb 2009 06:53:21 -0500 Received: from edge02.upc.biz ([192.168.13.237]) by viefep13-int.chello.at (InterMail vM.7.09.01.00 201-2219-108-20080618) with ESMTP id <20090206115315.XDSO18389.viefep13-int.chello.at@edge02.upc.biz> for ; Fri, 6 Feb 2009 12:53:15 +0100 Received: from ignotus by localhost with local (masqmail 0.2.21) id 1LVPEN-4Bj-00 for ; Fri, 06 Feb 2009 12:50:47 +0100 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 Here is a little code snippet for setting up the org-agenda-files variable via elisp code, to only include files modified in the last X days. I use this, because I have ~500 org files and if I add all of them to org-agenda-files then creating agenda buffers takes up just too much time[1], and it is wasted effort anyway, because I only use a handful of them on a day-to-day basis. ,---- | (defun rk-filter-new-files (max-age files) | "Returns only files that were modified MAX-AGE days ago." | (let ((current-day (time-to-days (current-time)))) | (loop for file in files | for age = (time-to-days (nth 5 (file-attributes file))) | if (< (- current-day age) | max-age) | collect file))) | | (setq org-agenda-files (rk-filter-new-files | 380 | (append (directory-files "~/.xemacs/org/" t nil nil t) | (directory-files "~/.Wiki/" t nil nil t)))) `---- Footnotes: [1] I don't want to add them manually 1-by-1 either. -- Udv, Richard