branch: externals/denote commit cbd39ada7285789e414f6f0b7435537661e59656 Author: Protesilaos Stavrou <i...@protesilaos.com> Commit: Protesilaos Stavrou <i...@protesilaos.com>
Document journal entry with check for existing daily note --- README.org | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/README.org b/README.org index 80bc5080ff..669861022c 100644 --- a/README.org +++ b/README.org @@ -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