Function: diary-icalendar-add-valarms
diary-icalendar-add-valarms is a byte-compiled function defined in
diary-icalendar.el.gz.
Signature
(diary-icalendar-add-valarms COMPONENT &optional VTIMEZONE)
Documentation
Add VALARMs to COMPONENT according to diary-icalendar-export-alarms.
COMPONENT should be an icalendar-vevent or icalendar-vtodo. The
generated VALARM components will be added to this node's children.
VTIMEZONE should define the local timezone; it is required when
formatting alarms as mail messages. Returns the modified COMPONENT.
Source Code
;; Defined in /usr/src/emacs/lisp/calendar/diary-icalendar.el.gz
(defun di:add-valarms (component &optional vtimezone)
"Add VALARMs to COMPONENT according to `diary-icalendar-export-alarms'.
COMPONENT should be an `icalendar-vevent' or `icalendar-vtodo'. The
generated VALARM components will be added to this node's children.
VTIMEZONE should define the local timezone; it is required when
formatting alarms as mail messages. Returns the modified COMPONENT."
(let* ((alarm-options
(if (and (bound-and-true-p icalendar-export-alarms)
(null di:export-alarms))
;; For backward compatibility with icalendar.el:
(with-suppressed-warnings
((obsolete ical:export-alarms
di:-convert-legacy-alarm-options))
(di:-convert-legacy-alarm-options ical:export-alarms))
di:export-alarms))
valarms)
(dolist (opts alarm-options)
(let* ((type (nth 0 opts))
(minutes (nth 1 opts)))
(cl-case type
(audio
(push (ical:make-valarm
(ical:action "AUDIO")
(ical:trigger (make-decoded-time :minute (* -1 minutes))))
valarms))
(display
(ical:with-component component
((ical:summary :value summary)
(ical:description :value description))
(let* ((displayed-summary
(replace-regexp-in-string
"%t" (number-to-string minutes)
(replace-regexp-in-string
"%s" summary
(nth 2 opts)))))
(push (ical:make-valarm
(ical:action "DISPLAY")
(ical:trigger (make-decoded-time :minute (* -1 minutes)))
(ical:summary displayed-summary)
(ical:description description))
valarms))))
(email
(ical:with-component component
((ical:summary :value summary)
(ical:attendee :all entry-attendees))
(let* ((subject
(replace-regexp-in-string
"%t" (number-to-string minutes)
(replace-regexp-in-string
"%s" summary
(nth 2 opts))))
(index (ical:index-insert-tz (ical:make-index) vtimezone))
(body
(dlet ((ical-as-alarm 'email))
(di:format-entry component index)))
(addresses (nth 3 opts))
all-attendees)
(dolist (address addresses)
(cond
((eq address 'from-entry)
(setq all-attendees (append entry-attendees all-attendees)))
((stringp address)
(push (ical:make-property ical:attendee
(concat "mailto:" address))
all-attendees))))
(push (ical:make-valarm
(ical:action "EMAIL")
(ical:trigger (make-decoded-time :minute (* -1 minutes)))
(ical:summary subject)
(ical:description body)
(@ all-attendees))
valarms)))))))
(apply #'ical:ast-node-adopt-children component valarms)
component))