From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tassilo Horn Subject: [PATCH] org.el (org-agenda-file-p): New predicate function. Date: Tue, 25 May 2010 23:21:55 +0200 Message-ID: <87typv7k3w.fsf@thinkpad.tsdh.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from [140.186.70.92] (port=40348 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OH1Zf-0001Zy-7y for emacs-orgmode@gnu.org; Tue, 25 May 2010 17:22:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OH1Zd-00068U-WC for emacs-orgmode@gnu.org; Tue, 25 May 2010 17:22:07 -0400 Received: from lo.gmane.org ([80.91.229.12]:59248) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OH1Zd-00068N-Pe for emacs-orgmode@gnu.org; Tue, 25 May 2010 17:22:05 -0400 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1OH1Zb-0006me-IX for emacs-orgmode@gnu.org; Tue, 25 May 2010 23:22:03 +0200 Received: from p54af18da.dip0.t-ipconnect.de ([84.175.24.218]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 25 May 2010 23:22:03 +0200 Received: from tassilo by p54af18da.dip0.t-ipconnect.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 25 May 2010 23:22:03 +0200 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: emacs-orgmode@gnu.org The new function `org-agenda-file-p' checks if a given file is an org agenda file. Such a function is very useful in hooks, for example if you want to export agenda files automatically when saving: (defun th-org-mode-init () ;; Update appointments and export to iCalendar when saving. (when (org-agenda-file-p) (add-hook 'after-save-hook 'th-org-agenda-to-appt t t) (add-hook 'after-save-hook 'org-export-icalendar-this-file t t))) (add-hook 'org-agenda-mode-hook 'th-org-agenda-mode-init) --- lisp/org.el | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index d21aa1f..31c5d5a 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -15042,6 +15042,13 @@ used by the agenda files. If ARCHIVE is `ifmode', do this only if (setq files (org-add-archive-files files))) files)) +(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))) + (defun org-edit-agenda-file-list () "Edit the list of agenda files. Depending on setup, this either uses customize to edit the variable -- 1.7.1 See Message-ID: <87vdacp1hi.fsf@thinkpad.tsdh.de> and Carsten's followup.