From f2f646b6c9171d459a3eea51bbec2971aa440aa0 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Thu, 5 Sep 2019 21:54:50 +0200 Subject: [PATCH] ox-icalendar: Allow ignoring done scheduled or deadlines tasks * lisp/ox-icalendar.el (org-icalendar-use-deadline): (org-icalendar-use-scheduled): Add a value to ignore done tasks. --- etc/ORG-NEWS | 7 ++++ lisp/ox-icalendar.el | 95 ++++++++++++++++++++++++++++++-------------- 2 files changed, 73 insertions(+), 29 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 089f62995..9fff4ad16 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -123,6 +123,13 @@ auto-commit attachments to git: one need to require the =org-attach-git= module in the startup. ** New features +*** New option to handle schedules and deadlines in iCalendar export + +Export ignore done tasks with a deadline when +~org-icalendar-use-deadline~ contains ~event-if-todo-not-done~. +Likewise, scheduled done tasks are also ignored when +~org-icalendar-use-scheduled~ contains the same symbol. + *** Add split-window-right option for src block edit window placement Given the increasing popularity of wide screen monitors, splitting horizontally may make more sense than splitting vertically. An diff --git a/lisp/ox-icalendar.el b/lisp/ox-icalendar.el index 779051cb0..15c572dc1 100644 --- a/lisp/ox-icalendar.el +++ b/lisp/ox-icalendar.el @@ -87,37 +87,66 @@ keyword." This is a list with possibly several symbols in it. Valid symbols are: -`event-if-todo' Deadlines in TODO entries become calendar events. -`event-if-not-todo' Deadlines in non-TODO entries become calendar events. -`todo-due' Use deadlines in TODO entries as due-dates." +`event-if-todo' + + Deadlines in TODO entries become calendar events. + +`event-if-todo-not-done' + + Deadlines in TODO entries with not-DONE state become events. + +`event-if-not-todo' + + Deadlines in non-TODO entries become calendar events. + +`todo-due' + + Use deadlines in TODO entries as due-dates." :group 'org-export-icalendar - :type '(set :greedy t - (const :tag "Deadlines in non-TODO entries become events" - event-if-not-todo) - (const :tag "Deadline in TODO entries become events" - event-if-todo) - (const :tag "Deadlines in TODO entries become due-dates" - todo-due))) + :type + '(set :greedy t + (const :tag "DEADLINE in non-TODO entries become events" + event-if-not-todo) + (const :tag "DEADLINE in TODO entries become events" + event-if-todo) + (const :tag "DEADLINE in TODO entries with not-DONE state become events" + event-if-todo-not-done) + (const :tag "DEADLINE in TODO entries become due-dates" + todo-due))) (defcustom org-icalendar-use-scheduled '(todo-start) "Contexts where iCalendar export should use a scheduling time stamp. This is a list with possibly several symbols in it. Valid symbols are: -`event-if-todo' Scheduling time stamps in TODO entries become an event. -`event-if-not-todo' Scheduling time stamps in non-TODO entries become an event. -`todo-start' Scheduling time stamps in TODO entries become start date. - Some calendar applications show TODO entries only after - that date." +`event-if-todo' + + Scheduling time stamps in TODO entries become an event. + +`event-if-todo-not-done' + + Scheduling time stamps in TODO entries with not-DONE state + become events. + +`event-if-not-todo' + + Scheduling time stamps in non-TODO entries become an event. + +`todo-start' + + Scheduling time stamps in TODO entries become start date. Some + calendar applications show TODO entries only after that date." :group 'org-export-icalendar - :type '(set :greedy t - (const :tag - "SCHEDULED timestamps in non-TODO entries become events" - event-if-not-todo) - (const :tag "SCHEDULED timestamps in TODO entries become events" - event-if-todo) - (const :tag "SCHEDULED in TODO entries become start date" - todo-start))) + :type + '(set :greedy t + (const :tag "SCHEDULED timestamps in non-TODO entries become events" + event-if-not-todo) + (const :tag "SCHEDULED timestamps in TODO entries become events" + event-if-todo) + (const :tag "SCHEDULED in TODO entries with not-DONE state become events" + event-if-todo-not-done) + (const :tag "SCHEDULED in TODO entries become start date" + todo-start))) (defcustom org-icalendar-categories '(local-tags category) "Items that should be entered into the \"categories\" field. @@ -566,17 +595,25 @@ inlinetask within the section." ;; Events: Delegate to `org-icalendar--vevent' to generate ;; "VEVENT" component from scheduled, deadline, or any ;; timestamp in the entry. - (let ((deadline (org-element-property :deadline entry))) + (let ((deadline (org-element-property :deadline entry)) + (use-deadline (plist-get info :icalendar-use-deadline))) (and deadline - (memq (if todo-type 'event-if-todo 'event-if-not-todo) - org-icalendar-use-deadline) + (pcase todo-type + (`todo (or (memq 'event-if-todo-not-done use-deadline) + (memq 'event-if-todo use-deadline))) + (`done (memq 'event-if-todo use-deadline)) + (_ (memq 'event-if-not-todo use-deadline))) (org-icalendar--vevent entry deadline (concat "DL-" uid) (concat "DL: " summary) loc desc cat tz class))) - (let ((scheduled (org-element-property :scheduled entry))) + (let ((scheduled (org-element-property :scheduled entry)) + (use-scheduled (plist-get info :icalendar-use-scheduled))) (and scheduled - (memq (if todo-type 'event-if-todo 'event-if-not-todo) - org-icalendar-use-scheduled) + (pcase todo-type + (`todo (or (memq 'event-if-todo-not-done use-scheduled) + (memq 'event-if-todo use-scheduled))) + (`done (memq 'event-if-todo use-scheduled)) + (_ (memq 'event-if-not-todo use-scheduled))) (org-icalendar--vevent entry scheduled (concat "SC-" uid) (concat "S: " summary) loc desc cat tz class)))