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

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

[elpa] externals/denote 259c8caac6 1/2: Make denote-journal-extras--file


From: ELPA Syncer
Subject: [elpa] externals/denote 259c8caac6 1/2: Make denote-journal-extras--filename-date-regexp more robust
Date: Thu, 5 Dec 2024 12:58:25 -0500 (EST)

branch: externals/denote
commit 259c8caac6d88eb0764ca924537386ab42794feb
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>

    Make denote-journal-extras--filename-date-regexp more robust
    
    We want it to work when the journal files are inside a directory and
    we also need it to account for variations of 
denote-file-name-components-order.
    
    Thanks to Samuel Flint for informing me about the previous
    implementation not working inside of a journal subdirectory. This was
    done in issue 485: <https://github.com/protesilaos/denote/issues/485>.
---
 denote-journal-extras.el | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/denote-journal-extras.el b/denote-journal-extras.el
index 481860c548..93d4a4ab8c 100644
--- a/denote-journal-extras.el
+++ b/denote-journal-extras.el
@@ -185,8 +185,13 @@ is internally processed by `denote-valid-date-p'."
 (defun denote-journal-extras--filename-date-regexp (&optional date)
   "Regular expression to match journal entries for today or optional DATE.
 DATE has the same format as that returned by `denote-valid-date-p'."
-  (let* ((identifier (format "%sT[0-9]\\{6\\}" (format-time-string "%Y%m%d" 
date))))
-    (concat "^" identifier "--.*__?.*" 
(denote-journal-extras--keyword-regex))))
+  (let* ((identifier (format "%sT[0-9]\\{6\\}" (format-time-string "%Y%m%d" 
date)))
+         (order denote-file-name-components-order)
+         (id-index (seq-position order 'identifier))
+         (kw-index (seq-position order 'keywords)))
+    (if (> kw-index id-index)
+        (format "%s.*?_%s" identifier (denote-journal-extras--keyword-regex))
+      (format "_%s.*?%s" (denote-journal-extras--keyword-regex) identifier))))
 
 (defun denote-journal-extras--entry-today (&optional date)
   "Return list of files matching a journal for today or optional DATE.



reply via email to

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