# HG changeset patch # User Ulf Jasper # Date 1225477625 0 # Node ID b39c4aef1848d39fec3f2b917618cb0e1d99a8b1 # Parent 563e71d339f2428ca49826912232acb01335e109 icalendar: uid-creation improved diff -r 563e71d339f2 -r b39c4aef1848 lisp/calendar/icalendar.el --- a/lisp/calendar/icalendar.el Fri Oct 31 15:57:31 2008 +0000 +++ b/lisp/calendar/icalendar.el Fri Oct 31 18:27:05 2008 +0000 @@ -877,6 +877,21 @@ (defalias 'icalendar-convert-diary-to-ical 'icalendar-export-file) (make-obsolete 'icalendar-convert-diary-to-ical 'icalendar-export-file) +(defvar icalendar--uid-count 0 + "Auxiliary counter for creating unique ids.") + +(defun icalendar--create-uid () + "Create a unique identifier. +Use `current-time' and a counter to create unique ids. The +counter is necessary for systems which do not provide resolution +finer than a second." + (setq icalendar--uid-count (1+ icalendar--uid-count)) + (format "emacs%d%d%d%d" + (car (current-time)) + (cadr (current-time)) + (car (cddr (current-time))) + icalendar--uid-count)) + ;;;###autoload (defun icalendar-export-region (min max ical-filename) "Export region in diary file to iCalendar format. @@ -916,10 +931,8 @@ (if (match-beginning 2) (setq entry-rest (match-string 2)) (setq entry-rest "")) - (setq header (format "\nBEGIN:VEVENT\nUID:emacs%d%d%d" - (car (current-time)) - (cadr (current-time)) - (car (cddr (current-time))))) + (setq header (format "\nBEGIN:VEVENT\nUID:%s" + (icalendar--create-uid))) (condition-case error-val (progn (setq contents-n-summary