]> code.delx.au - gnu-emacs/blobdiff - lisp/org/org-icalendar.el
Merge from emacs-23
[gnu-emacs] / lisp / org / org-icalendar.el
index dfc57908fd3c22ca243d0fc5a5489d7849f67675..144f261e42dd5c252b4a8ea78863c513472aadc5 100644 (file)
@@ -1,12 +1,12 @@
 ;;; org-icalendar.el --- iCalendar export for Org-mode
 
-;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
+;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
 ;;   Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.29c
+;; Version: 6.35i
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -47,6 +47,11 @@ The file name should be absolute, the file will be overwritten without warning."
   :group 'org-export-icalendar
   :type 'string)
 
+(defcustom org-icalendar-use-plain-timestamp t
+  "Non-nil means make an event from every plain time stamp."
+  :group 'org-export-icalendar
+  :type 'boolean)
+
 (defcustom org-icalendar-use-deadline '(event-if-not-todo todo-due)
   "Contexts where iCalendar export should use a deadline time stamp.
 This is a list with several symbols in it.  Valid symbol are:
@@ -99,11 +104,11 @@ all-tags    All tags, including inherited ones."
           (const :tag "All tags, including inherited ones" all-tags))))
 
 (defcustom org-icalendar-include-todo nil
-  "Non-nil means, export to iCalendar files should also cover TODO items.
+  "Non-nil means export to iCalendar files should also cover TODO items.
 Valid values are:
-nil         don't inlcude any TODO items
+nil         don't include any TODO items
 t           include all TODO items that are not in a DONE state
-unblocked   include all TODO idems that are not blocked
+unblocked   include all TODO items that are not blocked
 all         include both done and not done items."
   :group 'org-export-icalendar
   :type '(choice
@@ -112,14 +117,25 @@ all         include both done and not done items."
          (const :tag "Unblocked" unblocked)
          (const :tag "All" all)))
 
+(defvar org-icalendar-verify-function nil
+  "Function to verify entries for iCalendar export.
+This can be set to a function that will be called at each entry that
+is considered for export to iCalendar.  When the function returns nil,
+the entry will be skipped.  When it returns a non-nil value, the entry
+will be considered for export.
+This is used internally when an agenda buffer is exported to an ics file,
+to make sure that only entries currently listed in the agenda will end
+up in the ics file.  But for normal iCalendar export, you can use this
+for whatever you need.")
+
 (defcustom org-icalendar-include-bbdb-anniversaries nil
-  "Non-nil means, a combined iCalendar files should include anniversaries.
+  "Non-nil means a combined iCalendar files should include anniversaries.
 The anniversaries are define in the BBDB database."
   :group 'org-export-icalendar
   :type 'boolean)
 
 (defcustom org-icalendar-include-sexps t
-  "Non-nil means, export to iCalendar files should also cover sexp entries.
+  "Non-nil means export to iCalendar files should also cover sexp entries.
 These are entries like in the diary, but directly in an Org-mode file."
   :group 'org-export-icalendar
   :type 'boolean)
@@ -136,7 +152,7 @@ The text will be inserted into the DESCRIPTION field."
          (integer :tag "Max characters")))
 
 (defcustom org-icalendar-store-UID nil
-  "Non-nil means, store any created UIDs in properties.
+  "Non-nil means store any created UIDs in properties.
 The iCalendar standard requires that all entries have a unique identifier.
 Org will create these identifiers as needed.  When this variable is non-nil,
 the created UIDs will be stored in the ID property of the entry.  Then the
@@ -264,8 +280,8 @@ When COMBINE is non nil, add the category to each line."
       (while (re-search-forward re1 nil t)
        (catch :skip
          (org-agenda-skip)
-         (when (boundp 'org-icalendar-verify-function)
-           (unless (funcall org-icalendar-verify-function)
+         (when org-icalendar-verify-function
+           (unless (save-match-data (funcall org-icalendar-verify-function))
              (outline-next-heading)
              (backward-char 1)
              (throw :skip nil)))
@@ -307,6 +323,9 @@ When COMBINE is non nil, add the category to each line."
                  todo (org-get-todo-state)
                  ;; donep (org-entry-is-done-p)
                  ))
+         (when (and (not org-icalendar-use-plain-timestamp)
+                    (not deadlinep) (not scheduledp))
+           (throw :skip t))
          (when (and
                 deadlinep
                 (if todo
@@ -368,6 +387,11 @@ END:VEVENT\n"
        (while (re-search-forward "^&?%%(" nil t)
          (catch :skip
            (org-agenda-skip)
+           (when org-icalendar-verify-function
+             (unless (save-match-data (funcall org-icalendar-verify-function))
+               (outline-next-heading)
+               (backward-char 1)
+               (throw :skip nil)))
            (setq b (match-beginning 0))
            (goto-char (1- (match-end 0)))
            (forward-sexp 1)
@@ -384,7 +408,7 @@ END:VEVENT\n"
        (while (re-search-forward org-todo-line-regexp nil t)
          (catch :skip
            (org-agenda-skip)
-           (when (boundp 'org-icalendar-verify-function)
+           (when org-icalendar-verify-function
              (unless (save-match-data
                        (funcall org-icalendar-verify-function))
                (outline-next-heading)
@@ -577,5 +601,4 @@ a time), or the day by one (if it does not contain a time)."
 (provide 'org-icalendar)
 
 ;; arch-tag: 2dee2b6e-9211-4aee-8a47-a3c7e5bc30cf
-
 ;;; org-icalendar.el ends here