emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: thunk2@arcor.de (Thomas Plass)
To: Christoph Groth <christoph@grothesque.org>
Cc: emacs-orgmode@gnu.org
Subject: Re: Temporarily setting agenda files list, cleaning up
Date: Mon, 27 May 2019 20:51:29 +0200	[thread overview]
Message-ID: <23788.12721.384364.291804@AGAME7.local> (raw)
In-Reply-To: Your message of Monday, May 27 2019 14:04:09 (ID: <87v9xwf6iu.fsf@neron>).


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

  parent reply	other threads:[~2019-05-27 18:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-27 12:04 Temporarily setting agenda files list, cleaning up Christoph Groth
2019-05-27 12:46 ` John Kitchin
2019-05-27 18:51 ` Thomas Plass [this message]
2019-05-28 15:12   ` Christoph Groth

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=23788.12721.384364.291804@AGAME7.local \
    --to=thunk2@arcor.de \
    --cc=christoph@grothesque.org \
    --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).