From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gregor Zattler Subject: Re: automagically add/remove org mode buffers to agenda files list (was: Re: collect info from org files in agenda when open?) Date: Tue, 23 Jul 2013 13:06:23 +0200 Message-ID: <20130723110623.GE21141@boo.workgroup> References: <20130712221620.GC15939@boo.workgroup> <87ppumnan8.fsf@noman.maa.corp.collab.net> <20130713083315.GA20339@boo.workgroup> <878v1aa43m.fsf@ericabrahamsen.net> <20130714141134.GA31324@boo.workgroup> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:47524) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1aQW-0007tX-6g for emacs-orgmode@gnu.org; Tue, 23 Jul 2013 07:06:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V1aQT-0007x4-6P for emacs-orgmode@gnu.org; Tue, 23 Jul 2013 07:06:44 -0400 Received: from mout.gmx.net ([212.227.17.22]:54374) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1aQS-0007wm-TL for emacs-orgmode@gnu.org; Tue, 23 Jul 2013 07:06:41 -0400 Received: from boo.workgroup ([82.83.3.34]) by mail.gmx.com (mrgmx001) with ESMTPSA (Nemesis) id 0MIe0O-1UzOZ510Ce-002JDw for ; Tue, 23 Jul 2013 13:06:39 +0200 Content-Disposition: inline In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Drew Adams Cc: emacs-orgmode Hi Drew, org-mode-community, * Drew Adams [14. Jul. 2013]: >> (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? > > I have no idea what `org-remove-file' does, but if it expects > the current buffer to be visiting a file then that explains > your problem. `kill-buffer-hook' is run whenever ANY buffer is > killed, not just a buffer visiting a file. And Emacs uses lots > of buffers that are not visiting files. > > What you can do is use a different function, `foo', that first > tests whether the current buffer is the kind of buffer you want > to apply `org-remove-file' to, and if so invoke that, and if not > do nothing. Thanks, this helped. For the record: I wrote function which tests if the current buffer is associated with a file and if it is in org-mode. Iff so I remove it from the list of agenda files. Ciao, Gregor -- -... --- .-. . -.. ..--.. ...-.-