I'm trying to filter tasks such that only tasks that aren't done, but are scheduled or have deadlines, are exported to iCalendar.
org-icalendar-use-deadline '(todo-due)
org-icalendar-include-todo t
org-icalendar-include-body nil
org-icalendar-alarm-time 15
org-icalendar-with-timestamps 'active)
(defun gtd-filter-scheduled-todo-tasks (data backend info)
"Filter iCalendar export to include only TODO tasks that are
not done, but which are scheduled or have a deadline."
(when (eq backend 'icalendar)
(org-element-map data 'headline
(lambda (hl)
(when (or (not (equal 'todo (org-element-property :todo-type hl)))
(equal "DONE" (org-element-property :todo-keyword hl))
(not (or (org-element-property :scheduled hl)
(org-element-property :deadline hl))))
(org-export-ignore-element hl info))) info) data))
(defun gtd-export-agendas-and-calendar ()
"Store agenda views as plain text files, and export scheduled
events to a combined iCalendar file. Filter the calendar using
`gtd-filter-scheduled-todo-tasks', only allowing tasks that
aren't DONE, but are scheduled."
(interactive)
(org-store-agenda-views)
(let ((org-export-filter-parse-tree-functions '(gtd-filter-scheduled-todo-tasks)))
(org-icalendar-combine-agenda-files)))
But it leaves an empty calendar.ics file. Anyone know where I'm going wrong?
I assume that org-export-ignore-element is updating `info' in place.
I can't work out why it's not working...