[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote d862b65526 06/12: Define denote-get-identifier f
From: |
ELPA Syncer |
Subject: |
[elpa] externals/denote d862b65526 06/12: Define denote-get-identifier function |
Date: |
Sun, 11 Feb 2024 03:57:53 -0500 (EST) |
branch: externals/denote
commit d862b655268f051cd7153047adec0223c8daca1a
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Define denote-get-identifier function
The idea is to streamline how we do the 'format-time-string', so that
we do not get any weird bugs.
---
README.org | 6 ++++++
denote.el | 8 ++++++++
tests/denote-test.el | 6 ++++++
3 files changed, 20 insertions(+)
diff --git a/README.org b/README.org
index 1d6ea37b63..de1ce3a03c 100644
--- a/README.org
+++ b/README.org
@@ -4086,6 +4086,12 @@ might change them without further notice.
+ Function ~denote-retrieve-filename-signature~ :: Extract signature
from =FILE= name, if present, else return nil.
+#+findex: denote-get-identifier
++ Function ~denote-get-identifier~ :: Convert =DATE= into a Denote
+ identifier using ~denote-id-format~. =DATE= is parsed by
+ ~denote-valid-date-p~. If =DATE= is nil, use the current time.
+ [ Part of {{{development-version}}}. ]
+
#+findex: denote-create-unique-file-identifier
+ Function ~denote-create-unique-file-identifier~ :: Create a new unique
=FILE= identifier. Test that the identifier is unique among
diff --git a/denote.el b/denote.el
index 05da6644dd..dbd2eb6e11 100644
--- a/denote.el
+++ b/denote.el
@@ -1548,6 +1548,14 @@ To create a new one, refer to the function
(or (denote-retrieve-filename-identifier file)
(error "Cannot find `%s' as a file with a Denote identifier" file)))
+(defun denote-get-identifier (&optional date)
+ "Convert DATE into a Denote identifier using `denote-id-format'.
+DATE is parsed by `denote-valid-date-p'. If DATE is nil, use the
+current time."
+ (format-time-string
+ denote-id-format
+ (when date (denote-valid-date-p date))))
+
(defun denote-create-unique-file-identifier (file used-ids &optional date)
"Generate a unique identifier for FILE not in USED-IDS hash-table.
diff --git a/tests/denote-test.el b/tests/denote-test.el
index 1231cef1d2..04b83f0413 100644
--- a/tests/denote-test.el
+++ b/tests/denote-test.el
@@ -404,6 +404,12 @@ Extend what we do in
`denote-test--denote-file-type-extensions'."
(equal (denote-convert-file-name-keywords-to-crm "_denote") "denote")
(equal (denote-convert-file-name-keywords-to-crm "") ""))))
+(ert-deftest denote-test--denote-get-identifier ()
+ "Test that `denote-get-identifier' returns an identifier."
+ (should (and (equal (denote-get-identifier) (format-time-string
denote-id-format (current-time)))
+ (equal (denote-get-identifier "2024-02-01 10:34")
"20240201T103400")))
+ (should-error (denote-get-identifier "Invalid date")))
+
;;;; denote-journal-extras.el
(require 'denote-journal-extras)
- [elpa] externals/denote updated (9353d23aa4 -> 55e923ffc5), ELPA Syncer, 2024/02/11
- [elpa] externals/denote e66f275c15 01/12: Ensure that denote-surround-with-quotes does not return "nil" if S is nil, ELPA Syncer, 2024/02/11
- [elpa] externals/denote a2229e03ff 09/12: Simplify 'denote-parse-date' now that 'denote-valid-date-p' does the work, ELPA Syncer, 2024/02/11
- [elpa] externals/denote d862b65526 06/12: Define denote-get-identifier function,
ELPA Syncer <=
- [elpa] externals/denote 9dced4b7fd 07/12: Harden the conditionality of denote-valid-date-p, ELPA Syncer, 2024/02/11
- [elpa] externals/denote af17af9f2b 04/12: Move a helper function above where it is first called, ELPA Syncer, 2024/02/11
- [elpa] externals/denote 07e8d0bf90 08/12: Clarify the documentation of denote-valid-date-p, ELPA Syncer, 2024/02/11
- [elpa] externals/denote 121ed6d04d 11/12: Use the new 'denote-get-identifier' where appropriate, ELPA Syncer, 2024/02/11
- [elpa] externals/denote 6c503ed953 02/12: Rename denote-surround-with-quotes to denote-format-string-for-md-front-matter, ELPA Syncer, 2024/02/11
- [elpa] externals/denote 675f5e44ba 03/12: Add denote-format-string-for-org-front-matter, ELPA Syncer, 2024/02/11
- [elpa] externals/denote 2339e51633 05/12: Rename 'denote--valid-date' to 'denote-valid-date-p', ELPA Syncer, 2024/02/11
- [elpa] externals/denote 55e923ffc5 12/12: Make denote-format-file-name also accept nil TITLE and SIGNATURE, ELPA Syncer, 2024/02/11
- [elpa] externals/denote 91f51e6cab 10/12: Use the correct number for the {{{development-version}}} in the docs, ELPA Syncer, 2024/02/11