[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote 582f38c642 3/4: Add optional DATE in function th
From: |
ELPA Syncer |
Subject: |
[elpa] externals/denote 582f38c642 3/4: Add optional DATE in function that returns identifier |
Date: |
Sat, 8 Oct 2022 08:57:31 -0400 (EDT) |
branch: externals/denote
commit 582f38c642ad6cc35ac93b082617e1f387e67caf
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Add optional DATE in function that returns identifier
---
README.org | 24 ++++++++++++++++++++----
denote.el | 19 +++++++++++++++++--
2 files changed, 37 insertions(+), 6 deletions(-)
diff --git a/README.org b/README.org
index 15f2379708..759b50c9e8 100644
--- a/README.org
+++ b/README.org
@@ -2449,11 +2449,27 @@ might change them without further notice.
one, refer to the ~denote-retrieve-or-create-file-identifier~
function.
+[ The ~denote-retrieve-or-create-file-identifier~ accepts an optional
+ =DATE= argument as part of {{{development-version}}}. ]
+
#+findex: denote-retrieve-or-create-file-identifier
-+ Function ~denote-retrieve-or-create-file-identifier~ :: Extract
- identifier from =FILE= name. To only return an existing identifier
- or create a new one, refer to the function
- ~denote-retrieve-or-create-file-identifier~.
++ Function ~denote-retrieve-or-create-file-identifier~ :: Return
+ =FILE= identifier, generating one if appropriate. The conditions
+ are as follows:
+
+ - If =FILE= has an identifier, return it.
+
+ - If =FILE= does not have an identifier and optional =DATE= is
+ non-nil, invoke ~denote-prompt-for-date-return-id~.
+
+ - If =FILE= does not have an identifier and DATE is nil, use the
+ file attributes to determine the last modified date and format it
+ as an identifier.
+
+ - As a fallback, derive an identifier from the current time.
+
+ To only return an existing identifier, refer to the function
+ ~denote-retrieve-filename-identifier~.
#+findex: denote-retrieve-filename-title
+ Function ~denote-retrieve-filename-title~ :: Extract title from
diff --git a/denote.el b/denote.el
index 25206475e3..d6a17da958 100644
--- a/denote.el
+++ b/denote.el
@@ -1008,13 +1008,28 @@ the function
`denote-retrieve-or-create-file-identifier'."
'denote-retrieve-filename-identifier
"1.0.0")
-(defun denote-retrieve-or-create-file-identifier (file)
- "Return FILE identifier, else generate one.
+(defun denote-retrieve-or-create-file-identifier (file &optional date)
+ "Return FILE identifier, generating one if appropriate.
+
+The conditions are as follows:
+
+- If FILE has an identifier, return it.
+
+- If FILE does not have an identifier and optional DATE is
+ non-nil, invoke `denote-prompt-for-date-return-id'.
+
+- If FILE does not have an identifier and DATE is nil, use the
+ file attributes to determine the last modified date and format
+ it as an identifier.
+
+- As a fallback, derive an identifier from the current time.
+
To only return an existing identifier, refer to the function
`denote-retrieve-filename-identifier'."
(cond
((string-match denote-id-regexp file)
(substring file (match-beginning 0) (match-end 0)))
+ (date (denote-prompt-for-date-return-id))
((denote--file-attributes-time file))
(t (format-time-string denote-id-format))))