aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog9
-rw-r--r--lisp/calendar/icalendar.el66
2 files changed, 73 insertions, 2 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index c30a2dd9b4d..b232210f3c7 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,12 @@
12014-11-17 Ulf Jasper <ulf.jasper@web.de>
2
3 * calendar/icalendar.el (icalendar-export-alarms): New
4 customizable variable.
5 (icalendar-export-region): Export alarms as specified in
6 `icalendar-export-alarms'.
7 (icalendar--create-ical-alarm, icalendar--do-create-ical-alarm):
8 New functions for exporting alarms.
9
12014-11-17 Paul Eggert <eggert@cs.ucla.edu> 102014-11-17 Paul Eggert <eggert@cs.ucla.edu>
2 11
3 Port new time stamp handling to old Emacs and to XEmacs. 12 Port new time stamp handling to old Emacs and to XEmacs.
diff --git a/lisp/calendar/icalendar.el b/lisp/calendar/icalendar.el
index 9dba6ff2dcf..0bd126d9520 100644
--- a/lisp/calendar/icalendar.el
+++ b/lisp/calendar/icalendar.el
@@ -267,6 +267,28 @@ other sexp entries are enumerated in any case."
267 :type 'boolean 267 :type 'boolean
268 :group 'icalendar) 268 :group 'icalendar)
269 269
270
271(defcustom icalendar-export-alarms
272 nil
273 "Determine if and how alarms are included in exported diary events."
274 :version "25.1"
275 :type '(choice (const :tag "Do not include alarms in export"
276 nil)
277 (list :tag "Create alarms in exported diary entries"
278 (integer :tag "Advance time (minutes)"
279 :value 10)
280 (set :tag "Alarm type"
281 (list :tag "Audio"
282 (const audio :tag "Audio"))
283 (list :tag "Display"
284 (const display :tag "Display"))
285 (list :tag "Email"
286 (const email)
287 (repeat :tag "Attendees"
288 (string :tag "Email"))))))
289 :group 'icalendar)
290
291
270(defvar icalendar-debug nil 292(defvar icalendar-debug nil
271 "Enable icalendar debug messages.") 293 "Enable icalendar debug messages.")
272 294
@@ -1026,6 +1048,7 @@ FExport diary data into iCalendar file: ")
1026 (header "") 1048 (header "")
1027 (contents-n-summary) 1049 (contents-n-summary)
1028 (contents) 1050 (contents)
1051 (alarm)
1029 (found-error nil) 1052 (found-error nil)
1030 (nonmarker (concat "^" (regexp-quote diary-nonmarking-symbol) 1053 (nonmarker (concat "^" (regexp-quote diary-nonmarking-symbol)
1031 "?")) 1054 "?"))
@@ -1088,8 +1111,10 @@ FExport diary data into iCalendar file: ")
1088 (setq header (concat "\nBEGIN:VEVENT\nUID:" 1111 (setq header (concat "\nBEGIN:VEVENT\nUID:"
1089 (or uid 1112 (or uid
1090 (icalendar--create-uid 1113 (icalendar--create-uid
1091 entry-full contents))))) 1114 entry-full contents))))
1092 (setq result (concat result header contents 1115 (setq alarm (icalendar--create-ical-alarm
1116 (cdr contents-n-summary))))
1117 (setq result (concat result header contents alarm
1093 "\nEND:VEVENT"))) 1118 "\nEND:VEVENT")))
1094 (if (consp cns-cons-or-list) 1119 (if (consp cns-cons-or-list)
1095 (list cns-cons-or-list) 1120 (list cns-cons-or-list)
@@ -1264,6 +1289,43 @@ Returns an alist."
1264 (if url (cons 'url url) nil) 1289 (if url (cons 'url url) nil)
1265 (if uid (cons 'uid uid) nil)))))))) 1290 (if uid (cons 'uid uid) nil))))))))
1266 1291
1292(defun icalendar--create-ical-alarm (summary)
1293 "Return VALARM blocks for the given SUMMARY."
1294 (when icalendar-export-alarms
1295 (let* ((advance-time (car icalendar-export-alarms))
1296 (alarm-specs (cadr icalendar-export-alarms))
1297 (fun (lambda (spec)
1298 (icalendar--do-create-ical-alarm advance-time spec summary))))
1299 (mapconcat fun alarm-specs ""))))
1300
1301(defun icalendar--do-create-ical-alarm (advance-time alarm-spec summary)
1302 "Return a VALARM block.
1303Argument ADVANCE-TIME is a number giving the time when the alarm
1304fires (minutes before the respective event). Argument ALARM-SPEC
1305is a list which must be one of '(audio), '(display) or
1306'(email (ADDRESS1 ...)), see `icalendar-export-alarms'. Argument
1307SUMMARY is a string which contains a short description for the
1308alarm."
1309 (let* ((action (car alarm-spec))
1310 (act (format "\nACTION:%s"
1311 (cdr (assoc action '((audio . "AUDIO")
1312 (display . "DISPLAY")
1313 (email . "EMAIL"))))))
1314 (tri (format "\nTRIGGER:-PT%dM" advance-time))
1315 (des (if (memq action '(display email))
1316 (format "\nDESCRIPTION:%s" summary)
1317 ""))
1318 (sum (if (eq action 'email)
1319 (format "\nSUMMARY:%s" summary)
1320 ""))
1321 (att (if (eq action 'email)
1322 (mapconcat (lambda (i)
1323 (format "\nATTENDEE:MAILTO:%s" i))
1324 (cadr alarm-spec) "")
1325 "")))
1326
1327 (concat "\nBEGIN:VALARM" act tri des sum att "\nEND:VALARM")))
1328
1267;; subroutines for icalendar-export-region 1329;; subroutines for icalendar-export-region
1268(defun icalendar--convert-ordinary-to-ical (nonmarker entry-main) 1330(defun icalendar--convert-ordinary-to-ical (nonmarker entry-main)
1269 "Convert \"ordinary\" diary entry to iCalendar format. 1331 "Convert \"ordinary\" diary entry to iCalendar format.