Here is how to I browse through previsous days. I use file-per-day scheme.
If you are in a buffer: 2022-12-28.org
, how you’re going to
switch to day 2022-12-27.org
or to day 2022-12-29.org
? I used
org-roam-dailies-goto-date
to do such a switch, but the default selection is
based on the current date, not the buffer the user is currently visiting.
The following snippet can help you to navigate through yesterday’s or
tomorrow based on the current daily note.
(require 'ts)
(defun wr/org-roam-dailies-capture-current-daily-date-yesterday (&optional goto keys)
""
(interactive "P")
(if (org-roam-dailies--daily-note-p)
(let* ((ts-default-format "%Y-%m-%d")
(current-date-for-this-buffer (buffer-file-name))
(yesterday-date (ts-format (ts-adjust 'day -1 (ts-parse (file-name-sans-extension
(file-name-nondirectory current-date-for-this-buffer)))))))
(progn
(org-roam-dailies--capture (time-convert (ts-unix (ts-parse yesterday-date))) t keys)
(org-content 2)))
(message "Not in a daily buffer")))
(defun wr/org-roam-dailies-capture-current-daily-date-tomorrow (&optional goto keys)
""
(interactive "P")
(if (org-roam-dailies--daily-note-p)
(let* ((ts-default-format "%Y-%m-%d")
(current-date-for-this-buffer (buffer-file-name))
(tomorrow-date (ts-format (ts-adjust 'day +1 (ts-parse (file-name-sans-extension
(file-name-nondirectory current-date-for-this-buffer)))))))
(progn
(org-roam-dailies--capture (time-convert (ts-unix (ts-parse tomorrow-date))) t keys)
(org-content 2)))
(message "Not in a daily buffer")))
(defhydra wr/hydra-daily-jump (global-map "C-M-; d")
"There is no yesterday and tomorrow. Only present exists."
("j" wr/org-roam-dailies-capture-current-daily-date-yesterday "yesterday")
("k" wr/org-roam-dailies-capture-current-daily-date-tomorrow "tomorrow"))
Hope it is useful for someone.