From mboxrd@z Thu Jan 1 00:00:00 1970 From: Drew Adams Subject: RE: 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 07:22:18 -0700 (PDT) Message-ID: 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 Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <20130714141134.GA31324@boo.workgroup> 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: Gregor Zattler , emacs-orgmode , help-gnu-emacs@gnu.org List-Id: emacs-orgmode.gnu.org > (add-hook 'kill-buffer-hook 'org-remove-file) >=20 > 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.