From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric S Fraga Subject: [patch] icalendar extended to define alarm triggers for timed events Date: Wed, 30 Jun 2010 23:44:48 +0100 Message-ID: <87lj9wta1r.wl%ucecesf@ucl.ac.uk> Reply-To: Eric S Fraga Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: multipart/mixed; boundary="Multipart_Wed_Jun_30_23:44:48_2010-1" Return-path: Received: from [140.186.70.92] (port=41108 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OU61c-0000nc-BX for emacs-orgmode@gnu.org; Wed, 30 Jun 2010 18:45:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OU61b-0002O8-2i for emacs-orgmode@gnu.org; Wed, 30 Jun 2010 18:45:00 -0400 Received: from vscane-b.ucl.ac.uk ([144.82.108.141]:61118) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OU61a-0002NC-Tb for emacs-orgmode@gnu.org; Wed, 30 Jun 2010 18:44:59 -0400 Received: from 79-74-7-130.dynamic.dsl.as9105.com ([79.74.7.130] helo=esf.ucl.ac.uk) by vscane-b.ucl.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69) (envelope-from ) id 1OU61R-0007Ap-J9 for emacs-orgmode@gnu.org; Wed, 30 Jun 2010 23:44:50 +0100 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: org-mode mailing list --Multipart_Wed_Jun_30_23:44:48_2010-1 Content-Type: text/plain; charset=US-ASCII Hello, attached is a rudimentary patch for org-icalendar.el to add the definition of alarm triggers for timed events that are exported to icalendar format. The default is to behave as it does at the moment however. I hope it proves passable (given my less than brilliant elisp expertise...). eric --Multipart_Wed_Jun_30_23:44:48_2010-1 Content-Type: text/plain; type=patch; charset=US-ASCII Content-Disposition: attachment; filename="alarm.patch" Content-Transfer-Encoding: 7bit diff --git a/lisp/org-icalendar.el b/lisp/org-icalendar.el index a50fdb6..702c9ee 100644 --- a/lisp/org-icalendar.el +++ b/lisp/org-icalendar.el @@ -44,6 +44,12 @@ The file name should be absolute, the file will be overwritten without warning." :group 'org-export-icalendar :type 'file) +(defcustom org-icalendar-alarm-time 0 + "The default number of minutes for triggering an alarm if a timed event is exported. +A zero value (the default) turns off the definition of an alarm trigger for timed events." + :group 'org-export-icalendar + :type 'integer) + (defcustom org-icalendar-combined-name "OrgMode" "Calendar name for the combined iCalendar representing all agenda files." :group 'org-export-icalendar @@ -279,7 +285,7 @@ When COMBINE is non nil, add the category to each line." "DTSTART")) hd ts ts2 state status (inc t) pos b sexp rrule scheduledp deadlinep todo prefix due start - tmp pri categories location summary desc uid + tmp pri categories location summary desc uid alarm (sexp-buffer (get-buffer-create "*ical-tmp*"))) (org-refresh-category-properties) (save-excursion @@ -311,6 +317,7 @@ When COMBINE is non nil, add the category to each line." (org-id-get-create) (or (org-id-get) (org-id-new))) categories (org-export-get-categories) + alarm "" deadlinep nil scheduledp nil) (if (looking-at re2) (progn @@ -359,6 +366,17 @@ When COMBINE is non nil, add the category to each line." ";INTERVAL=" (match-string 1 ts))) (setq rrule "")) (setq summary (or summary hd)) + ;; create an alarm entry if the entry is timed. this is not very general in that: + ;; (a) only one alarm per entry is defined, + ;; (b) only minutes are allowed for the trigger period ahead of the start time, and + ;; (c) only a DISPLAY action is defined. + ;; [ESF] + (let ((t1 (ignore-errors (org-parse-time-string ts 'nodefault)))) + (if (and (> org-icalendar-alarm-time 0) + (car t1) (nth 1 t1) (nth 2 t1)) + (setq alarm (format "\nBEGIN:VALARM\nACTION:DISPLAY\nDESCRIPTION:%s\nTRIGGER:-P0D0H%dM0S\nEND:VALARM" summary org-icalendar-alarm-time)) + (setq alarm "")) + ) (if (string-match org-bracket-link-regexp summary) (setq summary (replace-match (if (match-end 3) @@ -375,7 +393,7 @@ UID: %s %s %s%s SUMMARY:%s%s%s -CATEGORIES:%s +CATEGORIES:%s%s END:VEVENT\n" (concat prefix uid) (org-ical-ts-to-string ts "DTSTART") @@ -385,7 +403,8 @@ END:VEVENT\n" (concat "\nDESCRIPTION: " desc) "") (if (and location (string-match "\\S-" location)) (concat "\nLOCATION: " location) "") - categories))))) + categories + alarm))))) (when (and org-icalendar-include-sexps (condition-case nil (require 'icalendar) (error nil)) (fboundp 'icalendar-export-region)) --Multipart_Wed_Jun_30_23:44:48_2010-1 Content-Type: text/plain; charset=US-ASCII -- Eric S Fraga GnuPG: 8F5C 279D 3907 E14A 5C29 570D C891 93D8 FFFC F67D --Multipart_Wed_Jun_30_23:44:48_2010-1 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --Multipart_Wed_Jun_30_23:44:48_2010-1--