branch: externals/denote
commit 76c2e27e8050d21997094ff074a5edf732a767a8
Author: Protesilaos Stavrou <[email protected]>
Commit: Protesilaos Stavrou <[email protected]>
Document how users can have a custom identifier without "T" in it
---
README.org | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/README.org b/README.org
index ae70c2b7a1..ab2580b513 100644
--- a/README.org
+++ b/README.org
@@ -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