From: Yuri Niyazov <yuri.niyazov@gmail.com>
To: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: Recurse through a directory tree in org-agenda
Date: Fri, 1 May 2015 21:22:20 -0700 [thread overview]
Message-ID: <CACbjG0sgpiT8mgkVuzEP1oDv1wEfJxqL44KSRpQBx9eX9wZZEw@mail.gmail.com> (raw)
It is common to have something like this in an org configuration:
(customize-set-variable 'org-agenda-files '("~/org"))
This means that all the org files in ~/org (but not all the org files
in subdirectories of "~/org") will be automatically included in the
agenda.
It seems like a common request on this mailing list is: what if I
created a fairly involved directory tree with org files throughout,
how do I include all those directories in org-agenda-files? And also,
what if I modify my filesystem and create a new directory somewhere
under "~/org" - do I have to restart Emacs or rerun the code that
configures org?
Here's a solution that seems to take care of everything automatically
for me (and also filters out things that I don't want to include, like
directories named "zz_old", ".git" and "zz_journal")
(require 'find-lisp)
(require 'cl)
(defun yn/recurse-subdirectories (directory)
(let ((predicate
(lambda (pred)
(lexical-let ((p pred))
(lambda (dir parent)
(and (not (or (string= dir ".git")
(string= dir "zz_old")
(string= dir "zz_journal")))
(funcall p dir parent)))))))
(append
(find-lisp-find-files-internal
directory
(funcall predicate 'find-lisp-file-predicate-is-directory)
(funcall predicate 'find-lisp-default-directory-predicate))
(cons directory nil))))
(defadvice org-agenda-files (before yn/org-agenda-files
(&optional unrestricted archives))
(customize-set-variable 'org-agenda-files (yn/recurse-subdirectories
org-directory)))
(ad-activate 'org-agenda-files)
I don't have contributor papers signed with the FSF (yet) but
obviously the intent of this message is for everyone to use this.
reply other threads:[~2015-05-02 4:22 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CACbjG0sgpiT8mgkVuzEP1oDv1wEfJxqL44KSRpQBx9eX9wZZEw@mail.gmail.com \
--to=yuri.niyazov@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).