From: Tassilo Horn <tassilo@member.fsf.org>
To: emacs-orgmode@gnu.org
Subject: [PATCH] org.el (org-agenda-file-p): New predicate function.
Date: Tue, 25 May 2010 23:21:55 +0200 [thread overview]
Message-ID: <87typv7k3w.fsf@thinkpad.tsdh.de> (raw)
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.
reply other threads:[~2010-05-25 21:22 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87typv7k3w.fsf@thinkpad.tsdh.de \
--to=tassilo@member.fsf.org \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.