[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org 5a52ee57d4 1/4: org-macs.el: Move UUID related code
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org 5a52ee57d4 1/4: org-macs.el: Move UUID related code |
Date: |
Wed, 22 Mar 2023 15:58:56 -0400 (EDT) |
branch: externals/org
commit 5a52ee57d4a04334ce39162119fa271e6d579d9a
Author: Matthew Trzcinski <matt@excalamus.com>
Commit: Matthew Trzcinski <matt@excalamus.com>
org-macs.el: Move UUID related code
* org-id.el (org-id-uuid): Move to org-macs.el.
* org.el (org-uuidgen-p): Move to org-macs.el. Expose regexp used to
match UUID.
* org-macs.el (org-uuid-regexp): Refactor `org-uuidgen-p' to expose
regexp used to match UUID.
---
lisp/org-id.el | 24 ------------------------
lisp/org-macs.el | 32 ++++++++++++++++++++++++++++++++
lisp/org.el | 4 ----
3 files changed, 32 insertions(+), 28 deletions(-)
diff --git a/lisp/org-id.el b/lisp/org-id.el
index 490e4ddee5..aa9610f169 100644
--- a/lisp/org-id.el
+++ b/lisp/org-id.el
@@ -399,30 +399,6 @@ 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)
- (org-time-convert-to-list nil)
- (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-int-to-b36-one-digit (integer)
"Convert INTEGER between 0 and 61 into a single character 0..9, A..Z, a..z."
(cond
diff --git a/lisp/org-macs.el b/lisp/org-macs.el
index 946e19e049..00979c2edc 100644
--- a/lisp/org-macs.el
+++ b/lisp/org-macs.el
@@ -829,6 +829,29 @@ When NEXT is non-nil, check the next line instead."
When NEXT is non-nil, check the next line instead."
(org--line-empty-p 2))
+(defun org-id-uuid ()
+ "Return string with random (version 4) UUID."
+ (let ((rnd (md5 (format "%s%s%s%s%s%s%s"
+ (random)
+ (org-time-convert-to-list nil)
+ (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))))
;;; Motion
@@ -948,6 +971,15 @@ return nil."
(require 'ffap)
(and ffap-url-regexp (string-match-p ffap-url-regexp s)))
+(defconst org-uuid-regexp
+
"\\`[0-9a-f]\\{8\\}-[0-9a-f]\\{4\\}-[0-9a-f]\\{4\\}-[0-9a-f]\\{4\\}-[0-9a-f]\\{12\\}\\'"
+ "Regular expression matching a universal unique identifier (UUID).")
+
+(defun org-uuidgen-p (s)
+ "Is S an ID created by UUIDGEN?"
+ (string-match org-uuid-regexp (downcase s)))
+
+
;;; String manipulation
diff --git a/lisp/org.el b/lisp/org.el
index c5ea3ebb73..23cb6012d8 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -18457,10 +18457,6 @@ With prefix arg UNCOMPILED, load the uncompiled
versions."
(setq s (replace-match "\\vert" t t s)))
s)
-(defun org-uuidgen-p (s)
- "Is S an ID created by UUIDGEN?"
- (string-match
"\\`[0-9a-f]\\{8\\}-[0-9a-f]\\{4\\}-[0-9a-f]\\{4\\}-[0-9a-f]\\{4\\}-[0-9a-f]\\{12\\}\\'"
(downcase s)))
-
(defun org-in-src-block-p (&optional inside element)
"Whether point is in a code source block.
When INSIDE is non-nil, don't consider we are within a source