Function: icalendar--create-uid

icalendar--create-uid is a byte-compiled function defined in icalendar.el.gz.

Signature

(icalendar--create-uid ENTRY-FULL CONTENTS)

Documentation

Construct a unique iCalendar UID for a diary entry.

ENTRY-FULL is the full diary entry string. CONTENTS is the current iCalendar object, as a string. Increase icalendar--uid-count. Returns the UID string.

Source Code

;; Defined in /usr/src/emacs/lisp/calendar/icalendar.el.gz
(defun icalendar--create-uid (entry-full contents)
  "Construct a unique iCalendar UID for a diary entry.
ENTRY-FULL is the full diary entry string.  CONTENTS is the
current iCalendar object, as a string.  Increase
`icalendar--uid-count'.  Returns the UID string."
  (let ((uid icalendar-uid-format))
    (if
	;; Allow other apps (such as org-mode) to create its own uid
	(get-text-property 0 'uid entry-full)
	(setq uid (get-text-property 0 'uid entry-full))
      (setq uid (replace-regexp-in-string
                 "%c"
                 (format "%d" icalendar--uid-count)
                 uid t t))
      (setq icalendar--uid-count (1+ icalendar--uid-count))
      (setq uid (replace-regexp-in-string
                 "%t"
                 (format-time-string "%s%N")
                 uid t t))
      (setq uid (replace-regexp-in-string
                 "%h"
                 (format "%d" (abs (sxhash entry-full))) uid t t))
      (setq uid (replace-regexp-in-string
                 "%u" (or user-login-name "UNKNOWN_USER") uid t t))
      (let ((dtstart (if (string-match "^DTSTART[^:]*:\\([0-9]*\\)" contents)
                         (substring contents (match-beginning 1) (match-end 1))
                       "DTSTART")))
        (setq uid (replace-regexp-in-string "%s" dtstart uid t t))))

    ;; Return the UID string
    uid))