emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [patch] icalendar extended to define alarm triggers for timed events
@ 2010-06-30 22:44 Eric S Fraga
  2010-07-02  6:53 ` Carsten Dominik
  0 siblings, 1 reply; 3+ messages in thread
From: Eric S Fraga @ 2010-06-30 22:44 UTC (permalink / raw)
  To: org-mode mailing list

[-- Attachment #1: Type: text/plain, Size: 301 bytes --]

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

[-- Attachment #2: alarm.patch --]
[-- Type: text/plain, Size: 2865 bytes --]

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))

[-- Attachment #3: Type: text/plain, Size: 75 bytes --]

-- 
Eric S Fraga
GnuPG: 8F5C 279D 3907 E14A 5C29  570D C891 93D8 FFFC F67D

[-- Attachment #4: Type: text/plain, Size: 201 bytes --]

_______________________________________________
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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [patch] icalendar extended to define alarm triggers for timed events
  2010-06-30 22:44 [patch] icalendar extended to define alarm triggers for timed events Eric S Fraga
@ 2010-07-02  6:53 ` Carsten Dominik
  2010-07-02 12:56   ` Eric S Fraga
  0 siblings, 1 reply; 3+ messages in thread
From: Carsten Dominik @ 2010-07-02  6:53 UTC (permalink / raw)
  To: Eric S Fraga; +Cc: org-mode mailing list

Hi Eric,


On Jul 1, 2010, at 12:44 AM, Eric S Fraga wrote:

> 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...).

This looks pretty good!
But can you please

- Make sure that the first line of the docstring of the new variable
   fits into 75 characters (better: 72)?
   You already have made it a stand-alone sentence, which is also  
needed.

- It would also be helpful if if can make git commit and
   include the proper commit message including a ChangeLog-like entry
   as the second paragraph in that message.

Great work!

- Carsten

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch] icalendar extended to define alarm triggers for timed events
  2010-07-02  6:53 ` Carsten Dominik
@ 2010-07-02 12:56   ` Eric S Fraga
  0 siblings, 0 replies; 3+ messages in thread
From: Eric S Fraga @ 2010-07-02 12:56 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: org-mode mailing list

[-- Attachment #1: Type: text/plain, Size: 1169 bytes --]

On Fri, 2 Jul 2010 08:53:06 +0200, Carsten Dominik <carsten.dominik@gmail.com> wrote:
> 
> Hi Eric,
> 
> 
> On Jul 1, 2010, at 12:44 AM, Eric S Fraga wrote:
> 
> > 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...).
> 
> This looks pretty good!
> But can you please
> 
> - Make sure that the first line of the docstring of the new variable
>   fits into 75 characters (better: 72)?
>   You already have made it a stand-alone sentence, which is also
> needed.
> 
> - It would also be helpful if if can make git commit and
>   include the proper commit message including a ChangeLog-like entry
>   as the second paragraph in that message.
> 
> Great work!
> 
> - Carsten
> 

Thanks Carsten.

I have seen the few messages regarding how to submit patches so I see
now what you would like.  I'll try to do that this weekend (I'm not au
fait with git but I think the instructions are fairly clear...).

[-- Attachment #2: Type: text/plain, Size: 75 bytes --]

-- 
Eric S Fraga
GnuPG: 8F5C 279D 3907 E14A 5C29  570D C891 93D8 FFFC F67D

[-- Attachment #3: Type: text/plain, Size: 201 bytes --]

_______________________________________________
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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-07-02 12:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-30 22:44 [patch] icalendar extended to define alarm triggers for timed events Eric S Fraga
2010-07-02  6:53 ` Carsten Dominik
2010-07-02 12:56   ` Eric S Fraga

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).