emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Gregor Zattler <telegraph@gmx.net>
To: emacs-orgmode <emacs-orgmode@gnu.org>, help-gnu-emacs@gnu.org
Subject: automagically add/remove org mode buffers to agenda files list (was: Re: collect info from org files in agenda when open?)
Date: Sun, 14 Jul 2013 16:11:34 +0200	[thread overview]
Message-ID: <20130714141134.GA31324@boo.workgroup> (raw)
In-Reply-To: <878v1aa43m.fsf@ericabrahamsen.net>

Hi Eric, org-mod users and developers,
* Eric Abrahamsen <eric@ericabrahamsen.net> [13. Jul. 2013]:
> Gregor Zattler <telegraph@gmx.net> writes:
>> But I wished there was also the ability to define a list of files
>> which do only contribute to the agenda if already open
>> (preferably with some pattern matching, so one could customize
>> org to add any open org file to the agenda).
> 
> You could certainly do this with a function attached to
> `find-file-hook'. In the function, check if (buffer-file-name) ends in
> ".org": if it does, then `org-agenda-file-to-front' and you're good to
> go.

Your answer motivated me to play with org-mode-hook.  Now I have
the following as part of my init.el:

; start with diary in agenda
(setq org-agenda-files '("~/org/diary.org"))
; automatically add org files to agenda
(add-hook 'org-mode-hook 'org-agenda-file-to-front)
; automagically remove killed org buffers from agenda files list
(add-hook 'kill-buffer-hook 'org-remove-file)

But the last hook does not work as espected.  Instead it says
"Current buffer does not visit a file".  But according to the
documentation kill-buffer-hook is run before the buffer is
actually killed and the buffer is current when calling the hook.
Any ideas what I'm doing wrong?


Ciao, Gregor
-- 
 -... --- .-. . -.. ..--.. ...-.-

  reply	other threads:[~2013-07-14 14:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-12 22:16 collect info from org files in agenda when open? Gregor Zattler
2013-07-13  8:10 ` Noorul Islam K M
2013-07-13  8:33   ` Gregor Zattler
2013-07-13 15:09     ` Eric Abrahamsen
2013-07-14 14:11       ` Gregor Zattler [this message]
2013-07-14 14:22         ` automagically add/remove org mode buffers to agenda files list (was: Re: collect info from org files in agenda when open?) Drew Adams
2013-07-23 11:06           ` Gregor Zattler

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=20130714141134.GA31324@boo.workgroup \
    --to=telegraph@gmx.net \
    --cc=emacs-orgmode@gnu.org \
    --cc=help-gnu-emacs@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).