[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote a204554b8d 05/17: denote-get-identifier returns
From: |
ELPA Syncer |
Subject: |
[elpa] externals/denote a204554b8d 05/17: denote-get-identifier returns an empty string when date is nil |
Date: |
Sun, 10 Nov 2024 00:57:51 -0500 (EST) |
branch: externals/denote
commit a204554b8d667781881c13b356cd32639d57b96c
Author: Jean-Philippe Gagné Guay <jeanphilippe150@gmail.com>
Commit: Jean-Philippe Gagné Guay <jeanphilippe150@gmail.com>
denote-get-identifier returns an empty string when date is nil
Also make the date parameter mandatory
---
README.org | 4 ++--
denote.el | 19 ++++++++++---------
tests/denote-test.el | 6 ++----
3 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/README.org b/README.org
index 574b3df034..419c450880 100644
--- a/README.org
+++ b/README.org
@@ -5775,8 +5775,8 @@ might change them without further notice.
#+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.
+ identifier using ~denote-id-format~. If =DATE= is nil, return an empty
+ string as the identifier.
#+findex: denote-create-unique-file-identifier
+ Function ~denote-create-unique-file-identifier~ :: Create a new unique
diff --git a/denote.el b/denote.el
index 37af20db03..92e705ae02 100644
--- a/denote.el
+++ b/denote.el
@@ -1867,13 +1867,12 @@ 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)
+(defun denote-get-identifier (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))))
+If DATE is nil, return an empty string as the identifier."
+ (if date
+ (format-time-string denote-id-format date)
+ ""))
(defvar denote--used-ids nil
"Hash table of used identifiers.
@@ -1899,7 +1898,7 @@ To only return an existing identifier, refer to the
function
(let ((id (cond
(date (denote-get-identifier date))
((denote--file-attributes-time file))
- (t (denote-get-identifier)))))
+ (t (denote-get-identifier (current-time))))))
(denote--find-first-unused-id id)))
(defun denote-retrieve-filename-keywords (file)
@@ -2653,7 +2652,7 @@ Use Org's more advanced date selection utility if the
user option
(defun denote-prompt-for-date-return-id ()
"Use `denote-date-prompt' and return it as `denote-id-format'."
- (denote-get-identifier (denote-date-prompt)))
+ (denote-get-identifier (denote-valid-date-p (denote-date-prompt))))
(defvar denote-subdirectory-history nil
"Minibuffer history of `denote-subdirectory-prompt'.")
@@ -2926,7 +2925,9 @@ Org. Otherwise, use the function `denote-file-type' to
return the type."
(defun denote--file-attributes-time (file)
"Return `file-attribute-modification-time' of FILE as identifier."
- (denote-get-identifier (file-attribute-modification-time (file-attributes
file))))
+ (when-let* ((file-modification-time
+ (file-attribute-modification-time (file-attributes file))))
+ (denote-get-identifier file-modification-time)))
(defun denote--revert-dired (buf)
"Revert BUF if appropriate.
diff --git a/tests/denote-test.el b/tests/denote-test.el
index 823daf0674..10c24e9647 100644
--- a/tests/denote-test.el
+++ b/tests/denote-test.el
@@ -395,11 +395,9 @@ does not involve the time zone."
(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 (and (equal (denote-get-identifier nil) "")
(equal (denote-get-identifier 1705644188) "20240119T080308")
- (equal (denote-get-identifier '(26026 4251))
"20240119T080307")))
- (should-error (denote-get-identifier "Invalid date")))
+ (equal (denote-get-identifier '(26026 4251))
"20240119T080307"))))
(ert-deftest denote-test--denote-retrieve-filename-identifier ()
"Test that `denote-retrieve-filename-identifier' returns only the
identifier."
- [elpa] externals/denote updated (b788f7c3d7 -> 344e1a65bb), ELPA Syncer, 2024/11/10
- [elpa] externals/denote a5ecae13cf 04/17: Obsolete denote-parse-date, ELPA Syncer, 2024/11/10
- [elpa] externals/denote 75d4ba1f7e 16/17: Do not add an empty identifier in denote--used-ids, ELPA Syncer, 2024/11/10
- [elpa] externals/denote 9d13ef9082 09/17: Allow identifiers with other formats in denote-format-file-name, ELPA Syncer, 2024/11/10
- [elpa] externals/denote b2ddfc0d3a 02/17: Rename denote--date to denote--format-front-matter-date, ELPA Syncer, 2024/11/10
- [elpa] externals/denote cf4ce27580 01/17: Do not check identifier format in retrieval functions of file name components, ELPA Syncer, 2024/11/10
- [elpa] externals/denote 7cd1461e4b 03/17: Add comment in denote-valid-date-p, ELPA Syncer, 2024/11/10
- [elpa] externals/denote 19164364a8 06/17: Obsolete denote-create-unique-file-identifier, ELPA Syncer, 2024/11/10
- [elpa] externals/denote a204554b8d 05/17: denote-get-identifier returns an empty string when date is nil,
ELPA Syncer <=
- [elpa] externals/denote 89b0525475 07/17: Do not check nil identifier in denote-format-file-name, ELPA Syncer, 2024/11/10
- [elpa] externals/denote b0b19b9ad1 08/17: Allow empty identifier in denote-format-file-name, ELPA Syncer, 2024/11/10
- [elpa] externals/denote 4a2caa43ef 13/17: Handle id in denote--creation-prepare-note-data, ELPA Syncer, 2024/11/10
- [elpa] externals/denote 8f8026bf56 11/17: Change denote and denote-org-capture to make them ready to handle empty identifiers, ELPA Syncer, 2024/11/10
- [elpa] externals/denote 5e21143e22 10/17: Update docstring of denote-format-file-name, ELPA Syncer, 2024/11/10
- [elpa] externals/denote 344e1a65bb 17/17: Merge pull request #476 from jeanphilippegg/date-functions, ELPA Syncer, 2024/11/10
- [elpa] externals/denote 722c1f3934 14/17: Add variable denote-generate-identifier-automatically, ELPA Syncer, 2024/11/10
- [elpa] externals/denote 8b005edd2d 12/17: Make some front matter functions ready to handle nil dates and empty identifiers, ELPA Syncer, 2024/11/10
- [elpa] externals/denote 427ebfed8e 15/17: Add date parameter to denote--add-front-matter, ELPA Syncer, 2024/11/10