emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/denote 722c1f3934 14/17: Add variable denote-generate-i


From: ELPA Syncer
Subject: [elpa] externals/denote 722c1f3934 14/17: Add variable denote-generate-identifier-automatically
Date: Sun, 10 Nov 2024 00:57:53 -0500 (EST)

branch: externals/denote
commit 722c1f3934046860727d53862db53cd7bb0d07c4
Author: Jean-Philippe Gagné Guay <jeanphilippe150@gmail.com>
Commit: Jean-Philippe Gagné Guay <jeanphilippe150@gmail.com>

    Add variable denote-generate-identifier-automatically
---
 denote.el | 30 +++++++++++++++++++++++-------
 1 file changed, 23 insertions(+), 7 deletions(-)

diff --git a/denote.el b/denote.el
index 74d6baf45c..80236bb479 100644
--- a/denote.el
+++ b/denote.el
@@ -985,6 +985,20 @@ to override what this function returns."
       (denote--make-denote-directory)
       denote-directory)))
 
+;; TODO: Review and fix the features listed in the docstring below before
+;; making this a user option.
+(defvar denote-generate-identifier-automatically t
+  "Make creation and renaming commands automatically create and identifier.
+
+This applies when a note is created or renamed.  The default is to
+always create an identifier automatically.
+
+Valid values are: t, nil, `on-creation', and `on-rename'.
+
+IMPORTANT: Some features are not working with notes that do not have an
+identifier.  Among them are the Dired fontification, identifier and date
+lines updated in front matter, linking (backlinks).")
+
 ;;;;; Sluggification functions
 
 (defun denote-slug-keep-only-ascii (str)
@@ -2491,7 +2505,10 @@ instead of that of the parameter."
          (file-type (denote--valid-file-type (or file-type denote-file-type)))
          (keywords (denote-keywords-sort keywords))
          (date (denote-valid-date-p date))
-         (date (or date (current-time)))
+         (date (cond (date date)
+                     ((or (eq denote-generate-identifier-automatically t)
+                          (eq denote-generate-identifier-automatically 
'on-creation))
+                      (current-time))))
          (id (denote-get-identifier date))
          (id (if (string-empty-p id) id (denote--find-first-unused-id id)))
          (date (if (string-empty-p id) nil (date-to-time id)))
@@ -3162,12 +3179,11 @@ renaming commands."
          ;; condition).
          (unless (denote-file-has-identifier-p file)
            (setq date (denote-valid-date-p (denote-date-prompt)))))))
-    ;; TODO: If the date is still nil, use the modification time of the file 
or the current time.
-    ;; This is done because the absence of an identifier is not supported yet.
-    ;; Once we do, this should be removed or made optional with a user option.
-    (setq date (or date
-                   (file-attribute-modification-time (file-attributes file))
-                   (current-time)))
+    (when (and (null date)
+               (or (eq denote-generate-identifier-automatically t)
+                   (eq denote-generate-identifier-automatically 'on-rename)))
+      (setq date (or (file-attribute-modification-time (file-attributes file))
+                     (current-time))))
     (list title keywords signature date)))
 
 ;;;###autoload



reply via email to

[Prev in Thread] Current Thread [Next in Thread]