emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Arun Persaud <apersaud@lbl.gov>
To: emacs-orgmode@gnu.org
Subject: Re: Export to iCalendar only not DONE, scheduled tasks?
Date: Mon, 05 May 2014 15:08:43 -0700	[thread overview]
Message-ID: <53680BEB.2070804@lbl.gov> (raw)
In-Reply-To: <CAF=P9QC7GfSBO-A+55sohPaDqv3zqEHpct8axOSLWe449LhMNA@mail.gmail.com>

Hi

> I've been searching round the manual, and blogs, to find a way to do this.
> 
> I want to export all of the scheduled/deadline tasks that are not in a
> DONE state to an iCalendar file.
> 
> Can this be done?

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

(defun org-mycal-export-limit (content backend info)
  "Limit the export to items that have a date, time and a range. Also
exclude certain categories."
  (when (eq backend 'icalendar)
    (setq org-tst-regexp "<\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} ...
[0-9]\\{2\\}:[0-9]\\{2\\}[^\r\n>]*?\\)>")
    (setq org-tstr-regexp (concat org-tst-regexp "--?-?" org-tst-regexp))
    (save-excursion
      ; get categories
      (setq mycategory (org-get-category))
      ; get start and end of tree
      (org-back-to-heading t)
      (setq mystart    (point))
      (org-end-of-subtree)
      (setq myend      (point))
      (goto-char mystart)
      ; search for timerange
      (setq myresult (re-search-forward org-tstr-regexp myend t))
      ; search for categories to exclude
      (setq mycatp (member mycategory org-export-exclude-category))
      ; return text if ok, nil when not ok
      (if (and myresult (not mycatp)) content nil))))

(defun org-mycal-export ()
  (let ((org-export-filter-final-output-functions
'(org-mycal-export-limit)))
    (org-icalendar-combine-agenda-files)))

NB org-export-exclude-category is defined somewhere else

You can look up org-export-filter-final-output-functions and other hooks
at http://orgmode.org/worg/doc.html. I overwrite that hook and have it
return the content if I like the item and skip it by returning nil if I
don't like it.

You can probably use org-entry-is-done-p or org-get-todo-state to figure
out if your entry is DONE or not and org-get-scheduled-time/
org-get-deadline-time to figure out if it's scheduled.

HTH

Arun

  reply	other threads:[~2014-05-05 22:09 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 [this message]
2014-05-10 14:55   ` Chris Poole
2014-05-14 22:31     ` Arun Persaud
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=53680BEB.2070804@lbl.gov \
    --to=apersaud@lbl.gov \
    --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).