From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gregor Zattler 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 Message-ID: <20130714141134.GA31324@boo.workgroup> References: <20130712221620.GC15939@boo.workgroup> <87ppumnan8.fsf@noman.maa.corp.collab.net> <20130713083315.GA20339@boo.workgroup> <878v1aa43m.fsf@ericabrahamsen.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <878v1aa43m.fsf@ericabrahamsen.net> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org To: emacs-orgmode , help-gnu-emacs@gnu.org List-Id: emacs-orgmode.gnu.org Hi Eric, org-mod users and developers, * Eric Abrahamsen [13. Jul. 2013]: > Gregor Zattler 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 -- -... --- .-. . -.. ..--.. ...-.-