protesilaos / denote

Simple notes for Emacs with an efficient file-naming scheme
https://protesilaos.com/emacs/denote
GNU General Public License v3.0
543 stars 55 forks source link

Anchor used in generated filename regexp for journals is incorrect #485

Open swflint opened 7 hours ago

swflint commented 7 hours ago

The implementation of denote-journal-extras--filename-date-regexp is faulty. By using the start-of-line anchor (^) it fails to detect journal files if kept in a denote-journal-extras-directory which is not denote-directory.

swflint commented 7 hours ago

Perhaps the following code would work better?

(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 (if (or (null denote-journal-extras-directory) (string= denote-journal-extras-directory denote-directory))
                "^"
              (format "^%s/" (file-relative-name denote-journal-extras-directory denote-directory)))
            identifier
            "--.*__?.*"
            (denote-journal-extras--keyword-regex))))