summaryrefslogtreecommitdiffstats
path: root/init.el
diff options
context:
space:
mode:
authorMatthew Lemon <matt@matthewlemon.com>2022-12-07 21:28:58 +0000
committerMatthew Lemon <matt@matthewlemon.com>2022-12-07 21:28:58 +0000
commit5bc3e0c4d74a45dfba433565e3c8b74e9186adde (patch)
tree736ad61730390929cb572f98b1875f23a2d41666 /init.el
parentab9d03a979ed04db7d6a76e95e366a6714e9d474 (diff)
func to detect today's journal in denote
Diffstat (limited to 'init.el')
-rw-r--r--init.el23
1 files changed, 20 insertions, 3 deletions
diff --git a/init.el b/init.el
index 1551903..04ccb93 100644
--- a/init.el
+++ b/init.el
@@ -258,14 +258,31 @@ Restart works only on graphic display."
(setq denote-file-type nil)
(setq denote-prompts '(title keywords))
(setq denote-date-prompt-use-org-read-date t)
+ (defun mrl/is-todays-journal? (f)
+ "If f is today's journal in denote, f is returned"
+ (let* ((month-regexp (car (calendar-current-date)))
+ (day-regexp (nth 1 (calendar-current-date)))
+ (year-regexp (nth 2 (calendar-current-date)))
+ (journal-files (directory-files (denote-directory) nil "_journal"))
+ (day-match?
+ (string-match-p "\\(monday\\|tuesday\\|wednesday\\|thursday\\|friday\\|saturday\\|sunday\\)" f))
+ (year-match? (string-match-p (concat "^" (number-to-string year-regexp)) f))
+ (month-match? (string-match-p (concat (number-to-string month-regexp) "..T") f)))
+ (when (and day-match? year-match? month-match?)
+ f)))
+
(defun mrl/denote-journal ()
"Create an entry tagged 'journal' with the date as its title."
(interactive)
- (denote
- (format-time-string "%A %e %B %Y") ; format like Tuesday 14 June 2022
- '("journal"))) ; multiple keywords are a list of strings: '("one" "two")
+ (let ((today-journal (mapcar #'mrl/is-todays-journal? (directory-files (denote-directory) nil "_journal"))))
+ (if 'today-journal
+ (find-file (concat (denote-directory) (car today-journal)))
+ (denote
+ (format-time-string "%A %e %B %Y")
+ '("journal"))))) ; multiple keywords are a list of strings: '("one" "two")
)
+
;; Enable vertico
(use-package vertico
:ensure t