]> git.eshelyaron.com Git - emacs.git/commitdiff
icalendar: uid-creation improved
authorUlf Jasper <ulf.jasper@web.de>
Fri, 31 Oct 2008 18:28:16 +0000 (18:28 +0000)
committerUlf Jasper <ulf.jasper@web.de>
Fri, 31 Oct 2008 18:28:16 +0000 (18:28 +0000)
lisp/ChangeLog
lisp/calendar/icalendar.el

index 726872e880aa7024e61aa55f8ed4fd8087f8c432..d7d6729bf49f3480ceee4eb7687a5daace5593d8 100644 (file)
@@ -1,3 +1,10 @@
+2008-10-31  Ulf Jasper  <ulf.jasper@web.de>
+
+       * calendar/icalendar.el (icalendar--uid-count): New.
+       (icalendar--create-uid): New. Extracted from
+       `icalendar-export-region' and add uid counter.
+       (icalendar-export-region): Use `icalendar--create-uid'.
+
 2008-10-31  Juanma Barranquero  <lekktu@gmail.com>
 
        * tooltip.el (tooltip-frame-parameters): Doc fix.
index 10ddb05820db604840d008a3649bfd3257a00844..c74d60763f81f024d2645c6bafc5fef8647d3a5d 100644 (file)
@@ -877,6 +877,21 @@ Finto iCalendar file: ")
 (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 @@ FExport diary data into iCalendar file: ")
         (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