diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index f1369b517..c66e48452 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -387,6 +387,10 @@ separator using ~org-agenda-breadcrumbs-separator~. This variable makes it possible to customize the list of commands for the attachment dispatcher. +*** New ID method based on timestamp +If one chooses, it is now possible to create ID's based on timestamp +(ISO8601) instead of UUID by changing org-id-method to ts. + *** New customization: ~org-id-locations-relative~ New customization to make the persisting of org-id-locations between sessions to store links to files as relative instead of absolute. The diff --git a/lisp/org-id.el b/lisp/org-id.el index 492845c1b..705211d1d 100644 --- a/lisp/org-id.el +++ b/lisp/org-id.el @@ -142,11 +142,15 @@ org Org's own internal method, using an encoding of the current time to uuid Create random (version 4) UUIDs. If the program defined in `org-id-uuid-program' is available it is used to create the ID. - Otherwise an internal functions is used." + Otherwise an internal functions is used. + +ts Create ID's based on ISO8601 timestamps (without separators + and without timezone, local time). Precision down to seconds." :group 'org-id :type '(choice (const :tag "Org's internal method" org) - (const :tag "external: uuidgen" uuid))) + (const :tag "external: uuidgen" uuid) + (const :tag "ISO8601 timestamp" ts))) (defcustom org-id-prefix nil "The prefix for IDs. @@ -163,7 +167,7 @@ to have no space characters in them." "Non-nil means add the domain name to new IDs. This ensures global uniqueness of IDs, and is also suggested by the relevant RFCs. This is relevant only if `org-id-method' is -`org'. When uuidgen is used, the domain will never be added. +`org' or `ts'. When uuidgen is used, the domain will never be added. The default is to not use this because we have no really good way to get the true domain, and Org entries will normally not be shared with enough @@ -368,6 +372,13 @@ So a typical ID could look like \"Org:4nd91V40HI\"." (require 'message) (concat "@" (message-make-fqdn)))))) (setq unique (concat etime postfix)))) + ((eq org-id-method 'ts) + (let ((ts (format-time-string "%Y%m%dT%H%M%S")) + (postfix (if org-id-include-domain + (progn + (require 'message) + (concat "@" (message-make-fqdn)))))) + (setq unique (concat ts postfix)))) (t (error "Invalid `org-id-method'"))) (concat prefix unique)))