From a9f3383bbd72dc93b2aaaa45c59dafc74321021f Mon Sep 17 00:00:00 2001 From: Tobias Ostner Date: Tue, 13 Jun 2023 09:43:23 +0200 Subject: [PATCH] Configure denote with directory and journal function --- .emacs.d/init.el | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 62e6c99..7f7d0e7 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -116,7 +116,23 @@ (use-package denote :config - (setq denote-directory (expand-file-name "~/TobCloud/org/notes"))) + (setq denote-directory (expand-file-name "~/TobCloud/org/notes")) + (defun to/denote-journal() + "Create an entry tagged 'journal' with the data 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* ((today (format-time-string "%A %e %B %Y")) + (string (denote-sluggify today)) + (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 today '("journal"))))))) (use-package dired :ensure nil