Skip to content

Commit 6c75b00

Browse files
yantar92bzg
authored andcommitted
Allow customised ID format for ts' org-id-method'
* lisp/org-id.el (org-id-new): Use `org-id-ts-format' as ID format for `ts' ID generation method. (org-id-ts-format): New custom variable for `ts' ID format. The default value is the same as old hard-coded ID format string. * etc/ORG-NEWS (New option ~org-id-ts-format~): Announce the new custom variable.
1 parent aea1109 commit 6c75b00

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

etc/ORG-NEWS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,12 @@ The new value uses Emacs as the application for opening directory.
404404

405405
Functions in this hook are run after ~org-agenda-filter~ is called.
406406

407+
*** New option ~org-id-ts-format~
408+
409+
Earlier, IDs generated using =ts= method had a hard-coded format (i.e. =20200923T160237.891616=).
410+
The new option allows user to customise the format.
411+
Defaults are unchanged.
412+
407413
** Removed or renamed functions and variables
408414
*** Deprecated ~org-flag-drawer~ function
409415

lisp/org-id.el

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ nil Never use an ID to make a link, instead link using a text search for
128128
:group 'org-id
129129
:type 'string)
130130

131+
(defcustom org-id-ts-format "%Y%m%dT%H%M%S.%6N"
132+
"Default format for IDs generated using `ts' `org-id-method'.
133+
The format should be suitable to pass as an argument to `format-time-string'.")
134+
131135
(defcustom org-id-method 'uuid
132136
"The method that should be used to create new IDs.
133137
@@ -380,7 +384,7 @@ So a typical ID could look like \"Org:4nd91V40HI\"."
380384
(concat "@" (message-make-fqdn))))))
381385
(setq unique (concat etime postfix))))
382386
((eq org-id-method 'ts)
383-
(let ((ts (format-time-string "%Y%m%dT%H%M%S.%6N"))
387+
(let ((ts (format-time-string org-id-ts-format))
384388
(postfix (if org-id-include-domain
385389
(progn
386390
(require 'message)

0 commit comments

Comments
 (0)