summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGustav Wikström <gustav@whil.se>2019-08-01 23:05:08 +0200
committerGustav Wikström <gustav@whil.se>2019-08-02 17:02:01 +0200
commitb082de626dfae5d0aaca5f4189490b6fbce09658 (patch)
tree217105b43c28b29b8477d98775e759cef589ed53
parent9104c0c52d705cc50b255ab06bed1810aa144d2b (diff)
downloadorg-mode-b082de626dfae5d0aaca5f4189490b6fbce09658.tar.gz
org-id: Additional id method; ISO8601 timestamp
* New choice in org-id-method Timestamps can be chosen as org-id-method. This id-method has the benefit of being human-readable and has synergies with org-attach if one likes to organize attachment directories by timestamp instead of by random names.
-rw-r--r--etc/ORG-NEWS4
-rw-r--r--lisp/org-id.el17
2 files changed, 18 insertions, 3 deletions
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index f1369b5..c66e484 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 492845c..705211d 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)))