Document journal entry with check for existing daily note

This commit is contained in:
Protesilaos Stavrou 2023-05-11 17:58:21 +03:00
parent 8f6acf01ca
commit cbd39ada72
No known key found for this signature in database
GPG key ID: 99BD6459CD5CA3EA

View file

@ -2138,6 +2138,33 @@ Of course, you can always set up the function so that it asks for a
'("journal")))
#+end_src
The above snippets do not check if a daily entry exists: they always
create a new one. The idea is that one may want to write multiple
journal entries per day. Another approach is to create a single entry
on a given day, in which case the command must be repurposed to
surface the existing note, if present. As with ~my-denote-journal~
above, the title is formatted as =Tuesday 14 June 2022=.
#+begin_src emacs-lisp
(defun my-denote-journal ()
"Create an entry tagged 'journal' with the date as its title.
If a journal for the current day exists, visit it. If multiple
entries exist, prompt with completion for a choice between them.
Else create a new file."
(interactive)
(let* ((string (denote-sluggify (format-time-string "%A %e %B %Y")))
(files (denote-directory-files-matching-regexp string)))
(cond
((> (length files) 1)
(find-file (completing-read "Select file: " files nil :require-match)))
(files
(find-file (car files)))
(t
(denote
(format-time-string "%A %e %B %Y")
'("journal"))))))
#+end_src
*** Journaling with a timer
:PROPERTIES:
:CUSTOM_ID: h:4af1f81e-e93a-43cc-b344-960032a16d42