emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Arun Persaud <apersaud@lbl.gov>
To: Chris Poole <lists@chrispoole.com>
Cc: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: Re: Export to iCalendar only not DONE, scheduled tasks?
Date: Wed, 14 May 2014 15:31:49 -0700	[thread overview]
Message-ID: <5373EED5.8020306@lbl.gov> (raw)
In-Reply-To: <CAF=P9QDAV2XnJgwRGds_-XjkWR4na3vtUbOw4oHkwVpD8egKpg@mail.gmail.com>

Hi

On 05/10/2014 07:55 AM, Chris Poole wrote:
> On Mon, May 5, 2014 at 11:08 PM, Arun Persaud <apersaud@lbl.gov
> <mailto:apersaud@lbl.gov>> wrote:
> 
>     pretty sure this can be done. I export only events to an ics file that
>     have a start and an end date and are not in a certain category. For this
>     I use
> 
> 
> That's great, thank you. I have this, but it doesn't work:
> 
> (defun filter-scheduled-todo-tasks (content 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)
>     (if (and (org-entry-is-todo-p)
>              (not (org-entry-is-done-p))
>              (or (org-get-scheduled-time (point))
>                  (org-get-deadline-time (point))))
>         content nil)))
> 
> ... called with:
> 
> (let ((org-export-filter-final-output-functions
>          '(filter-scheduled-todo-tasks)))
>     (org-icalendar-combine-agenda-files))

had another look and org-export-filter-final-output-functions is the
wrong function to use. I'm not really using the ical export anymore and
when the org exporter got updated a while ago, I apparently didn't
update this correctly. Sorry about that.

I think the correct way is probably something like:

(defun filter-scheduled-todo-tasks (data backend info)
   ; add check for backend
  (org-element-map data 'headline 'my-debug info)
  data)

(defun org-mycal-export ()
  (let ((org-export-filter-parse-tree-functions
'(filter-scheduled-todo-tasks)))
    (org-icalendar-combine-agenda-files)))

the filter function is called before each entry is transcoded into ical
format and gets the whole parse tree. You can then loop through the
parse tree with org-element-map looking at each headline (not 100% sure
if headline is the correct thing to use). Each headline has for example
properties set that you can use to filter. You can access them using
things like:

(defun my-debug (e)
    (message "+++++++++++++++++++++++++")
    (message (buffer-substring (org-element-property :begin e)
(org-element-property :end e)))
    (message "------")
    (message "%S" (org-element-property :raw-value e))
    (message "------ todo")
    (message "%S" (org-element-property :todo-keyword e))
    (message "------ todo type")
    (message "%S" (org-element-property :todo-type e))
    (message "------ tags")
    (message "%S" (org-element-property :tags e))
    (message "------ level")
    (message "%S" (org-element-property :level e))
    (message "*********************"))

To ignore a headline, I think, you can mark it using

(org-export-ignore-element headline info)

where headline would be the same as argument 'e' in my-debug, but I
haven't played around with this yet. I found

http://searchcode.com/codesearch/view/48068680

which uses the function and perhaps you can get an idea how things work
from it.

Arun

  reply	other threads:[~2014-05-14 22:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-04 17:03 Export to iCalendar only not DONE, scheduled tasks? Chris Poole
2014-05-05 22:08 ` Arun Persaud
2014-05-10 14:55   ` Chris Poole
2014-05-14 22:31     ` Arun Persaud [this message]
2014-05-16 21:22       ` Chris Poole
2014-06-01 16:56       ` Chris Poole
2014-05-06 10:02 ` Bastien
2014-05-07 11:15   ` Chris Poole

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=5373EED5.8020306@lbl.gov \
    --to=apersaud@lbl.gov \
    --cc=emacs-orgmode@gnu.org \
    --cc=lists@chrispoole.com \
    /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).