summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Dominik <carsten.dominik@gmail.com>2009-05-10 12:32:05 +0200
committerCarsten Dominik <carsten.dominik@gmail.com>2009-05-10 12:32:05 +0200
commit0a01a7a12b122efb0675c24aab0469199aaff9ec (patch)
tree0b180c96f156b2932d46d11e9807bd30d56c711b
parent3065dcbd427fa8aeeb50797e95221ff67ade83be (diff)
downloadorg-mode-0a01a7a12b122efb0675c24aab0469199aaff9ec.tar.gz
iCalendar export: Make it possible to export only unblocked TODO
entries. Guy Wiener writes: > Hello everyone, > > I use orgmode to write down TODO tasks with dependencies (using > org-enforce-todo-dependencies). I want to export the tasks to an > iCalendar file, but *without* the blocked tasks (i.e, tasks that have > unfinished dependencies). The agenda view hides these tasks if you set > org-agenda-dim-blocked-tasks. It there a way to configure the > iCalendar export to ignore these tasks too, like in the agenda view? This commit implements this, when the value of `org-icalendar-include-todo' is the symbol `unblocked'.
-rwxr-xr-xlisp/ChangeLog5
-rw-r--r--lisp/org-icalendar.el33
2 files changed, 34 insertions, 4 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 856ec6a..c00da4f 100755
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,10 @@
2009-05-10 Carsten Dominik <carsten.dominik@gmail.com>
+ * org-icalendar.el (org-icalendar-include-todo): New allowedvalue
+ `unblocked'.
+ (org-print-icalendar-entries): Respect the new value of
+ `org-icalendar-include-todo'.
+
* org.el (org-link-try-special-completion)
(org-file-complete-link): New functions.
(org-insert-link): Add special completion support for some link
diff --git a/lisp/org-icalendar.el b/lisp/org-icalendar.el
index 308b070..3eae89c 100644
--- a/lisp/org-icalendar.el
+++ b/lisp/org-icalendar.el
@@ -97,11 +97,17 @@ all-tags All tags, including inherited ones."
(const :tag "All tags, including inherited ones" all-tags))))
(defcustom org-icalendar-include-todo nil
- "Non-nil means, export to iCalendar files should also cover TODO items."
+ "Non-nil means, export to iCalendar files should also cover TODO items.
+Valid values are:
+nil don't inlcude any TODO items
+t include all TODO items that are not in a DONE state
+unblocked include all TODO idems that are not blocked
+all include both done and not done items."
:group 'org-export-icalendar
:type '(choice
(const :tag "None" nil)
(const :tag "Unfinished" t)
+ (const :tag "Unblocked" unblocked)
(const :tag "All" all)))
(defcustom org-icalendar-include-sexps t
@@ -368,7 +374,8 @@ END:VEVENT\n"
(catch :skip
(org-agenda-skip)
(when (boundp 'org-icalendar-verify-function)
- (unless (funcall org-icalendar-verify-function)
+ (unless (save-match-data
+ (funcall org-icalendar-verify-function))
(outline-next-heading)
(backward-char 1)
(throw :skip nil)))
@@ -376,8 +383,26 @@ END:VEVENT\n"
(setq status (if (member state org-done-keywords)
"COMPLETED" "NEEDS-ACTION"))
(when (and state
- (or (not (member state org-done-keywords))
- (eq org-icalendar-include-todo 'all))
+ (cond
+ ;; check if the state is one we should use
+ ((eq org-icalendar-include-todo 'all)
+ ;; all should be included
+ t)
+ ((eq org-icalendar-include-todo 'unblocked)
+ ;; only undone entries that are not blocked
+ (and (member state org-not-done-keywords)
+ (or (not org-blocker-hook)
+ (save-match-data
+ (run-hook-with-args-until-failure
+ 'org-blocker-hook
+ (list :type 'todo-state-change
+ :position (point-at-bol)
+ :from 'todo
+ :to 'done))))))
+ ((eq org-icalendar-include-todo t)
+ ;; include everything that is not done
+ (member state org-not-done-keywords)))
+ ;; but make sure this is not an archived entry
(not (member org-archive-tag (org-get-tags-at)))
)
(setq hd (match-string 3)