From mboxrd@z Thu Jan 1 00:00:00 1970 From: Chris Poole Subject: Filter tasks when exporting to iCalendar Date: Sat, 17 May 2014 12:12:55 +0100 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a11c2efb8a7730b04f9969c22 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48587) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WlcY2-0006Fk-N6 for emacs-orgmode@gnu.org; Sat, 17 May 2014 07:13:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WlcXw-0005O8-Fy for emacs-orgmode@gnu.org; Sat, 17 May 2014 07:13:02 -0400 Received: from mail-ob0-f172.google.com ([209.85.214.172]:45307) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WlcXw-0005O1-AO for emacs-orgmode@gnu.org; Sat, 17 May 2014 07:12:56 -0400 Received: by mail-ob0-f172.google.com with SMTP id wp18so4141581obc.17 for ; Sat, 17 May 2014 04:12:55 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: "emacs-orgmode@gnu.org" --001a11c2efb8a7730b04f9969c22 Content-Type: text/plain; charset=UTF-8 Hi, I'm trying to filter tasks such that only tasks that aren't done, but are scheduled or have deadlines, are exported to iCalendar. I have this so far: (setq org-icalendar-use-scheduled '(todo-start) 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... Cheers, Chris --001a11c2efb8a7730b04f9969c22 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi,

I'm trying to filter tasks such that = only tasks that aren't done, but are scheduled or have deadlines, are e= xported to iCalendar.

I have this so far:


(setq org-icalendar-use-scheduled '(todo-= start)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 org-icalendar-use-deadlin= e '(todo-due)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 org-icalendar-inclu= de-todo t
=C2=A0 =C2=A0 =C2=A0 =C2=A0 org-icalendar-include-body = nil
=C2=A0 =C2=A0 =C2=A0 =C2=A0 org-icalendar-alarm-time 15
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 org-icalendar-with-timestamps 'active)

(defun gtd-filter-scheduled-todo-tasks (data b= ackend info)
=C2=A0 "Filter iCalendar export to include only= TODO tasks that are
not done, but which are scheduled or have a deadline."
= =C2=A0 (when (eq backend 'icalendar)
=C2=A0 =C2=A0 (org-eleme= nt-map data 'headline
=C2=A0 =C2=A0 =C2=A0 (lambda (hl)
=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (when (or (not (equal 'todo (org-eleme= nt-property :todo-type hl)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (equal = "DONE" (org-element-property :todo-keyword hl))
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (not (or (org-eleme= nt-property :scheduled hl)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(org-element-pro= perty :deadline hl))))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (org-export-ignore-element hl info)= )) info) data))

(defun gtd-export-agendas-and-cale= ndar ()
=C2=A0 "Store agenda views as plain text files, and = export scheduled
events to a combined iCalendar file. Filter the calendar using
`g= td-filter-scheduled-todo-tasks', only allowing tasks that
are= n't DONE, but are scheduled."
=C2=A0 (interactive)
=
=C2=A0 (org-store-agenda-views)
=C2=A0 (let ((org-export-filter-p= arse-tree-functions '(gtd-filter-scheduled-todo-tasks)))
=C2= =A0 =C2=A0 (org-icalendar-combine-agenda-files)))


But it leaves an empty calendar.ics file. Anyone know where I'm going w= rong?
I assume that org-export-ignore-element is updating `info&#= 39; in place.

I can't work out why it's no= t working...


Cheers,
Chris
--001a11c2efb8a7730b04f9969c22--