From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Gregor Zattler Newsgroups: gmane.emacs.help,gmane.emacs.orgmode 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> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1373811129 6265 80.91.229.3 (14 Jul 2013 14:12:09 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 14 Jul 2013 14:12:09 +0000 (UTC) To: 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:12:11 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 1UyN21-0001cu-Br for geh-help-gnu-emacs@m.gmane.org; Sun, 14 Jul 2013 16:12:09 +0200 Original-Received: from localhost ([::1]:33252 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UyN20-0002CP-OG for geh-help-gnu-emacs@m.gmane.org; Sun, 14 Jul 2013 10:12:08 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56340) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UyN1n-0002CJ-4Z for help-gnu-emacs@gnu.org; Sun, 14 Jul 2013 10:11:58 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UyN1j-00023p-Km for help-gnu-emacs@gnu.org; Sun, 14 Jul 2013 10:11:55 -0400 Original-Received: from mout.gmx.net ([212.227.17.20]:52282) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UyN1j-0001za-Cj; Sun, 14 Jul 2013 10:11:51 -0400 Original-Received: from boo.workgroup ([87.187.179.97]) by mail.gmx.com (mrgmx102) with ESMTPSA (Nemesis) id 0Meduu-1UnQp30Zmi-00OKeB; Sun, 14 Jul 2013 16:11:49 +0200 Original-Received: from grfz by boo.workgroup with local (Exim 4.80) (envelope-from ) id 1UyN1c-0001yw-5b; Sun, 14 Jul 2013 16:11:44 +0200 Mail-Followup-To: emacs-orgmode , help-gnu-emacs@gnu.org Content-Disposition: inline In-Reply-To: <878v1aa43m.fsf@ericabrahamsen.net> User-Agent: Mutt/1.5.21 (2010-09-15) X-Provags-ID: V03:K0:ZogEIeAYn3md59gaoj6G+fryZvT/M85oyScH5bK5I4Ow1TRKwK3 Pum/ZCj4JazKSCkZ7LBFmb13YBBhkfe4Y+MHmZurtyCvz3HVLJ+wnqlSUVy69j1US1I5H+f m3sbWR1PNUv9Ebimq2nJGpyNihTrHa9RUlIKZqPPKCCc3OuMPVcRmUAyY5XaD6aqFf6ghGN SwOFWUBzE379CMiKedHIw== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 212.227.17.20 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:92120 gmane.emacs.orgmode:74673 Archived-At: 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 -- -... --- .-. . -.. ..--.. ...-.-