emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Chris Poole <lists@chrispoole.com>
To: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: Filter tasks when exporting to iCalendar
Date: Sat, 17 May 2014 12:12:55 +0100	[thread overview]
Message-ID: <CAF=P9QDbiEqOwLR0XqXBxQLPttgzwmA66DQJxniqm7QFs_DX0A@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1656 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 2366 bytes --]

                 reply	other threads:[~2014-05-17 11:13 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAF=P9QDbiEqOwLR0XqXBxQLPttgzwmA66DQJxniqm7QFs_DX0A@mail.gmail.com' \
    --to=lists@chrispoole.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).