* Export to iCalendar only not DONE, scheduled tasks?
@ 2014-05-04 17:03 Chris Poole
2014-05-05 22:08 ` Arun Persaud
2014-05-06 10:02 ` Bastien
0 siblings, 2 replies; 8+ messages in thread
From: Chris Poole @ 2014-05-04 17:03 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 220 bytes --]
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?
Cheers,
Chris
[-- Attachment #2: Type: text/html, Size: 366 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Export to iCalendar only not DONE, scheduled tasks?
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-06 10:02 ` Bastien
1 sibling, 1 reply; 8+ messages in thread
From: Arun Persaud @ 2014-05-05 22:08 UTC (permalink / raw)
To: emacs-orgmode
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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Export to iCalendar only not DONE, scheduled tasks?
2014-05-05 22:08 ` Arun Persaud
@ 2014-05-10 14:55 ` Chris Poole
2014-05-14 22:31 ` Arun Persaud
0 siblings, 1 reply; 8+ messages in thread
From: Chris Poole @ 2014-05-10 14:55 UTC (permalink / raw)
To: Arun Persaud; +Cc: emacs-orgmode@gnu.org
[-- Attachment #1: Type: text/plain, Size: 1116 bytes --]
On Mon, May 5, 2014 at 11:08 PM, Arun Persaud <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))
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?
[-- Attachment #2: Type: text/html, Size: 1800 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Export to iCalendar only not DONE, scheduled tasks?
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
0 siblings, 2 replies; 8+ messages in thread
From: Arun Persaud @ 2014-05-14 22:31 UTC (permalink / raw)
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 <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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Export to iCalendar only not DONE, scheduled tasks?
2014-05-14 22:31 ` Arun Persaud
@ 2014-05-16 21:22 ` Chris Poole
2014-06-01 16:56 ` Chris Poole
1 sibling, 0 replies; 8+ messages in thread
From: Chris Poole @ 2014-05-16 21:22 UTC (permalink / raw)
To: Arun Persaud; +Cc: emacs-orgmode@gnu.org
[-- Attachment #1: Type: text/plain, Size: 77 bytes --]
That's very helpful, thanks — I'll get experimenting.
Cheers,
Chris
[-- Attachment #2: Type: text/html, Size: 129 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Export to iCalendar only not DONE, scheduled tasks?
2014-05-14 22:31 ` Arun Persaud
2014-05-16 21:22 ` Chris Poole
@ 2014-06-01 16:56 ` Chris Poole
1 sibling, 0 replies; 8+ messages in thread
From: Chris Poole @ 2014-06-01 16:56 UTC (permalink / raw)
To: Arun Persaud; +Cc: emacs-orgmode@gnu.org
[-- Attachment #1: Type: text/plain, Size: 732 bytes --]
On Wed, May 14, 2014 at 11:31 PM, Arun Persaud <apersaud@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
[-- Attachment #2: Type: text/html, Size: 1541 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Export to iCalendar only not DONE, scheduled tasks?
2014-05-04 17:03 Export to iCalendar only not DONE, scheduled tasks? Chris Poole
2014-05-05 22:08 ` Arun Persaud
@ 2014-05-06 10:02 ` Bastien
2014-05-07 11:15 ` Chris Poole
1 sibling, 1 reply; 8+ messages in thread
From: Bastien @ 2014-05-06 10:02 UTC (permalink / raw)
To: Chris Poole; +Cc: emacs-orgmode
Hi Chris,
Chris Poole <lists@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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Export to iCalendar only not DONE, scheduled tasks?
2014-05-06 10:02 ` Bastien
@ 2014-05-07 11:15 ` Chris Poole
0 siblings, 0 replies; 8+ messages in thread
From: Chris Poole @ 2014-05-07 11:15 UTC (permalink / raw)
To: Bastien; +Cc: emacs-orgmode@gnu.org
[-- Attachment #1: Type: text/plain, Size: 523 bytes --]
On Tuesday, May 6, 2014, Bastien <bzg@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
[-- Attachment #2: Type: text/html, Size: 725 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2014-06-01 16:56 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.