mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-11-26 07:33:39 +00:00
Provide function that returns a string with a random (version 4) UUID.
This commit is contained in:
parent
7f86e0dedb
commit
aa0004004b
@ -1,3 +1,8 @@
|
||||
2010-05-16 David Maus <dmaus@ictsoc.de>
|
||||
|
||||
* org-id.el (org-id-uuid): New function. Return string with
|
||||
random (version 4) UUID.
|
||||
|
||||
2010-05-15 Carsten Dominik <carsten.dominik@gmail.com>
|
||||
|
||||
* org-latex.el (org-export-latex-format-image): Add support
|
||||
|
@ -318,6 +318,30 @@ So a typical ID could look like \"Org:4nd91V40HI\"."
|
||||
(t (error "Invalid `org-id-method'")))
|
||||
(concat prefix unique)))
|
||||
|
||||
(defun org-id-uuid ()
|
||||
"Return string with random (version 4) UUID."
|
||||
(let ((rnd (md5 (format "%s%s%s%s%s%s%s"
|
||||
(random t)
|
||||
(current-time)
|
||||
(user-uid)
|
||||
(emacs-pid)
|
||||
(user-full-name)
|
||||
user-mail-address
|
||||
(recent-keys)))))
|
||||
(format "%s-%s-4%s-%s%s-%s"
|
||||
(substring rnd 0 8)
|
||||
(substring rnd 8 12)
|
||||
(substring rnd 13 16)
|
||||
(format "%x"
|
||||
(logior
|
||||
#B10000000
|
||||
(logand
|
||||
#B10111111
|
||||
(string-to-number
|
||||
(substring rnd 16 18) 16))))
|
||||
(substring rnd 18 20)
|
||||
(substring rnd 20 32))))
|
||||
|
||||
(defun org-id-reverse-string (s)
|
||||
(mapconcat 'char-to-string (nreverse (string-to-list s)) ""))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user