[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] Temporarily setting agenda files list, cleaning up
From: |
Thomas Plass |
Subject: |
Re: [O] Temporarily setting agenda files list, cleaning up |
Date: |
Mon, 27 May 2019 20:51:29 +0200 |
Christoph Groth wrote at 14:04 on May 27, 2019:
: Instead, I imagine a custom Emacs command to launch an agenda with
: org-agenda-files that is temporarily set to a list of files that depends
: on the current context. For starters, this list could contain all the
: org files under the current directory:
This will use a private set of 'org-agenda-files and kill their
buffers after executing `org-agenda-list':
(defun Groth/agenda-list (&optional dir)
(interactive)
(let* ((project-dir (or dir default-directory))
(org-agenda-files (directory-files-recursively project-dir "\\.org$"))
tmp-agenda-buffer)
(unwind-protect
;; FIXME: set org-agenda-list args as necessary: &optional ARG
START-DAY SPAN WITH-HOUR)
(org-agenda-list)
(mapc
(lambda (f)
(and (setq tmp-agenda-buffer (find-buffer-visiting f))
(kill-buffer tmp-agenda-buffer)))
org-agenda-files))))
Call it like this:
M-x Groth/agenda-list
or eval
(Groth/agenda-list "/path/to/dir")
I just whipped this up and it might need improvements such as optional
prompting for a search directory and a set of arguments to
`org-agenda-list' that fit your needs (refer to its docstring). Note
that buffers for files on the old value of 'org-agenda-files that are
already open will be killed, too.
Regards
Thomas