From mboxrd@z Thu Jan 1 00:00:00 1970 From: Arun Persaud Subject: Re: Export to iCalendar only not DONE, scheduled tasks? Date: Wed, 14 May 2014 15:31:49 -0700 Message-ID: <5373EED5.8020306@lbl.gov> References: <53680BEB.2070804@lbl.gov> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:45420) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WkhiU-0004Hp-Tt for emacs-orgmode@gnu.org; Wed, 14 May 2014 18:32:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WkhiO-0008Ux-Du for emacs-orgmode@gnu.org; Wed, 14 May 2014 18:32:02 -0400 Received: from fe1.lbl.gov ([128.3.41.133]:50623) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WkhiO-0008Uc-6T for emacs-orgmode@gnu.org; Wed, 14 May 2014 18:31:56 -0400 Received: by mail-pa0-f43.google.com with SMTP id hz1so182650pad.16 for ; Wed, 14 May 2014 15:31:52 -0700 (PDT) In-Reply-To: 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: Chris Poole Cc: "emacs-orgmode@gnu.org" Hi On 05/10/2014 07:55 AM, Chris Poole wrote: > On Mon, May 5, 2014 at 11:08 PM, Arun Persaud > 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