From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.help,gmane.emacs.orgmode 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> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1373811759 12887 80.91.229.3 (14 Jul 2013 14:22:39 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 14 Jul 2013 14:22:39 +0000 (UTC) To: Gregor Zattler , emacs-orgmode , help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Jul 14 16:22:39 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UyNC9-0000Rm-N7 for geh-help-gnu-emacs@m.gmane.org; Sun, 14 Jul 2013 16:22:37 +0200 Original-Received: from localhost ([::1]:35773 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UyNC9-0004TU-2v for geh-help-gnu-emacs@m.gmane.org; Sun, 14 Jul 2013 10:22:37 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58813) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UyNBv-0004TB-Ls for help-gnu-emacs@gnu.org; Sun, 14 Jul 2013 10:22:24 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UyNBu-0005MV-Oy for help-gnu-emacs@gnu.org; Sun, 14 Jul 2013 10:22:23 -0400 Original-Received: from aserp1040.oracle.com ([141.146.126.69]:27744) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UyNBu-0005MO-Ip; Sun, 14 Jul 2013 10:22:22 -0400 Original-Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r6EEMIf2022849 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 14 Jul 2013 14:22:20 GMT Original-Received: from userz7021.oracle.com (userz7021.oracle.com [156.151.31.85]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r6EEMIZx022179 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 14 Jul 2013 14:22:18 GMT Original-Received: from abhmt108.oracle.com (abhmt108.oracle.com [141.146.116.60]) by userz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r6EEMHQw022170; Sun, 14 Jul 2013 14:22:17 GMT In-Reply-To: <20130714141134.GA31324@boo.workgroup> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.7 (607090) [OL 12.0.6668.5000 (x86)] X-Source-IP: ucsinet21.oracle.com [156.151.31.93] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 141.146.126.69 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor 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 Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:92121 gmane.emacs.orgmode:74674 Archived-At: > (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.