[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote 9c410b1e2f 2/3: Make used-ids parameter non opti
|
From: |
ELPA Syncer |
|
Subject: |
[elpa] externals/denote 9c410b1e2f 2/3: Make used-ids parameter non optional in denote-create-file-identifier |
|
Date: |
Sun, 5 Nov 2023 03:57:43 -0500 (EST) |
branch: externals/denote
commit 9c410b1e2fc3f3b6be20b3325ec30620e0f0cf54
Author: Jean-Philippe Gagné Guay <jeanphilippe150@gmail.com>
Commit: Jean-Philippe Gagné Guay <jeanphilippe150@gmail.com>
Make used-ids parameter non optional in denote-create-file-identifier
---
README.org | 6 ++----
denote.el | 17 ++++++-----------
2 files changed, 8 insertions(+), 15 deletions(-)
diff --git a/README.org b/README.org
index 1b42bb906f..7b81eb47ab 100644
--- a/README.org
+++ b/README.org
@@ -3827,7 +3827,8 @@ might change them without further notice.
#+findex: denote-create-unique-file-identifier
+ Function ~denote-create-unique-file-identifier~ :: Create a new unique
- =FILE= identifier. The conditions are as follows:
+ =FILE= identifier. Test that the identifier is unique among
+ =USED-IDS=. The conditions are as follows:
- If =DATE= is non-nil, invoke ~denote-prompt-for-date-return-id~.
@@ -3836,9 +3837,6 @@ might change them without further notice.
- As a fallback, derive an identifier from the current time.
- With optional =USED-IDS= as a hash table of identifiers, test that the
- identifier is unique among them.
-
With optional =USED-IDS= as nil, test that the identifier is unique
among all files and buffers in variable ~denote-directory~.
diff --git a/denote.el b/denote.el
index fc460439dd..5796c69d6c 100644
--- a/denote.el
+++ b/denote.el
@@ -1366,8 +1366,8 @@ To create a new one, refer to the function
(when (not no-error)
(error "Cannot find `%s' as a file with a Denote identifier" file)))))
-(defun denote-create-unique-file-identifier (file &optional date used-ids)
- "Generate a unique identifier for FILE.
+(defun denote-create-unique-file-identifier (file used-ids &optional date)
+ "Generate a unique identifier for FILE not in USED-IDS hash-table.
The conditions are as follows:
@@ -1379,18 +1379,13 @@ The conditions are as follows:
- As a fallback, derive an identifier from the current time.
-If USED-IDS hash-table is non-nil, use it, else create and
-populate a new one.
-
To only return an existing identifier, refer to the function
`denote-retrieve-filename-identifier'."
(let ((id (cond
(date (denote-prompt-for-date-return-id))
((denote--file-attributes-time file))
(t (format-time-string denote-id-format)))))
- (if used-ids
- (denote--find-first-unused-id id used-ids)
- (denote--find-first-unused-id id (denote--get-all-used-ids)))))
+ (denote--find-first-unused-id id used-ids)))
(define-obsolete-function-alias
'denote-retrieve-or-create-file-identifier
@@ -2437,7 +2432,7 @@ place."
current-prefix-arg)))
(let* ((dir (file-name-directory file))
(id (or (denote-retrieve-filename-identifier file :no-error)
- (denote-create-unique-file-identifier file ask-date)))
+ (denote-create-unique-file-identifier file
(denote--get-all-used-ids) ask-date)))
(extension (denote-get-file-extension file))
(file-type (denote-filetype-heuristics file))
(title (or title (denote--retrieve-title-or-filename file file-type)))
@@ -2473,7 +2468,7 @@ the changes made to the file: perform them outright."
(file-in-prompt (propertize file 'face 'error))
(dir (file-name-directory file))
(id (or (denote-retrieve-filename-identifier file :no-error)
- (denote-create-unique-file-identifier file nil
used-ids)))
+ (denote-create-unique-file-identifier file used-ids)))
(title (denote-title-prompt
(denote--retrieve-title-or-filename file file-type)
(format "Rename `%s' with title" file-in-prompt)))
@@ -2539,7 +2534,7 @@ Specifically, do the following:
(dolist (file marks)
(let* ((dir (file-name-directory file))
(id (or (denote-retrieve-filename-identifier file :no-error)
- (denote-create-unique-file-identifier file nil
used-ids)))
+ (denote-create-unique-file-identifier file used-ids)))
(signature (denote-retrieve-filename-signature file))
(file-type (denote-filetype-heuristics file))
(title (denote--retrieve-title-or-filename file file-type))