From 111e6886564abbf3becb2a94e66f235f502b79d9 Mon Sep 17 00:00:00 2001 From: Mikhail Skorzhinskii Date: Sat, 12 Sep 2020 18:52:39 +0200 Subject: [PATCH 3/3] ox-icalendar.el: introduce setting to force alarms This is a new setting for icalendar exports to allow users set alarms exactly at the event start. With this setting set to non-nil and alarm set to zero (by global setting or APPT_WARNTIME property) it will create an alarm at the event start. Note, that zero alarm set as APPT_WARNTIME property will override default warning time. --- etc/ORG-NEWS | 10 ++++++++++ lisp/ox-icalendar.el | 24 +++++++++++++++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index b912e807d..eb950d934 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -23,6 +23,16 @@ path. Through these new options for icalendar export, one can customise the looks of summary lines in exported events. +*** New option ~org-icalendar-force-alarm~ + +This is a new setting for icalendar exports to allow users set alarms +exactly at the event start. With this setting set to non-nil and alarm +set to zero (by global setting or APPT_WARNTIME property) it will +create an alarm at the event start. + +Note, that zero alarm set as =APPT_WARNTIME= property will override +default warning time. + * Version 9.4 ** Incompatible changes *** Possibly broken internal file links: please check and fix diff --git a/lisp/ox-icalendar.el b/lisp/ox-icalendar.el index f110a4b2b..baed925e8 100644 --- a/lisp/ox-icalendar.el +++ b/lisp/ox-icalendar.el @@ -64,6 +64,15 @@ for timed events. If non-zero, alarms are created. :version "24.1" :type 'integer) +(defcustom org-icalendar-force-alarm nil + "Non-nil means alarm will be created even if is set to zero. + +This overrides default behaviour where zero means no alarm. With +this set to non-nil and alarm set to zero, alarm will be created +and will fire at the event start." + :group 'org-export-icalendar + :type 'bool) + (defcustom org-icalendar-combined-name "OrgMode" "Calendar name for the combined iCalendar representing all agenda files." :group 'org-export-icalendar @@ -797,8 +806,11 @@ Return VALARM component as a string, or nil if it isn't allowed." (let ((alarm-time (let ((warntime (org-element-property :APPT_WARNTIME entry))) - (if warntime (string-to-number warntime) 0)))) - (and (or (> alarm-time 0) (> org-icalendar-alarm-time 0)) + (if warntime (string-to-number warntime) nil)))) + (and (or (and alarm-time + (> alarm-time 0)) + (> org-icalendar-alarm-time 0) + org-icalendar-force-alarm) (org-element-property :hour-start timestamp) (format "BEGIN:VALARM ACTION:DISPLAY @@ -806,7 +818,13 @@ DESCRIPTION:%s TRIGGER:-P0DT0H%dM0S END:VALARM\n" summary - (if (zerop alarm-time) org-icalendar-alarm-time alarm-time))))) + (if org-icalendar-force-alarm + (if alarm-time + alarm-time + org-icalendar-alarm-time) + (if (zerop alarm-time) + org-icalendar-alarm-time + alarm-time)))))) ;;;; Template -- 2.28.0