Re: [O] Export to iCalendar only not DONE, scheduled tasks?

2014-06-01 Thread Chris Poole
On Wed, May 14, 2014 at 11:31 PM, Arun Persaud apers...@lbl.gov wrote:

 had another look and org-export-filter-final-output-functions is the
 wrong function to use. ...


So, I ended up solving my problem, via an alternative route. The code is
here:

https://github.com/chrispoole643/org-gtd/blob/dcfe7122fa496de51a8de3a8f02184bc7aec05b9/org-gtd.el#L143

Essentially, the icalendar function that combines the agendas and exports
stuff just calls a function that happens to accept a restricted list of
items to export. So, I use this function directly, but first I look through
my agenda files and mark where the scheduled tasks are. I then pass these
as the restricted list, and all works well :)

Thanks for the help,
Chris


Re: [O] Export to iCalendar only not DONE, scheduled tasks?

2014-05-16 Thread Chris Poole
That's very helpful, thanks — I'll get experimenting.


Cheers,
Chris


Re: [O] Export to iCalendar only not DONE, scheduled tasks?

2014-05-14 Thread Arun Persaud
Hi

On 05/10/2014 07:55 AM, Chris Poole wrote:
 On Mon, May 5, 2014 at 11:08 PM, Arun Persaud apers...@lbl.gov
 mailto:apers...@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




Re: [O] Export to iCalendar only not DONE, scheduled tasks?

2014-05-10 Thread Chris Poole
On Mon, May 5, 2014 at 11:08 PM, Arun Persaud apers...@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))

I have (setq org-icalendar-include-todo t) too.

Using edebug, it seems that the `content' argument only iterates through
the top-level headings of each of my agenda files. I was assuming it'd
iterate through each subheading too --- do I need to do this manually?


Re: [O] Export to iCalendar only not DONE, scheduled tasks?

2014-05-07 Thread Chris Poole
On Tuesday, May 6, 2014, Bastien b...@gnu.org wrote:
 (setq org-icalendar-include-todo t)

I tried that, but it has the unfortunate effect of adding all my TODO
entries into the calendar.

I want unscheduled TODO items to be in tags-todo lists only (for @contexts
in GTD parlance), and scheduled TODO items to appear in the weekly agenda
and iCalendar files. (And nothing else going to iCalendar.)

I have been able to set everything up except for the last piece in
parentheses above.

Any other thoughts?

Cheers,
Chris


Re: [O] Export to iCalendar only not DONE, scheduled tasks?

2014-05-06 Thread Bastien
Hi Chris,

Chris Poole li...@chrispoole.com writes:

 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?

(setq org-icalendar-include-todo t)

Also see `org-icalendar-use-scheduled' and
`org-icalendar-use-deadline'.

HTH,

-- 
 Bastien



Re: [O] Export to iCalendar only not DONE, scheduled tasks?

2014-05-05 Thread Arun Persaud
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