diff options
author | Kyle Meyer <kyle@kyleam.com> | 2019-08-18 11:22:36 -0400 |
---|---|---|
committer | Kyle Meyer <kyle@kyleam.com> | 2019-08-18 17:31:05 -0400 |
commit | 24ba689506afd11148865e992e507ddc801b2913 (patch) | |
tree | 6596768cbcfe478513566e03f74a387cbd90158a | |
parent | 4e3a1b3f5a5e1d5534d94c0b5d2e6e2a5fc724da (diff) | |
download | org-mode-24ba689506afd11148865e992e507ddc801b2913.tar.gz |
org-compat: Add time-convert compatibility wrappers
* lisp/org-compat.el (org-time-convert-to-integer)
(org-time-convert-to-list): New defsubt's to replace common
invocations of time-convert (new in Emacs 27).
* lisp/org-compat.el (org-current-time-as-list): Drop in favor of
org-time-convert-to-list.
These will be used to port changes from the Emacs repo.
-rw-r--r-- | lisp/org-compat.el | 16 | ||||
-rw-r--r-- | lisp/org-id.el | 4 |
2 files changed, 12 insertions, 8 deletions
diff --git a/lisp/org-compat.el b/lisp/org-compat.el index cae8a05..2fb623d 100644 --- a/lisp/org-compat.el +++ b/lisp/org-compat.el @@ -90,12 +90,16 @@ is nil)." ;; 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))) +(if (fboundp 'time-convert) + (progn + (defsubst org-time-convert-to-integer (time) + (time-convert time 'integer)) + (defsubst org-time-convert-to-list (time) + (time-convert time 'list))) + (defun org-time-convert-to-integer (time) + (floor (float-time time))) + (defun org-time-convert-to-list (time) + (seconds-to-time (float-time time)))) ;;; Emacs < 26.1 compatibility diff --git a/lisp/org-id.el b/lisp/org-id.el index c8de8dd..52fce54 100644 --- a/lisp/org-id.el +++ b/lisp/org-id.el @@ -357,7 +357,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) - (org-current-time-as-list) + (org-time-convert-to-list nil) (user-uid) (emacs-pid) (user-full-name) @@ -419,7 +419,7 @@ using `org-id-decode'." ;; FIXME: If TIME represents N seconds after the epoch, then ;; this encoding assumes 0 <= N < 110075314176 = (* (expt 36 4) 65536), ;; i.e., that TIME is from 1970-01-01 00:00:00 to 5458-02-23 20:09:36 UTC. - (setq time (or time (org-current-time-as-list))) + (setq time (org-time-convert-to-list nil)) (concat (org-id-int-to-b36 (nth 0 time) 4) (org-id-int-to-b36 (nth 1 time) 4) (org-id-int-to-b36 (nth 2 time) 4))) |