]> code.delx.au - gnu-emacs/blobdiff - lisp/org/ox-icalendar.el
Merge from origin/emacs-24
[gnu-emacs] / lisp / org / ox-icalendar.el
index 7c4b4bfbce4314592f860407a37fa9c23585e9ae..a77eaedb9a08abf06d0c6d8bc5813bb7b106a6c2 100644 (file)
@@ -1,6 +1,6 @@
 ;;; ox-icalendar.el --- iCalendar Back-End for Org Export Engine
 
-;; Copyright (C) 2004-2013 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2015 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;;      Nicolas Goaziou <n dot goaziou at gmail dot com>
@@ -174,8 +174,7 @@ The anniversaries are defined in the BBDB database."
 
 (defcustom org-icalendar-include-sexps t
   "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."
+These are entries like in the diary, but directly in an Org file."
   :group 'org-export-icalendar
   :type 'boolean)
 
@@ -302,14 +301,14 @@ which will be updated."
 
 INFO is a plist used as a communication channel.
 
-a headline is blocked when either:
+A headline is blocked when either
 
-  - It has children which are not all in a completed state.
+  - it has children which are not all in a completed state;
 
-  - It has a parent with the property :ORDERED:, and there are
-    siblings prior to it with incomplete status.
+  - it has a parent with the property :ORDERED:, and there are
+    siblings prior to it with incomplete status;
 
-  - Its parent is blocked because it has siblings that should be
+  - its parent is blocked because it has siblings that should be
     done first or is a child of a blocked grandparent entry."
   (or
    ;; Check if any child is not done.
@@ -478,10 +477,10 @@ or subject for the event."
 ;;; Filters
 
 (defun org-icalendar-clear-blank-lines (headline back-end info)
-  "Remove trailing blank lines in HEADLINE export.
+  "Remove blank lines in HEADLINE export.
 HEADLINE is a string representing a transcoded headline.
 BACK-END and INFO are ignored."
-  (replace-regexp-in-string "^\\(?:[ \t]*\n\\)*" "" headline))
+  (replace-regexp-in-string "^\\(?:[ \t]*\n\\)+" "" headline))
 
 
 \f
@@ -570,13 +569,19 @@ inlinetask within the section."
            ;; happen once ENTRY is one of them.
            (let ((counter 0))
              (mapconcat
-              'identity
+              #'identity
               (org-element-map (cons (org-element-property :title entry)
                                      (org-element-contents inside))
                   'timestamp
                 (lambda (ts)
-                  (let ((uid (format "TS%d-%s" (incf counter) uid)))
-                    (org-icalendar--vevent entry ts uid summary loc desc cat)))
+                  (when (let ((type (org-element-property :type ts)))
+                          (case (plist-get info :with-timestamps)
+                            (active (memq type '(active active-range)))
+                            (inactive (memq type '(inactive inactive-range)))
+                            ((t) t)))
+                    (let ((uid (format "TS%d-%s" (incf counter) uid)))
+                      (org-icalendar--vevent
+                       entry ts uid summary loc desc cat))))
                 info nil (and (eq type 'headline) 'inlinetask))
               ""))
            ;; Task: First check if it is appropriate to export it.
@@ -589,7 +594,7 @@ inlinetask within the section."
                          (and (eq type 'headline)
                               (not (org-icalendar-blocked-headline-p
                                     entry info))))
-                        ('t (eq todo-type 'todo))))
+                        ((t) (eq todo-type 'todo))))
              (org-icalendar--vtodo entry uid summary loc desc cat))
            ;; Diary-sexp: Collect every diary-sexp element within
            ;; ENTRY and its title, and transcode them.  If ENTRY is
@@ -597,7 +602,7 @@ inlinetask within the section."
            ;; separately.
            (when org-icalendar-include-sexps
              (let ((counter 0))
-               (mapconcat 'identity
+               (mapconcat #'identity
                           (org-element-map
                               (cons (org-element-property :title entry)
                                     (org-element-contents inside))
@@ -613,7 +618,7 @@ inlinetask within the section."
        ;; inlinetask within it.  In agenda export, this is independent
        ;; from the mark (or lack thereof) on the entry.
        (when (eq type 'headline)
-        (mapconcat 'identity
+        (mapconcat #'identity
                    (org-element-map inside 'inlinetask
                      (lambda (task) (org-icalendar-entry task nil info))
                      info) ""))
@@ -673,7 +678,7 @@ Return VTODO component as a string."
                        (org-element-property :scheduled entry))
                   ;; If we can't use a scheduled time for some
                   ;; reason, start task now.
-                  (let ((now (decode-time (current-time))))
+                  (let ((now (decode-time)))
                     (list 'timestamp
                           (list :type 'active
                                 :minute-start (nth 1 now)
@@ -964,9 +969,7 @@ files to build the calendar from."
             ;; BBDB anniversaries.
             (when (and org-icalendar-include-bbdb-anniversaries
                        (require 'org-bbdb nil t))
-              (with-temp-buffer
-                (org-bbdb-anniv-export-ical)
-                (buffer-string)))))))
+              (with-output-to-string (org-bbdb-anniv-export-ical)))))))
        (run-hook-with-args 'org-icalendar-after-save-hook
                            org-icalendar-combined-agenda-file))
     (org-release-buffers org-agenda-new-buffers)))