From ef0a072d18825265a102acb21c2922760332bf1e Mon Sep 17 00:00:00 2001 From: Jeremy Dormitzer Date: Tue, 14 May 2024 11:54:58 -0400 Subject: [PATCH] Extend daily note to be able to prompt for date --- emacs/.emacs.d/config/init-org.el | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/emacs/.emacs.d/config/init-org.el b/emacs/.emacs.d/config/init-org.el index e8e9a7f..81c61f0 100644 --- a/emacs/.emacs.d/config/init-org.el +++ b/emacs/.emacs.d/config/init-org.el @@ -13,19 +13,24 @@ (interactive) (switch-to-buffer "*org-scratch*") (org-mode)) - (defun org-find-daily-note () - (interactive) + (cl-defun org-find-daily-note (date) + "Find the daily note for DATE, creating it if necessary. + +DATE should be in the format \"YYYY-MM-DD\". If called interactively, default to today's date. If called with\ + a prefix argument, prompt for the date." + + (interactive (list (if current-prefix-arg + (org-read-date nil nil nil "Date: ") + (format-time-string "%Y-%m-%d")))) (let* ((filename (expand-file-name - (format "~/org/daily/%s.org" - (format-time-string "%Y-%m-%d")))) + (format "~/org/daily/%s.org" date))) (file-exists (file-exists-p filename))) (find-file filename) (goto-char (point-min)) (unless file-exists (org-id-get-create) (goto-char (point-max)) - (insert (format "#+title: %s daily note" - (format-time-string "%Y-%m-%d"))) + (insert (format "#+title: %s daily note" date)) (newline)) (goto-char (point-max)))) (org-babel-do-load-languages @@ -87,7 +92,15 @@ (leader-map "ol" #'org-store-link) (leader-map "od" #'org-find-daily-note) (normal org-mode-map "" #'org-return) - (normal org-mode-map "T" #'org-insert-todo-heading)) + (normal org-mode-map "T" #'org-insert-todo-heading) + (org-read-date-minibuffer-local-map "C-k" (lambda () (interactive) + (org-eval-in-calendar '(calendar-backward-week 1))) + "C-j" (lambda () (interactive) + (org-eval-in-calendar '(calendar-forward-week 1))) + "C-h" (lambda () (interactive) + (org-eval-in-calendar '(calendar-backward-day 1))) + "C-l" (lambda () (interactive) + (org-eval-in-calendar '(calendar-forward-day 1))))) (use-package evil-org :after org