Document how users can have a custom identifier without "T" in it

This commit is contained in:
Protesilaos Stavrou 2026-03-06 19:23:10 +02:00
parent e1d16ba77b
commit 76c2e27e80
No known key found for this signature in database
GPG key ID: 99BD6459CD5CA3EA

View file

@ -2791,6 +2791,43 @@ Slightly modified version of `denote-generate-identifier-as-date'."
(my-denote-format-date (or date (current-time))))))))
#+end_src
*** A custom identifier without the time separator
:PROPERTIES:
:CUSTOM_ID: h:d238cd1f-a185-4dbe-a9f3-0dea29273e1f
:END:
The default Denote identifier consists of the date as =YYYYMMDD=, then
the letter =T=, and then the time as =HHMMSS=. Users who do not want
the letter =T= there can use the following:
#+begin_src emacs-lisp
(setq denote-get-identifier-function #'my-denote-generate-identifier-without-time-separator)
(defconst my-denote-date-identifier-format-without-time-separator
(replace-regexp-in-string "T" "" denote-date-identifier-format))
(defun my-denote-generate-identifier-without-time-separator (initial-identifier date)
"Generate an identifier based on DATE.
If INITIAL-IDENTIFIER is not already used, return it. Else, if it is
possible to derive an identifier from it, return this identifier.
Else, use the DATE. If it is nil, use `current-time'.
Slightly modified version of `denote-generate-identifier-as-date'."
(let ((denote-used-identifiers (or denote-used-identifiers (denote--get-all-used-ids))))
(cond ((and initial-identifier
(not (gethash initial-identifier denote-used-identifiers)))
initial-identifier)
((and initial-identifier
(string-match-p denote-date-identifier-regexp initial-identifier)
(date-to-time initial-identifier))
(denote--find-first-unused-id-as-date initial-identifier))
(t
(denote--find-first-unused-id-as-date
(format-time-string my-denote-date-identifier-format-without-time-separator (or date (current-time))))))))
#+end_src
*** A custom identifier to encode publisher data
:PROPERTIES:
:CUSTOM_ID: h:f92cd454-51f4-4403-9061-3b2efaef2851