فهرست منبع

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.
Kyle Meyer 6 سال پیش
والد
کامیت
d782b01d35
2فایلهای تغییر یافته به همراه9 افزوده شده و 2 حذف شده
  1. 7 0
      lisp/org-compat.el
  2. 2 2
      lisp/org-id.el

+ 7 - 0
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
 

+ 2 - 2
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)))