emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: John Kitchin <jkitchin@andrew.cmu.edu>
To: Christoph Groth <christoph@grothesque.org>
Cc: org-mode-email <emacs-orgmode@gnu.org>
Subject: Re: Temporarily setting agenda files list, cleaning up
Date: Mon, 27 May 2019 08:46:04 -0400	[thread overview]
Message-ID: <CAJ51EToUiFv50yska+J8gyBOYGWeHN2+nzgz0pz2mngd_mfYZA@mail.gmail.com> (raw)
In-Reply-To: <87v9xwf6iu.fsf@neron>

[-- Attachment #1: Type: text/plain, Size: 3922 bytes --]

For running code that should close all buffers that were opened, I use a
macro like this:

(defmacro with-no-new-buffers (&rest body)
  "Run BODY, and kill any new buffers created.
Returns whatever BODY would return."
  (let ((current-buffers (buffer-list)))
    `(prog1
(progn
  ,@body)
       (mapc (lambda (buf)
      (unless (-contains? ',current-buffers buf)
(kill-buffer buf)))
    (buffer-list)))))

For the other kinds of things you listed, check out
https://github.com/jkitchin/scimax/blob/master/scimax-notebook.org,
especially the nb-agenda function. It is more than you want, you can choose
a project, and then get an agenda for the org-files in that project.

Another example is at
https://github.com/jkitchin/scimax/blob/master/scimax-journal.el#L284 where
I get an agenda for journal entries in a date range. You can use this idea
generally, you let-bind the org-agenda-files variable to be the list you
want, and then call org-agenda.

These are a work in progress, but I use them pretty often.

You can restrict the agenda to a file, and even select search with
something like this:

(org-agenda nil "s" "<")




John

-----------------------------------
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu



On Mon, May 27, 2019 at 8:11 AM Christoph Groth <christoph@grothesque.org>
wrote:

> Hello,
>
> I would like to expand my use of Org for notes, and to this end spread
> project-specific org files across my home directory (currently I'm using
> a central directory with one agenda file per year).  For obvious
> reasons, I can't possibly include all these org files in
> org-agenda-files permanently and have them open in Emacs all the time.
>
> Instead, I'm thinking of a setup as follows: I'll reserve
> org-agenda-files for active projects only.  But there will be many other
> org files (for projects that are finished or dormant, general notes,
> etc.), that I would like to be able to search as well.
>
> I saw that some people have solved this problem with a custom search
> solution, even using a database [1], but I think that for my purposes a
> simpler solution mostly using Org's built-in functionality will do.  I'm
> also aware of org-agenda-text-search-extra-files, keeping all my extra
> files there is not satisfactory, because the search possibilities are
> limited (and otherwise it poses the same questions that I will ask
> further below).
>
> 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:
>
> (split-string (shell-command-to-string "find `pwd`/* -name '*.org' -type
> f") "\n" t)
>
> This way, I could easily explore the org files that belong to specific
> subsets of my activities and interests.  I could also search *all* my
> notes, when needed (for now the time this takes should not be a
> problem).
>
> I wonder if anyone has tried a similar setup and would be willing to
> share his experience and ideas.  Specifically, I wonder about the
> following points:
>
> * Do you see any obvious problems with the above idea?
>
> * In Elisp, what is the best way to temporarily set org-agenda-files and
>   later reset it back to the standard value?
>
> * How to automatically close unneeded org buffers that were opened for
>   the temporarily agenda?  The command org-agenda-exit is not
>   satisfactory, because it also kills the buffers that one has just
>   found due to the search, and also it's not automatic.  Perhaps one
>   could close the buffers immediately once the agenda view has been
>   created?
>
> Thanks
> Christoph
>
> [1]
> https://kitchingroup.cheme.cmu.edu/blog/2017/01/03/Find-stuff-in-org-mode-anywhere/
>

[-- Attachment #2: Type: text/html, Size: 5326 bytes --]

  reply	other threads:[~2019-05-27 12:46 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 [this message]
2019-05-27 18:51 ` Thomas Plass
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=CAJ51EToUiFv50yska+J8gyBOYGWeHN2+nzgz0pz2mngd_mfYZA@mail.gmail.com \
    --to=jkitchin@andrew.cmu.edu \
    --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).