create log for today

This commit is contained in:
Willem van den Ende
2025-09-09 08:24:21 +01:00
parent 91f744e726
commit f0b92dd983
+15
View File
@@ -30,3 +30,18 @@
:limit 20]))) :limit 20])))
(setq org-agenda-files (collect-org-agenda-files-)) (setq org-agenda-files (collect-org-agenda-files-))
(defun open-today-log ()
"Open today's log file in log/YYYY-MM-DD.md format.
Creates the log directory if it doesn't exist."
(interactive)
(let* ((git-root (locate-dominating-file (or buffer-file-name default-directory) ".git"))
(log-dir (concat (if git-root (file-name-directory git-root) default-directory) "log"))
(date-str (format-time-string "%Y-%m-%d"))
(unless (file-directory-p log-dir)
(make-directory log-dir t))
(let ((file-name (concat log-dir "/" date-str ".md")))
(if (file-exists-p file-name)
(find-file file-name)
(find-file file-name)
(insert (format "# %s\n\n" date-str))))))