[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] Export to iCalendar only not DONE, scheduled tasks?
From: |
Arun Persaud |
Subject: |
Re: [O] Export to iCalendar only not DONE, scheduled tasks? |
Date: |
Wed, 14 May 2014 15:31:49 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 |
Hi
On 05/10/2014 07:55 AM, Chris Poole wrote:
> On Mon, May 5, 2014 at 11:08 PM, Arun Persaud <address@hidden
> <mailto:address@hidden>> 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