;;; org-icalendar.el --- iCalendar export for Org-mode
-;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
-;; Free Software Foundation, Inc.
+;; Copyright (C) 2004-2012 Free Software Foundation, Inc.
;; Author: Carsten Dominik <carsten at orgmode dot org>
;; Keywords: outlines, hypermedia, calendar, wp
;; Homepage: http://orgmode.org
-;; Version: 7.4
;;
;; This file is part of GNU Emacs.
;;
- The alarm will go off N minutes before the event
- only a DISPLAY action is defined."
:group 'org-export-icalendar
+ :version "24.1"
:type 'integer)
(defcustom org-icalendar-combined-name "OrgMode"
(defcustom org-icalendar-combined-description nil
"Calendar description for the combined iCalendar (all agenda files)."
:group 'org-export-icalendar
+ :version "24.1"
:type 'string)
(defcustom org-icalendar-use-plain-timestamp t
:group 'org-export-icalendar
:type 'boolean)
+(defcustom org-icalendar-honor-noexport-tag nil
+ "Non-nil means don't export entries with a tag in `org-export-exclude-tags'."
+ :group 'org-export-icalendar
+ :version "24.1"
+ :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:
(const :tag "Unspecified" nil)
(string :tag "Time zone")))
-(defcustom org-icalendar-use-UTC-date-time ()
- "Non-nil force the use of the universal time for iCalendar DATE-TIME.
-The iCalendar DATE-TIME can be expressed with local time or universal Time,
-universal time could be more compatible with some external tools."
+;; Backward compatibility with previous variable
+(defvar org-icalendar-use-UTC-date-time nil)
+(defcustom org-icalendar-date-time-format
+ (if org-icalendar-use-UTC-date-time
+ ":%Y%m%dT%H%M%SZ"
+ ":%Y%m%dT%H%M%S")
+ "Format-string for exporting icalendar DATE-TIME.
+See `format-time-string' for a full documentation. The only
+difference is that `org-icalendar-timezone' is used for %Z.
+
+Interesting value are:
+ - \":%Y%m%dT%H%M%S\" for local time
+ - \";TZID=%Z:%Y%m%dT%H%M%S\" for local time with explicit timezone
+ - \":%Y%m%dT%H%M%SZ\" for time expressed in Universal Time"
+
:group 'org-export-icalendar
- :type 'boolean)
+ :version "24.1"
+ :type '(choice
+ (const :tag "Local time" ":%Y%m%dT%H%M%S")
+ (const :tag "Explicit local time" ";TZID=%Z:%Y%m%dT%H%M%S")
+ (const :tag "Universal time" ":%Y%m%dT%H%M%SZ")
+ (string :tag "Explicit format")))
+
+(defun org-icalendar-use-UTC-date-timep ()
+ (char-equal (elt org-icalendar-date-time-format
+ (1- (length org-icalendar-date-time-format))) ?Z))
;;; iCalendar export
(format-time-string (cdr org-time-stamp-formats) (current-time))
"DTSTART"))
hd ts ts2 state status (inc t) pos b sexp rrule
- scheduledp deadlinep todo prefix due start
+ scheduledp deadlinep todo prefix due start tags
tmp pri categories location summary desc uid alarm
(sexp-buffer (get-buffer-create "*ical-tmp*")))
(org-refresh-category-properties)
(throw :skip nil)))
(setq pos (match-beginning 0)
ts (match-string 0)
+ tags (org-get-tags-at)
inc t
hd (condition-case nil
(org-icalendar-cleanup-string
(when (and (not org-icalendar-use-plain-timestamp)
(not deadlinep) (not scheduledp))
(throw :skip t))
+ ;; don't export entries with a :noexport: tag
+ (when (and org-icalendar-honor-noexport-tag
+ (delq nil (mapcar (lambda(x)
+ (member x org-export-exclude-tags)) tags)))
+ (throw :skip t))
(when (and
deadlinep
(if todo
;; (c) only a DISPLAY action is defined.
;; [ESF]
(let ((t1 (ignore-errors (org-parse-time-string ts 'nodefault))))
- (if (and (> org-icalendar-alarm-time 0)
+ (if (and (> org-icalendar-alarm-time 0)
(car t1) (nth 1 t1) (nth 2 t1))
- (setq alarm (format "\nBEGIN:VALARM\nACTION:DISPLAY\nDESCRIPTION:%s\nTRIGGER:-P0D0H%dM0S\nEND:VALARM" summary org-icalendar-alarm-time))
+ (setq alarm (format "\nBEGIN:VALARM\nACTION:DISPLAY\nDESCRIPTION:%s\nTRIGGER:-P0DT0H%dM0S\nEND:VALARM" summary org-icalendar-alarm-time))
(setq alarm ""))
)
(if (string-match org-bracket-link-regexp summary)
(if scheduledp (setq summary (concat "S: " summary)))
(if (string-match "\\`<%%" ts)
(with-current-buffer sexp-buffer
- (insert (substring ts 1 -1) " " summary "\n"))
+ (let ((entry (substring ts 1 -1)))
+ (put-text-property 0 1 'uid
+ (concat " " prefix uid) entry)
+ (insert entry " " summary "\n")))
(princ (format "BEGIN:VEVENT
UID: %s
%s
(setq h (+ 2 h)))
(setq d (1+ d))))
(setq time (encode-time s mi h d m y)))
- (setq fmt (if have-time (if org-icalendar-use-UTC-date-time
- ":%Y%m%dT%H%M%SZ"
- ":%Y%m%dT%H%M%S")
+ (setq fmt (if have-time
+ (replace-regexp-in-string "%Z"
+ org-icalendar-timezone
+ org-icalendar-date-time-format)
";VALUE=DATE:%Y%m%d"))
- (concat keyword (format-time-string fmt time
- (and org-icalendar-use-UTC-date-time
+ (concat keyword (format-time-string fmt time
+ (and (org-icalendar-use-UTC-date-timep)
have-time))))))
(provide 'org-icalendar)