diff options
author | Matthew Lemon <matt@matthewlemon.com> | 2022-12-08 05:49:20 +0000 |
---|---|---|
committer | Matthew Lemon <matt@matthewlemon.com> | 2022-12-08 05:49:20 +0000 |
commit | e14bdef830d23a295a5f29c19f11aaccac6cc4cd (patch) | |
tree | f0cf5af8ec9ccb2d6f243881c14f709a9893a6b3 | |
parent | a37d23d4cf9894c08c383630fb1278bb3f273884 (diff) |
largely working func to create new journal in denote
Diffstat (limited to '')
-rw-r--r-- | init.el | 35 |
1 files changed, 22 insertions, 13 deletions
@@ -246,6 +246,8 @@ Restart works only on graphic display." (setq coding-system-for-read 'utf-8) (setq coding-system-for-write 'utf-8) + + ;; PACKAGES (use-package denote @@ -258,30 +260,37 @@ 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)) + (day-match? (string-match-p (concat "......0" (number-to-string day-regexp)) 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))) + f))) - (defun mrl/denote-journal () - "Create an entry tagged 'journal' with the date as its title." - (interactive) - (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") +(defun mrl/denote-journal () + "Create an entry tagged 'journal' with the date as its title." + (interactive) + (let* ((today-journal (mapcar #'mrl/is-todays-journal? (directory-files (denote-directory) nil "_journal"))) + (journal (if (> (length today-journal) 1) + (car (cdr today-journal)) + nil))) + (if journal + (progn + (find-file (concat (denote-directory) journal))) + (denote + (format-time-string "%A %e %B %Y") + '("journal"))))) + :bind (("C-c n n" . denote-create-note) + ("C-c n d" . mrl/denote-journal) + ("C-c n t" . denote-type)) ) - +(denote (format-time-string "%A %e %B %Y") '("journal") 'text (concat (denote-directory) "/journals")) ;; Enable vertico (use-package vertico |