From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: Canonical way to check if an org file is an agenda file? Date: Tue, 25 May 2010 16:35:41 +0200 Message-ID: References: <87vdacp1hi.fsf@thinkpad.tsdh.de> Mime-Version: 1.0 (Apple Message framework v936) Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Return-path: Received: from [140.186.70.92] (port=55442 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OGvER-0007iD-W0 for emacs-orgmode@gnu.org; Tue, 25 May 2010 10:35:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OGvEQ-0006WH-KU for emacs-orgmode@gnu.org; Tue, 25 May 2010 10:35:47 -0400 Received: from mail-wy0-f169.google.com ([74.125.82.169]:35100) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OGvEQ-0006Vv-GW for emacs-orgmode@gnu.org; Tue, 25 May 2010 10:35:46 -0400 Received: by wyf19 with SMTP id 19so99074wyf.0 for ; Tue, 25 May 2010 07:35:45 -0700 (PDT) In-Reply-To: <87vdacp1hi.fsf@thinkpad.tsdh.de> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Tassilo Horn Cc: emacs-orgmode@gnu.org On May 25, 2010, at 3:14 PM, Tassilo Horn wrote: > Hi all, > > I use org files for anything I once used plain text files, so that I > can > use all org features. > > Unfortunately, for my agenda files I do some additional work. For > example, I export my agenda files to iCalendar and show them with > KOrganizer. And I update the list of appointments. > > To do that, I add some functions to `after-save-hook' in org-mode > buffers, if that file is an agenda file. But the test that checks if > `buffer-file-name' is an agenda file is very fragile and only > matches my > current setup (`org-agenda-files' is a list of exactly one directory). > > So is there a canonical way to check if a file is an agenda file, > something like `org-agenda-file-p'? > > Argh, after writing this, I've discovered the function > `org-agenda-files', which can be used to write such a predicate. So > how > about something like this? > > --8<---------------cut here---------------start------------->8--- > (defun org-agenda-file-p (&optional file) > "Return non-nil, if FILE is an agenda file. > If FILE is omitted, use the file associated with the current > buffer." > (member (or file (buffer-file-name)) > (org-agenda-files t))) > --8<---------------cut here---------------end--------------->8--- > > If we agree that this is useful, I can wrap up a git patch this > evening. > Of course, you can also add that code on your own and add a meaningful > log entry. Sure, this would be useful. - Carsten > > Bye, > Tassilo > > > _______________________________________________ > Emacs-orgmode mailing list > Please use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode - Carsten