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

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

[elpa] externals/denote 8b005edd2d 12/17: Make some front matter functio


From: ELPA Syncer
Subject: [elpa] externals/denote 8b005edd2d 12/17: Make some front matter functions ready to handle nil dates and empty identifiers
Date: Sun, 10 Nov 2024 00:57:52 -0500 (EST)

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

    Make some front matter functions ready to handle nil dates and empty 
identifiers
---
 denote.el | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/denote.el b/denote.el
index 3f8092b670..c046df2842 100644
--- a/denote.el
+++ b/denote.el
@@ -1559,7 +1559,10 @@ Consult the `denote-file-types' for how this is used."
   "Extract date object from front matter DATE-STRING.
 
 Consult the `denote-file-types' for how this is used."
-  (date-to-time (denote-trim-whitespace date-string)))
+  (let ((date-string (denote-trim-whitespace date-string)))
+    (if (string-empty-p date-string)
+        nil
+      (date-to-time date-string))))
 
 (defvar denote-file-types
   '((org
@@ -2125,6 +2128,8 @@ which case it is not added to the base file name."
   "Expand DATE in an appropriate format for FILE-TYPE."
   (let ((format denote-date-format))
     (cond
+     ((null date)
+      "")
      (format
       (format-time-string format date))
      ((when-let* ((fn (denote--date-value-function file-type)))
@@ -2950,7 +2955,8 @@ If a buffer is visiting the file, its name is updated."
 The TITLE, KEYWORDS, ID, SIGNATURE, and FILE-TYPE are passed from the
 renaming command and are used to construct a new front matter block if
 appropriate."
-  (when-let* ((new-front-matter (denote--format-front-matter title 
(date-to-time id) keywords id signature file-type)))
+  (when-let* ((date (if (string-empty-p id) nil (date-to-time id)))
+              (new-front-matter (denote--format-front-matter title date 
keywords id signature file-type)))
     (with-current-buffer (find-file-noselect file)
       (goto-char (point-min))
       (insert new-front-matter))))



reply via email to

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