summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2018-12-28 18:03:54 -0500
committerKyle Meyer <kyle@kyleam.com>2019-01-13 12:43:04 -0500
commitd782b01d35a474597a31d4c03e92acb850e43c72 (patch)
tree17cbc7afa1a529626587462af09cc4ed79b1dcb3
parent2b6c7e14f2d7c5eac5d3f08d307b7fc73371ee64 (diff)
downloadorg-mode-d782b01d35a474597a31d4c03e92acb850e43c72.tar.gz
org-compat: Add org-current-time-as-list
* lisp/org-compat.el (org-current-time-as-list): New function for compatibility with Emacsen before 27.1. This is a follow-up to the backport of Emacs's 93fe42094.
-rw-r--r--lisp/org-compat.el7
-rw-r--r--lisp/org-id.el4
2 files changed, 9 insertions, 2 deletions
diff --git a/lisp/org-compat.el b/lisp/org-compat.el
index 9b7638d..e3fbed7 100644
--- a/lisp/org-compat.el
+++ b/lisp/org-compat.el
@@ -74,6 +74,13 @@
;; The misspelled variant was made obsolete in Emacs 27.1
(defalias 'pcomplete-uniquify-list 'pcomplete-uniqify-list))
+(defun org-current-time-as-list ()
+ "Compatibility wrapper for `current-time'.
+As of Emacs 27.1, `current-time' callers should not assume a list
+return value."
+ (or (ignore-errors (encode-time nil 'list))
+ (current-time)))
+
;;; Emacs < 26.1 compatibility
diff --git a/lisp/org-id.el b/lisp/org-id.el
index 2054f0c..f4c737f 100644
--- a/lisp/org-id.el
+++ b/lisp/org-id.el
@@ -358,7 +358,7 @@ So a typical ID could look like \"Org:4nd91V40HI\"."
"Return string with random (version 4) UUID."
(let ((rnd (md5 (format "%s%s%s%s%s%s%s"
(random)
- (encode-time nil 'list)
+ (org-current-time-as-list)
(user-uid)
(emacs-pid)
(user-full-name)
@@ -417,7 +417,7 @@ The input I may be a character, or a single-letter string."
"Encode TIME as a 10-digit string.
This string holds the time to micro-second accuracy, and can be decoded
using `org-id-decode'."
- (setq time (encode-time time 'list))
+ (setq time (or time (org-current-time-as-list)))
(concat (org-id-int-to-b36 (nth 0 time) 4)
(org-id-int-to-b36 (nth 1 time) 4)
(org-id-int-to-b36 (or (nth 2 time) 0) 4)))